Search in sources :

Example 1 with CleanStringException

use of org.broadleafcommerce.common.security.service.CleanStringException in project BroadleafCommerce by BroadleafCommerce.

the class DynamicEntityRemoteService method cleanEntity.

protected void cleanEntity(Entity entity) throws ServiceException {
    Property currentProperty = null;
    try {
        for (Property property : entity.getProperties()) {
            currentProperty = property;
            property.setRawValue(property.getValue());
            property.setValue(exploitProtectionService.cleanStringWithResults(property.getValue()));
            property.setUnHtmlEncodedValue(StringEscapeUtils.unescapeHtml(property.getValue()));
        }
    } catch (CleanStringException e) {
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < e.getCleanResults().getNumberOfErrors(); j++) {
            sb.append("\n");
            sb.append(j + 1);
            sb.append(") ");
            sb.append((String) e.getCleanResults().getErrorMessages().get(j));
            sb.append("\n");
        }
        sb.append("\nNote - Antisamy policy in effect. Set a new policy file to modify validation behavior/strictness.");
        entity.addValidationError(currentProperty.getName(), sb.toString());
    }
}
Also used : CleanStringException(org.broadleafcommerce.common.security.service.CleanStringException) Property(org.broadleafcommerce.openadmin.dto.Property)

Aggregations

CleanStringException (org.broadleafcommerce.common.security.service.CleanStringException)1 Property (org.broadleafcommerce.openadmin.dto.Property)1