Map<String, FieldMetadata> unfilteredProperties, Boolean setId, Boolean validateUnsubmittedProperties) throws ValidationException {
Map<String, FieldMetadata> mergedProperties = filterOutCollectionMetadata(unfilteredProperties);
FieldManager fieldManager = getFieldManager();
boolean handled = false;
for (FieldPersistenceProvider fieldPersistenceProvider : fieldPersistenceProviders) {
FieldProviderResponse response = fieldPersistenceProvider.filterProperties(new AddFilterPropertiesRequest(entity), unfilteredProperties);
if (FieldProviderResponse.NOT_HANDLED != response) {
handled = true;
}
if (FieldProviderResponse.HANDLED_BREAK == response) {
break;
}
}
if (!handled) {
defaultFieldPersistenceProvider.filterProperties(new AddFilterPropertiesRequest(entity), unfilteredProperties);
}
try {
for (Property property : entity.getProperties()) {
BasicFieldMetadata metadata = (BasicFieldMetadata) mergedProperties.get(property.getName());
Class<?> returnType;
if (!property.getName().contains(FieldManager.MAPFIELDSEPARATOR) && !property.getName().startsWith("__")) {
Field field = fieldManager.getField(instance.getClass(), property.getName());
if (field == null) {
LOG.debug("Unable to find a bean property for the reported property: " + property.getName() + ". Ignoring property.");
continue;
}
returnType = field.getType();
} else {
if (metadata == null) {
LOG.debug("Unable to find a metadata property for the reported property: " + property.getName() + ". Ignoring property.");
continue;
}
returnType = getMapFieldType(instance, fieldManager, property);
if (returnType == null) {
returnType = getBasicBroadleafType(metadata.getFieldType());
}
}
if (returnType == null) {
throw new IllegalAccessException("Unable to determine the value type for the property ("+property.getName()+")");
}
String value = property.getValue();
if (metadata != null) {
Boolean mutable = metadata.getMutable();
Boolean readOnly = metadata.getReadOnly();
if (metadata.getFieldType().equals(SupportedFieldType.BOOLEAN)) {
if (value == null) {
value = "false";
}
}
if ((mutable == null || mutable) && (readOnly == null || !readOnly)) {
if (value != null) {
handled = false;
PopulateValueRequest request = new PopulateValueRequest(setId,
fieldManager, property, metadata, returnType, value, persistenceManager, this);
boolean attemptToPopulate = true;
for (PopulateValueRequestValidator validator : populateValidators) {
PropertyValidationResult validationResult = validator.validate(request, instance);
if (!validationResult.isValid()) {
entity.addValidationError(property.getName(), validationResult.getErrorMessage());
attemptToPopulate = false;
}
}
if (attemptToPopulate) {
for (FieldPersistenceProvider fieldPersistenceProvider : fieldPersistenceProviders) {
FieldProviderResponse response = fieldPersistenceProvider.populateValue(request, instance);
if (FieldProviderResponse.NOT_HANDLED != response) {
handled = true;
}
if (FieldProviderResponse.HANDLED_BREAK == response) {
break;