Class AddFileProcessor


  • public class AddFileProcessor
    extends Object
    Encapsulates logic for adding files to an object, both adding them to the inventory and moving them into staging.
    • Constructor Detail

      • AddFileProcessor

        public AddFileProcessor​(InventoryUpdater inventoryUpdater,
                                Path stagingDir,
                                DigestAlgorithm digestAlgorithm)
        Parameters:
        inventoryUpdater - the inventory updater
        stagingDir - the staging directory to move files into
        digestAlgorithm - the digest algorithm
        See Also:
        AddFileProcessor.Builder
    • Method Detail

      • processPath

        public Map<String,​Path> processPath​(Path sourcePath,
                                                  OcflOption... ocflOptions)
        Adds all of the files at or under the sourcePath to the root of the object.
        Parameters:
        sourcePath - the file or directory to add
        ocflOptions - options for how to move the files
        Returns:
        a map of logical paths to their corresponding file within the stagingDir for newly added files
      • processPath

        public Map<String,​Path> processPath​(Path sourcePath,
                                                  String destinationPath,
                                                  OcflOption... options)
        Adds all of the files at or under the sourcePath to the object at the specified destinationPath.
        Parameters:
        sourcePath - the file or directory to add
        destinationPath - the location to insert the file or directory at within the object
        options - options for how to move the files
        Returns:
        a map of logical paths to their corresponding file within the stagingDir for newly added files
      • processFileWithDigest

        public Map<String,​Path> processFileWithDigest​(String digest,
                                                            Path sourcePath,
                                                            String destinationPath,
                                                            OcflOption... options)
        Adds the file at sourcePath to the object at the specified destinationPath. The provided digest is trusted to be accurate. If it is not, or is the wrong algorithm, then the object will be corrupted.
        Parameters:
        digest - the digest of the file. MUST use the same algorithm as the object's content digest algorithm
        sourcePath - the file or directory to add
        destinationPath - the location to insert the file or directory at within the object
        options - options for how to move the files
        Returns:
        a map of logical paths to their corresponding file within the stagingDir for newly added files