Class ValidationExecutor
java.lang.Object
org.apache.jackrabbit.vault.validation.ValidationExecutor
Provides methods to call all registered validators. This instance is bound to the
ValidationContext being given in the
ValidationExecutorFactory.createValidationExecutor(org.apache.jackrabbit.vault.validation.spi.ValidationContext, boolean, boolean, Map).
This class is thread-safe (i.e. methods can be used from different threads on the same instance).- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionValidationExecutor(@NotNull Map<@NotNull String, @NotNull Validator> validatorsById) Creates a new instance with the given validators. -
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<ValidationViolation>done()Must be called at the end of the validation (when the validation context is no longer used).static @NotNull StringfilePathToNodePath(@NotNull Path filePath) Converts the given file path (a relative one) to the absolute node path.Returns all bound validators by id.Returns all unused validators by id.@NotNull Collection<ValidationViolation>validateJcrRoot(@Nullable InputStream input, @NotNull Path filePath, @NotNull Path basePath) Validates a package's input stream (below jcr_root, no metadata) with all relevant validators.@NotNull Collection<ValidationViolation>validateMetaInf(@Nullable InputStream input, @NotNull Path filePath, @NotNull Path basePath) Validates a package's META-INF input stream with all relevant validators.
-
Field Details
-
EXTENSION_BINARY
- See Also:
-
-
Constructor Details
-
ValidationExecutor
Creates a new instance with the given validators.- Parameters:
validatorsById- a map of validator ids and actual validators
-
-
Method Details
-
getAllValidatorsById
Returns all bound validators by id.- Returns:
- a map with all validators (key=validator id, value=actual validator)
-
getUnusedValidatorsById
Returns all unused validators by id. Unused validators are those implementing an interface which is not understood by this executor.- Returns:
- a map with all unused validators (key=validator id, value=actual validator)
-
validateMetaInf
@NotNull public @NotNull Collection<ValidationViolation> validateMetaInf(@Nullable @Nullable InputStream input, @NotNull @NotNull Path filePath, @NotNull @NotNull Path basePath) throws IOException Validates a package's META-INF input stream with all relevant validators.- Parameters:
input- the input stream if it is a file ornullin case it is called for a folder. It is not closed during processing, this is obligation of the caller. Should not be buffered as buffering is done internally!filePath- should be relative to the META-INF directory (i.e. should not start withMETA-INF)basePath- the path to which the file path is relative- Returns:
- the list of validation messages
- Throws:
IOException- in case the input stream could not be accessed
-
validateJcrRoot
@NotNull public @NotNull Collection<ValidationViolation> validateJcrRoot(@Nullable @Nullable InputStream input, @NotNull @NotNull Path filePath, @NotNull @NotNull Path basePath) throws IOException Validates a package's input stream (below jcr_root, no metadata) with all relevant validators.As some validators rely on the order of validated files, make sure to first call for streams representing the parent nodes (i.e. folders and .content.xml streams), before calling it for streams representing the children.
- Parameters:
input- the input stream if it is a file ornullin case it is called for a folder. It is not closed during processing, this is obligation of the caller. Should not be buffered as buffering is done internally!filePath- file path relative to the content package jcr root (i.e. the folder named "jcr_root")basePath- the path to which the file path is relative- Returns:
- the list of validation messages
- Throws:
IOException- in case the input stream could not be accessed
-
done
Must be called at the end of the validation (when the validation context is no longer used). This is important as some validators emit violation messages only when this method is called.- Returns:
- the list of additional validation violations (might be empty) which have not been reported before
-
filePathToNodePath
Converts the given file path (a relative one) to the absolute node path.- Parameters:
filePath- the relative file path to convert- Returns:
- the node path
-