Class ValidationExecutor

    • Constructor Detail

      • ValidationExecutor

        public ValidationExecutor​(@NotNull
                                  @NotNull Map<@NotNull String,​@NotNull Validator> validatorsById)
        Creates a new instance with the given validators.
        Parameters:
        validatorsById - a map of validator ids and actual validators
    • 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 or null 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 with META-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 or null 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
      • filePathToNodePath

        @NotNull
        public static @NotNull String filePathToNodePath​(@NotNull
                                                         @NotNull Path filePath)
        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