Author: kwin Date: Mon Jun 29 13:46:08 2015 New Revision: 1688218 URL: http://svn.apache.org/r1688218 Log: SLING-4822 document changes
Modified: sling/site/trunk/content/documentation/bundles/validation.mdtext Modified: sling/site/trunk/content/documentation/bundles/validation.mdtext URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/validation.mdtext?rev=1688218&r1=1688217&r2=1688218&view=diff ============================================================================== --- sling/site/trunk/content/documentation/bundles/validation.mdtext (original) +++ sling/site/trunk/content/documentation/bundles/validation.mdtext Mon Jun 29 13:46:08 2015 @@ -24,11 +24,20 @@ To validate a resource one first needs t // give out error message that the validation model is invalid! } -Apart from that it is also possible to validate resources including all child resources having their own validation model (i.e. a merged view of the validation models is applied). The appropriate validation model is being looked up by getting the resource type for each node. Since by default the JCR will return the primary type in case there is no `sling:resourceType` property found on the node, either the 2nd parameter `enforceValidation` should be set to `false` or some resource types must be explicitly ignored to also properly support validation models which have children on its own. +Apart from that it is also possible to validate resources including all child resources having their own validation model (i.e. a merged view of the validation models is applied). The appropriate validation model is being looked up by getting the resource type for each node. Since by default the JCR will return the primary type in case there is no `sling:resourceType` property found on the node, either the 2nd parameter `enforceValidation` should be set to `false` or some resource types must be explicitly ignored by the given filter in the 3rd parameter `filter` to also properly support validation models which have children resources on their own. ::java try { - ValidationResult result = validationService.validateAllResourceTypesInResource(resource, false, null); + Predicate ignoreResourceType1Predicate = new Predicate() { + public boolean evaluate(Object object) { + Resource resource = (Resource) object; + if ("resourcetype1".equals(resource.getResourceType())) { + return false; + } + return true; + } + } + ValidationResult result = validationService.validateResourceRecursively(resource, false, ignoreResourceType1Predicate); if (!result.isValid()) { // give out validation messages from result.get }