Class DSBitStoreService

  • All Implemented Interfaces:
    BitStoreService

    public class DSBitStoreService
    extends Object
    implements BitStoreService
    Native DSpace (or "Directory Scatter" if you prefer) asset store. Implements a directory 'scatter' algorithm to avoid OS limits on files per directory.
    Author:
    Peter Breton, Robert Tansley, Richard Rodgers, Peter Dietz
    • Constructor Detail

      • DSBitStoreService

        public DSBitStoreService()
    • Method Detail

      • init

        public void init()
        Initialize the asset store
        Specified by:
        init in interface BitStoreService
      • generateId

        public String generateId()
        Return an identifier unique to this asset store instance
        Specified by:
        generateId in interface BitStoreService
        Returns:
        a unique ID
      • get

        public InputStream get​(Bitstream bitstream)
                        throws IOException
        Retrieve the bits for the asset with ID. If the asset does not exist, returns null.
        Specified by:
        get in interface BitStoreService
        Parameters:
        bitstream - The ID of the asset to retrieve
        Returns:
        The stream of bits, or null
        Throws:
        IOException - If a problem occurs while retrieving the bits
      • put

        public void put​(Bitstream bitstream,
                        InputStream in)
                 throws IOException
        Store a stream of bits.

        If this method returns successfully, the bits have been stored. If an exception is thrown, the bits have not been stored.

        Specified by:
        put in interface BitStoreService
        Parameters:
        in - The stream of bits to store
        bitstream - The bitstream object
        Throws:
        IOException - If a problem occurs while storing the bits
      • about

        public Map about​(Bitstream bitstream,
                         Map attrs)
                  throws IOException
        Obtain technical metadata about an asset in the asset store.
        Specified by:
        about in interface BitStoreService
        Parameters:
        bitstream - The asset to describe
        attrs - A Map whose keys consist of desired metadata fields
        Returns:
        attrs A Map with key/value pairs of desired metadata
        Throws:
        IOException - If a problem occurs while obtaining metadata
      • remove

        public void remove​(Bitstream bitstream)
                    throws IOException
        Remove an asset from the asset store. An irreversible operation.
        Specified by:
        remove in interface BitStoreService
        Parameters:
        bitstream - The asset to delete
        Throws:
        IOException - If a problem occurs while removing the asset
      • getFile

        protected File getFile​(Bitstream bitstream)
                        throws IOException
        Return the file corresponding to a bitstream. It's safe to pass in null.
        Parameters:
        bitstream - the database table row for the bitstream. Can be null
        Returns:
        The corresponding file in the file system, or null
        Throws:
        IOException - If a problem occurs while determining the file
      • getIntermediatePath

        protected String getIntermediatePath​(String iInternalId)
        Return the intermediate path derived from the internal_id. This method splits the id into groups which become subdirectories.
        Parameters:
        iInternalId - The internal_id
        Returns:
        The path based on the id without leading or trailing separators
      • isRegisteredBitstream

        public boolean isRegisteredBitstream​(String internalId)
      • getBaseDir

        public File getBaseDir()
      • setBaseDir

        public void setBaseDir​(File baseDir)