Class EntityValidatorServiceImpl
- All Implemented Interfaces:
EntityValidatorService
- Direct Known Subclasses:
BeanValidationEntityValidatorServiceImpl
Property from the given Entity according to the
ValidationConfigurations associated with it.- Author:
- Phillip Verheyden
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected List<GlobalPropertyValidator>protected static final org.apache.commons.logging.Logprotected RowLevelSecurityService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetTypeHierarchy(Entity entity) Returns the type hierarchy of the given entity in ascending order of type, stopping at ObjectvoidvoidsetGlobalEntityValidators(List<GlobalPropertyValidator> globalEntityValidators) Set the global validators that will be run on every entity that is attempted to be saved in the admin.voidvalidate(Entity submittedEntity, Serializable instance, Map<String, FieldMetadata> propertiesMetadata, RecordHelper recordHelper, boolean validateUnsubmittedProperties) Validate the given entity.
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG -
globalEntityValidators
-
applicationContext
@Autowired protected org.springframework.context.ApplicationContext applicationContext -
securityService
-
-
Constructor Details
-
EntityValidatorServiceImpl
public EntityValidatorServiceImpl()
-
-
Method Details
-
populateBroadleafValidatorMap
@PostConstruct public void populateBroadleafValidatorMap() -
validate
public void validate(Entity submittedEntity, @Nullable Serializable instance, Map<String, FieldMetadata> propertiesMetadata, RecordHelper recordHelper, boolean validateUnsubmittedProperties) Description copied from interface:EntityValidatorServiceValidate the given entity. Implementers should setEntity.setValidationFailure(boolean)appropriately. Validation is invoked after the entire instance has been populated according toBasicPersistenceModule.createPopulatedInstance(Serializable, Entity, Map, Boolean).- Specified by:
validatein interfaceEntityValidatorService- Parameters:
submittedEntity- DTO representation of instanceinstance- actual domain representation of submittedEntity. If this is null, allPropertyValidators will be skipped, as this instance type is consulted to match whether or not the properties from propertiesMetadata are applicable and should be validatedpropertiesMetadata- all of the merged properties metadata for the givenEntityvalidateUnsubmittedProperties- if set to true, will ignore validation for properties that weren't submitted along with the entity
-
getTypeHierarchy
Returns the type hierarchy of the given entity in ascending order of type, stopping at Object
For instance, if this entity's
Entity.getType()isProductBundleImpl, then the result will be:[org.broadleafcommerce.core.catalog.domain.ProductBundleImpl, org.broadleafcommerce.core.catalog.domain.ProductImpl]
- Parameters:
entity-- Returns:
-
getGlobalEntityValidators
- Specified by:
getGlobalEntityValidatorsin interfaceEntityValidatorService- Returns:
- the global validators that will be executed for every
Entity
-
setGlobalEntityValidators
Description copied from interface:EntityValidatorServiceSet the global validators that will be run on every entity that is attempted to be saved in the admin. Global validators are useful to operate on things like field types and other scenarios that could occur with a number of entities. Rather than being required to define a
ValidationConfigurationon all of those properties, this can more conveniently validate that set of properties.An example of a global validator in Broadleaf is the
RequiredPropertyValidatorwhich will ensure that every property that is marked as required will fail validation if a value is unset.- Specified by:
setGlobalEntityValidatorsin interfaceEntityValidatorService- Parameters:
globalEntityValidators- the globalEntityValidators to set
-