Class InventoryUpdater


  • public class InventoryUpdater
    extends Object
    This class is used to record changes to OCFL objects and construct an updated inventory.
    • Method Detail

      • buildNewInventory

        public Inventory buildNewInventory​(OffsetDateTime createdTimestamp,
                                           VersionInfo versionInfo)
        Constructs a new Inventory that contains a new Version based on the changes that were recorded. After calling this method, the InventoryUpdater instance should NOT be used again.
        Parameters:
        createdTimestamp - when the version was created
        versionInfo - information about the version
        Returns:
        new inventory
      • addFile

        public InventoryUpdater.AddFileResult addFile​(String fileId,
                                                      String logicalPath,
                                                      OcflOption... options)
        Adds a file. If there is already a file with the same digest in the manifest, only the state is updated.
        Parameters:
        fileId - the file's digest
        logicalPath - the logical path to insert the file at within the object
        options - options
        Returns:
        details about the file if it was added to the manifest
      • innerContentPath

        public String innerContentPath​(String logicalPath)
        Maps the logical path to a content path and returns the part of the content path that's under the content directory.
        Parameters:
        logicalPath - the logical path
        Returns:
        content path part that's under the content directory
      • addFixity

        public void addFixity​(String logicalPath,
                              DigestAlgorithm algorithm,
                              String digest)
        Adds an entry to the fixity block. An entry is not added if the algorithm is the same as the inventory's algorithm.
        Parameters:
        logicalPath - the file's logical path
        algorithm - algorithm used to calculate the digest
        digest - the digest value
      • getFixityDigest

        public String getFixityDigest​(String logicalPath,
                                      DigestAlgorithm algorithm)
        Gets the fixity digest for the specified file or null.
        Parameters:
        logicalPath - the logical path to the file
        algorithm - the digest algorithm
        Returns:
        the digest or null
      • clearFixity

        public void clearFixity()
        Removes all entries from the fixity block.
      • removeFile

        public Set<InventoryUpdater.RemoveFileResult> removeFile​(String logicalPath)
        Removes a file from the current version. If the file was added in the same version, it is also removed from the manifest.
        Parameters:
        logicalPath - logical path to the file
        Returns:
        files that were removed from the manifest
      • renameFile

        public Set<InventoryUpdater.RemoveFileResult> renameFile​(String srcLogicalPath,
                                                                 String dstLogicalPath,
                                                                 OcflOption... options)
        Renames a file in the current version to a new logical path. If there is an existing file at the new logical path, and OcflOption.OVERWRITE is specified, then the existing file is replaced. If the replaced file was originally added in the current version, then it is also removed from the manifest.
        Parameters:
        srcLogicalPath - current logical path
        dstLogicalPath - new logical path
        options - options
        Returns:
        files that were removed from the manifest
      • reinstateFile

        public Set<InventoryUpdater.RemoveFileResult> reinstateFile​(VersionNum sourceVersion,
                                                                    String srcLogicalPath,
                                                                    String dstLogicalPath,
                                                                    OcflOption... options)
        Reinstates a file from a previous version to the current version. If there is an existing file at the new logical path, and OcflOption.OVERWRITE is specified, then the existing file is replaced. If the replaced file was originally added in the current version, then it is also removed from the manifest.
        Parameters:
        sourceVersion - the version number the source logical path corresponds to
        srcLogicalPath - the source logical path of the file to reinstate
        dstLogicalPath - the destination logical path to reinstate the file at
        options - options
        Returns:
        files that were removed from the manifest
      • clearState

        public void clearState()
        Removes all of the files from the version's state.