Class ValidationExecutor
- java.lang.Object
-
- org.apache.jackrabbit.vault.validation.ValidationExecutor
-
public final class ValidationExecutor extends Object
Provides methods to call all registered validators. This instance is bound to theValidationContext
being given in theValidationExecutorFactory.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:
ValidationExecutorFactory
-
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_BINARY
-
Constructor Summary
Constructors Constructor Description ValidationExecutor(@NotNull Map<@NotNull String,@NotNull Validator> validatorsById)
Creates a new instance with the given validators.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Collection<ValidationViolation>
done()
Must be called at the end of the validation (when the validation context is no longer used).static @NotNull String
filePathToNodePath(@NotNull Path filePath)
Converts the given file path (a relative one) to the absolute node path.@NotNull Map<String,Validator>
getAllValidatorsById()
Returns all bound validators by id.@NotNull Map<String,Validator>
getUnusedValidatorsById()
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 Detail
-
EXTENSION_BINARY
public static final String EXTENSION_BINARY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllValidatorsById
@NotNull public @NotNull Map<String,Validator> getAllValidatorsById()
Returns all bound validators by id.- Returns:
- a map with all validators (key=validator id, value=actual validator)
-
getUnusedValidatorsById
@NotNull public @NotNull Map<String,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 ornull
in 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 ornull
in 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
@NotNull public @NotNull Collection<ValidationViolation> 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
-
-