@ProviderType
public interface ValidationService
ValidationService
provides methods for finding ValidationModel
s and to trigger validations against those.Modifier and Type | Method and Description |
---|---|
ValidationModel |
getValidationModel(Resource resource,
boolean considerResourceSuperTypeModels)
Tries to obtain a
ValidationModel that is able to validate the given resource . |
ValidationModel |
getValidationModel(String validatedResourceType,
String resourcePath,
boolean considerResourceSuperTypeModels)
Tries to obtain a
ValidationModel that is able to validate a Resource of type validatedResourceType . |
ValidationResult |
validate(Resource resource,
ValidationModel model)
Validates a
Resource using a specific ValidationModel . |
ValidationResult |
validate(ValueMap valueMap,
ValidationModel model)
|
ValidationResult |
validateResourceRecursively(Resource resource,
boolean enforceValidation,
java.util.function.Predicate<Resource> filter,
boolean considerResourceSuperTypeModels)
Validates a
Resource and all child resources recursively by traversing through the resource tree starting from the given resource. |
@CheckForNull ValidationModel getValidationModel(@Nonnull String validatedResourceType, String resourcePath, boolean considerResourceSuperTypeModels) throws IllegalStateException, IllegalArgumentException
ValidationModel
that is able to validate a Resource
of type validatedResourceType
.validatedResourceType
- the type of Resources
the model validates, should be either relative
(i.e. not start with a "/") or starting with one of the resource resolver's search pathsresourcePath
- the path of the validated resource, may be null
or empty. Must match the applicablePath property of the modelconsiderResourceSuperTypeModels
- if true
will also consider the validation model of the resource super type (recursively), otherwise not.ValidationModel
if one is found, null
otherwiseIllegalStateException
- in case an invalid validation model was foundIllegalArgumentException
- in case validatedResourceType was blank, null
or absolute but outside of the search paths or some other error occurred while retrieving the models.@CheckForNull ValidationModel getValidationModel(@Nonnull Resource resource, boolean considerResourceSuperTypeModels) throws IllegalStateException, IllegalArgumentException
ValidationModel
that is able to validate the given resource
.resource
- the resource for which to obtain a validation modelconsiderResourceSuperTypeModels
- if true
will also consider the validation model of the resource super type (recursively), otherwise not.ValidationModel
if one is found, null
otherwiseIllegalStateException
- in case an invalid validation model was foundIllegalArgumentException
- in case resourceType being set on the given resource is blank, not set or absolute but outside of the search paths or some other error occurred while retrieving the models.@Nonnull ValidationResult validate(@Nonnull Resource resource, @Nonnull ValidationModel model) throws SlingValidationException, IllegalStateException
Resource
using a specific ValidationModel
. If the model
describes a resource tree,
the ResourceResolver
associated with the resource
will be used for retrieving information about the resource
's descendants.resource
- the resource to validatemodel
- the model with which to perform the validationValidationResult
that provides the necessary informationSlingValidationException
- if one validator was called with invalid argumentsIllegalStateException
- if a validator id referenced in the given model could not be resolved@Nonnull ValidationResult validate(@Nonnull ValueMap valueMap, @Nonnull ValidationModel model) throws SlingValidationException
ValueMap
or any object adaptable to a ValueMap
using a specific ValidationModel
. Since the
valueMap
only contains the direct properties of the adapted object, the model
's descendants description should not
be queried for this validation operation.valueMap
- the map to validatemodel
- the model with which to perform the validationValidationResult
that provides the necessary informationSlingValidationException
- if one validator was called with invalid arguments@Nonnull ValidationResult validateResourceRecursively(@Nonnull Resource resource, boolean enforceValidation, java.util.function.Predicate<Resource> filter, boolean considerResourceSuperTypeModels) throws IllegalStateException, IllegalArgumentException, SlingValidationException
Resource
and all child resources recursively by traversing through the resource tree starting from the given resource.
For all resources which are included in the given filter
the according ValidationModel
is retrieved and validation is called on those resources.resource
- the root resource which is validatedenforceValidation
- if true
will throw an IllegalArgumentException
in case a validation model could not be found for a (not-ignored) resourcefilter
- a Predicate
on a resource which is evaluated to determine whether a given resource should be validated. May be null
in which case all resources are validated.
Children of ignored resources are still validated (if this predicate applies to them).considerResourceSuperTypeModels
- if true
will also consider the validation model of the resource super type (recursively), otherwise not.ValidationResult
over all child resource validationsIllegalStateException
- in case an invalid validation model was foundIllegalArgumentException
- in case resourceType is absolute but outside of the search paths or if no validation model could be found (and enforceValidation is true
).SlingValidationException
- if one validator was called with invalid argumentsCopyright © 2017 The Apache Software Foundation. All rights reserved.