public void process()

in src/main/java/org/apache/sling/validation/impl/postprocessor/ValidationPostProcessor.java [66:104]


    public void process(SlingHttpServletRequest request, List<Modification> changes) throws Exception {
        // is this globally disabled?
        if (configuration.disabled()) {
            LOG.debug("ValidationPostProcessor globally disabled!");
            return;
        }
        
        String path = request.getResource().getPath();
        if (enabledForPath(path)) {
            LOG.debug("ValidationPostProcessor is enabled for path {}", path);
        } else {
            LOG.debug("ValidationPostProcessor is not enabled for path {}", path);
            return;
        }

        // request.getResource() contains the old resource (might even be the non-existing one), 
        // therefore retrieve the transient new resource at the same path
        Resource newResource = request.getResourceResolver().getResource(request.getResource().getPath());
        if (newResource == null) {
            LOG.debug("Could not find new/modified resource at {} to validate", request.getResource().getPath());
            return;
        }
        // get model for resource type
        ValidationModel model = validationService.getValidationModel(newResource, configuration.considerResourceSuperTypes());
        if (model == null) {
            if (configuration.failForMissingValidationModels()) {
                throw new IllegalStateException("Could not find validation model for resource type " + newResource.getResourceType());
            } else {
                LOG.debug("Could not find validation model for resource type {} -> skip validation", newResource.getResourceType());
                return;
            }
        }
        ValidationResult validationResult = validationService.validate(newResource, model);
        if (!validationResult.isValid()) {
            throw new InvalidResourcePostProcessorException(validationResult, request.getResourceBundle(null));
        } else {
            LOG.debug("Successfully validated modified/created resource at '{}'", request.getResource().getPath());
        }
    }