use of org.broadleafcommerce.openadmin.server.service.persistence.validation.GlobalValidationResult in project BroadleafCommerce by BroadleafCommerce.
the class RowLevelSecurityServiceImpl method validateAddRequest.
@Override
public GlobalValidationResult validateAddRequest(AdminUser currentUser, Entity entity, PersistencePackage persistencePackage) {
GlobalValidationResult validationResult = new GlobalValidationResult(true);
for (RowLevelSecurityProvider provider : getProviders()) {
GlobalValidationResult providerValidation = provider.validateAddRequest(currentUser, entity, persistencePackage);
if (providerValidation.isNotValid()) {
validationResult.setValid(false);
validationResult.addErrorMessage(providerValidation.getErrorMessage());
}
}
return validationResult;
}
use of org.broadleafcommerce.openadmin.server.service.persistence.validation.GlobalValidationResult in project BroadleafCommerce by BroadleafCommerce.
the class AdminSecurityServiceRemote method securityCheck.
@Override
public void securityCheck(PersistencePackage persistencePackage, EntityOperationType operationType) throws ServiceException {
Set<String> ceilingNames = new HashSet<String>();
ceilingNames.add(persistencePackage.getSecurityCeilingEntityFullyQualifiedClassname());
if (!ArrayUtils.isEmpty(persistencePackage.getSectionCrumbs())) {
ceilingNames.addAll(CollectionUtils.transform(Arrays.asList(persistencePackage.getSectionCrumbs()), new Transformer() {
@Override
public Object transform(Object o) {
return ((SectionCrumb) o).getSectionIdentifier();
}
}));
}
Entity entity = persistencePackage.getEntity();
if (persistencePackage.getPersistencePerspectiveItems().containsKey(PersistencePerspectiveItemType.ADORNEDTARGETLIST)) {
if (persistencePackage.getEntity() != null) {
for (Property property : persistencePackage.getProperties()) {
if (property.getName() != null && property.getName().endsWith(".id") && property.getValue() == null) {
entity.addGlobalValidationError("adornedTargetRequired");
throw new ValidationException(entity);
}
}
}
}
GlobalValidationResult globalValidationResult = null;
if (operationType.equals(EntityOperationType.UPDATE)) {
globalValidationResult = rowLevelSecurityService.validateUpdateRequest(getPersistentAdminUser(), entity, persistencePackage);
} else if (operationType.equals(EntityOperationType.REMOVE)) {
globalValidationResult = rowLevelSecurityService.validateRemoveRequest(getPersistentAdminUser(), entity, persistencePackage);
} else if (operationType.equals(EntityOperationType.ADD)) {
globalValidationResult = rowLevelSecurityService.validateAddRequest(getPersistentAdminUser(), entity, persistencePackage);
}
if (globalValidationResult != null) {
if (!globalValidationResult.isValid()) {
if (StringUtils.isEmpty(globalValidationResult.getErrorMessage())) {
entity.addGlobalValidationError("rowLevelSecurityFailed");
} else {
entity.addGlobalValidationErrors(globalValidationResult.getErrorMessages());
}
throw new ValidationException(entity, "Row level security check failed for " + operationType);
}
}
securityCheck(ceilingNames.toArray(new String[ceilingNames.size()]), operationType);
}
use of org.broadleafcommerce.openadmin.server.service.persistence.validation.GlobalValidationResult in project BroadleafCommerce by BroadleafCommerce.
the class RowLevelSecurityServiceImpl method validateRemoveRequest.
@Override
public GlobalValidationResult validateRemoveRequest(AdminUser currentUser, Entity entity, PersistencePackage persistencePackage) {
GlobalValidationResult validationResult = new GlobalValidationResult(true);
for (RowLevelSecurityProvider provider : getProviders()) {
GlobalValidationResult providerValidation = provider.validateRemoveRequest(currentUser, entity, persistencePackage);
if (providerValidation.isNotValid()) {
validationResult.setValid(false);
validationResult.addErrorMessage(providerValidation.getErrorMessage());
}
}
return validationResult;
}
use of org.broadleafcommerce.openadmin.server.service.persistence.validation.GlobalValidationResult in project BroadleafCommerce by BroadleafCommerce.
the class RowLevelSecurityServiceImpl method validateUpdateRequest.
@Override
public GlobalValidationResult validateUpdateRequest(AdminUser currentUser, Entity entity, PersistencePackage persistencePackage) {
GlobalValidationResult validationResult = new GlobalValidationResult(true);
for (RowLevelSecurityProvider provider : getProviders()) {
GlobalValidationResult providerValidation = provider.validateUpdateRequest(currentUser, entity, persistencePackage);
if (providerValidation.isNotValid()) {
validationResult.setValid(false);
validationResult.addErrorMessage(providerValidation.getErrorMessage());
}
}
return validationResult;
}
Aggregations