Package org.dspace.storage.bitstore
Class DSBitStoreService
- java.lang.Object
-
- org.dspace.storage.bitstore.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
-
-
Field Summary
Fields Modifier and Type Field Description protected StringREGISTERED_FLAG
-
Constructor Summary
Constructors Constructor Description DSBitStoreService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mapabout(Bitstream bitstream, Map attrs)Obtain technical metadata about an asset in the asset store.StringgenerateId()Return an identifier unique to this asset store instanceInputStreamget(Bitstream bitstream)Retrieve the bits for the asset with ID.FilegetBaseDir()protected FilegetFile(Bitstream bitstream)Return the file corresponding to a bitstream.protected StringgetIntermediatePath(String iInternalId)Return the intermediate path derived from the internal_id.voidinit()Initialize the asset storebooleanisRegisteredBitstream(String internalId)voidput(Bitstream bitstream, InputStream in)Store a stream of bits.voidremove(Bitstream bitstream)Remove an asset from the asset store.voidsetBaseDir(File baseDir)
-
-
-
Field Detail
-
REGISTERED_FLAG
protected final String REGISTERED_FLAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init()
Initialize the asset store- Specified by:
initin interfaceBitStoreService
-
generateId
public String generateId()
Return an identifier unique to this asset store instance- Specified by:
generateIdin interfaceBitStoreService- 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:
getin interfaceBitStoreService- 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:
putin interfaceBitStoreService- Parameters:
in- The stream of bits to storebitstream- 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:
aboutin interfaceBitStoreService- Parameters:
bitstream- The asset to describeattrs- 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:
removein interfaceBitStoreService- 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 innull.- Parameters:
bitstream- the database table row for the bitstream. Can benull- 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)
-
-