Class DefaultValidationService
java.lang.Object
de.hybris.platform.servicelayer.internal.service.AbstractService
de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
de.hybris.platform.validation.services.impl.DefaultValidationService
- All Implemented Interfaces:
ValidationService,Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
Validation service which by default use HybrisHibernateValidator. Service exposes two main features: 1) validation
methods 2) validation engine reloading
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO -
Field Summary
FieldsFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManagerFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns all activeconstraint groupswhich are bound to the current session.protected Class<?>Deprecated, for removal: This API element is subject to removal in a future version.Returns the default constraint group (which is created during creation of eccencial data).protected javax.validation.ConfigurationgetOrCreateConfiguration(boolean replace) protected booleanprotected ConfigurableHybrisConstraintViolationDeprecated, for removal: This API element is subject to removal in a future version.uselookupViolation(ConstraintViolation)insteadprotected Set<HybrisConstraintViolation>lookupViolation(javax.validation.ConstraintViolation violation) booleanReturnstrueif the given constraint was modified (seeItemModel.getModifiedtime()) after the last reload (ValidationService.reloadValidationEngine()) of the validation engine.voidJust set a flag , lazy with first validation engine will be reloaded.voidSets the given collection with theConstraintGroupModels to the current session context.voidsetConstraintDao(ConstraintDao constraintDao) voidsetConstraintsExtractor(ConstraintsExtractor constraintsExtractor) voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService) voidvoidsetViolationFactory(ConstraintViolationFactory violationFactory) voidMethod removes all constraints available forValidator, since it call no violation should be noticed.Validates the givenmodelorPojo.validate(T object, Collection<ConstraintGroupModel> groups) Validates the givenmodelorPojo.voidCreates TEST validation configuration using given constraint model.protected Set<HybrisConstraintViolation>validateLocalizedConstraint(Object object, LocalizedAttributeConstraint localizedConstraint, Class<?>... groups) method validates theobject's localized attribute defined inlocalizedConstraintin context of provided ingroupsconstraint groups.validateProperty(T object, String propertyName, Class<?>... groups) Validates all constraints placed on the property ofobjectnamedpropertyName.validateProperty(T object, String propertyName, Collection<ConstraintGroupModel> groups) Validates all constraints placed on the property ofobjectnamedpropertyName.validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) Validates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue.validateValue(Class<T> beanType, String propertyName, Object value, Collection<ConstraintGroupModel> groups) Validates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalueMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Field Details
-
violationFactory
-
-
Constructor Details
-
DefaultValidationService
public DefaultValidationService()
-
-
Method Details
-
getOrCreateConfiguration
protected javax.validation.Configuration getOrCreateConfiguration(boolean replace) -
reloadValidationEngine
public void reloadValidationEngine()Just set a flag , lazy with first validation engine will be reloaded.- Specified by:
reloadValidationEnginein interfaceValidationService
-
needReloadOfValidationEngine
Description copied from interface:ValidationServiceReturnstrueif the given constraint was modified (seeItemModel.getModifiedtime()) after the last reload (ValidationService.reloadValidationEngine()) of the validation engine.- Specified by:
needReloadOfValidationEnginein interfaceValidationService- Parameters:
model- the constraint- Returns:
falseotherwise
-
validateConstraint
Description copied from interface:ValidationServiceCreates TEST validation configuration using given constraint model. Does NOT influence current configuration of validation engine. When invalid constraint model is given throws ValidationException.- Specified by:
validateConstraintin interfaceValidationService- Parameters:
model- the constraint
-
validate
public <T> Set<HybrisConstraintViolation> validate(T object, Collection<ConstraintGroupModel> groups) Description copied from interface:ValidationServiceValidates the givenmodelorPojo.If groups aren't provided - this method uses for the validation all constrains which are not in any group.
- Specified by:
validatein interfaceValidationService- Parameters:
object- the Model or Pojo to validategroups- A collection ofconstraint groups. Each group contains someconstraints. Use an empty collection for validate agains the default constraints.- Returns:
- a set with
ConstraintViolations or an empty set if no validation was found.
-
validate
Description copied from interface:ValidationServiceValidates the givenmodelorPojo.Same as
ValidationService.validate(Object, Collection)but here the constraint group interfaces must be provided. If not constraint group interface is provided the default constraint group is asumed per default.- Specified by:
validatein interfaceValidationService- Parameters:
object- the model or pojo to validategroups- a class array which contains the group marker interfaces.- Returns:
- a set with constraint violations or an empty set if no validation was found.
-
getClassesForLocalizedAttributeConstraints
-
getClassForLocalizedAttributeConstraints
@Deprecated(since="2005.0", forRemoval=true) protected Class<?> getClassForLocalizedAttributeConstraints(Object object) Deprecated, for removal: This API element is subject to removal in a future version. -
getClassesForPropertyValidationLocalizedAttributeConstraints
-
isMultiLanguageValidationDisabled
protected boolean isMultiLanguageValidationDisabled() -
validateLocalizedConstraint
protected Set<HybrisConstraintViolation> validateLocalizedConstraint(Object object, LocalizedAttributeConstraint localizedConstraint, Class<?>... groups) method validates theobject's localized attribute defined inlocalizedConstraintin context of provided ingroupsconstraint groups. The validation will be performed on localized values of the attribute only for locales defined inlocalizedConstraint.- Parameters:
object- object, which attribute should be validatedlocalizedConstraint- constraint defining the attribute which should be validated and the locales of the attribute that should be validatedgroups- A collection ofconstraint groups. Each group contains nconstraints. Use an empty collection for validate against the default constraints.- Returns:
- constraint violations or an empty Set if none
-
validateProperty
public <T> Set<HybrisConstraintViolation> validateProperty(T object, String propertyName, Collection<ConstraintGroupModel> groups) Description copied from interface:ValidationServiceValidates all constraints placed on the property ofobjectnamedpropertyName.- Specified by:
validatePropertyin interfaceValidationService- Parameters:
object- object to validatepropertyName- property to validate (i.e. field and getter constraints)groups- A collection ofconstraint groups. Each group contains nconstraints. Use an empty collection for validate agains the default constraints.- Returns:
- a set with constraint violations or an empty set if no validation was found.
-
validateProperty
public <T> Set<HybrisConstraintViolation> validateProperty(T object, String propertyName, Class<?>... groups) Description copied from interface:ValidationServiceValidates all constraints placed on the property ofobjectnamedpropertyName.- Specified by:
validatePropertyin interfaceValidationService- Parameters:
object- object to validatepropertyName- property to validate (ie field and getter constraints)groups- group or list of groups targeted for validation (default tojavax.validation.groups.Default)- Returns:
- a set with constraint violations or an empty set if no validation was found.
-
validateValue
public <T> Set<HybrisConstraintViolation> validateValue(Class<T> beanType, String propertyName, Object value, Collection<ConstraintGroupModel> groups) Description copied from interface:ValidationServiceValidates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalueConstraintViolationobjects return null forConstraintViolation.getRootBean()andConstraintViolation.getLeafBean()- Specified by:
validateValuein interfaceValidationService- Parameters:
beanType- the bean typepropertyName- property to validatevalue- property value to validategroups- A collection ofconstraint groups. Each group contains nconstraints. Use an empty collection for validate agains the default constraints.- Returns:
- constraint violations or an empty Set if none
-
validateValue
public <T> Set<HybrisConstraintViolation> validateValue(Class<T> beanType, String propertyName, Object value, Class<?>... groups) Description copied from interface:ValidationServiceValidates all constraints placed on the property namedpropertyNameof the classbeanTypewould the property value bevalue.ConstraintViolationobjects return null forConstraintViolation.getRootBean()andConstraintViolation.getLeafBean().- Specified by:
validateValuein interfaceValidationService- Parameters:
beanType- the bean typepropertyName- property to validatevalue- property value to validategroups- group or list of groups targeted for validation (default tojavax.validation.groups.Default)- Returns:
- constraint violations or an empty Set if none
-
lookupViolation
protected Set<HybrisConstraintViolation> lookupViolation(javax.validation.ConstraintViolation violation) -
lookupViolation
@Deprecated(since="2005.0", forRemoval=true) protected ConfigurableHybrisConstraintViolation lookupViolation()Deprecated, for removal: This API element is subject to removal in a future version.uselookupViolation(ConstraintViolation)instead -
getActiveConstraintGroups
Description copied from interface:ValidationServiceReturns all activeconstraint groupswhich are bound to the current session.- Specified by:
getActiveConstraintGroupsin interfaceValidationService- Returns:
- an empty set if no group is set
-
setActiveConstraintGroups
Description copied from interface:ValidationServiceSets the given collection with theConstraintGroupModels to the current session context. Those groups will be used to validate any given model during modelService.save(...).- Specified by:
setActiveConstraintGroupsin interfaceValidationService- Parameters:
groups- a collection with ConstraintGroupModel
-
unloadValidationEngine
public void unloadValidationEngine()Description copied from interface:ValidationServiceMethod removes all constraints available forValidator, since it call no violation should be noticed.- Specified by:
unloadValidationEnginein interfaceValidationService
-
getDefaultConstraintGroup
Description copied from interface:ValidationServiceReturns the default constraint group (which is created during creation of eccencial data). This group displays (ConstraintGroupModel.getConstraints()) allconstraintswhich ARE NOT in any group. MeaningAbstractConstraintModel.getConstraintGroups()returns an empty set. Setting any constraint to this default group or adding this default group to any constraint results in aModelSavingException! ThegetInterfaceName()returns always "javax.validation.groups.Default" and theIdreturns always "default". Both values cannot be modified!- Specified by:
getDefaultConstraintGroupin interfaceValidationService
-
setConstraintsExtractor
-
setFlexibleSearchService
-
setConstraintDao
-
setLocalizedConstraintsRegistry
-
setViolationFactory
-
getClassesForPropertyValidationLocalizedAttributeConstraints(java.lang.Object)instead