Interface BitstreamStorageService
- All Known Implementing Classes:
BitstreamStorageServiceImpl
Stores, retrieves and deletes bitstreams.
Presently, asset stores are specified in dspace.cfg. Since
Java does not offer a way of detecting free disk space, the asset store to
use for new bitstreams is also specified in a configuration property. The
drawbacks to this are that the administrators are responsible for monitoring
available space in the asset stores, and DSpace (Tomcat) has to be restarted
when the asset store for new ('incoming') bitstreams is changed.
Mods by David Little, UCSD Libraries 12/21/04 to allow the registration of files (bitstreams) into DSpace.
Cleanup integration with checker package by Nate Sarr 2006-01. N.B. The dependency on the checker package isn't ideal - a Listener pattern would be better but was considered overkill for the purposes of integrating the checker. It would be worth re-considering a Listener pattern if another package needs to be notified of BitstreamStorageManager actions.
- Version:
- $Revision$
- Author:
- Peter Breton, Robert Tansley, David Little, Nathan Sarr
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup(boolean deleteDbRecords, boolean verbose) Clean up the bitstream storage area.Clone the given bitstream to a new bitstream with a new ID.computeChecksum(Context context, Bitstream bitstream) getLastModified(Bitstream bitstream) Gets the last modified timestamp of the the given bitstream's content, if known.booleanisRegisteredBitstream(String internalId) Does the internal_id column in the bitstream row indicate the bitstream is a registered filevoidmigrate(Context context, Integer assetstoreSource, Integer assetstoreDestination, boolean deleteOld, Integer batchCommitSize) Migrate all the assets from assetstoreSource to assetstoreDestinationvoidprintStores(Context context) Print out (log/out) a listing of the assetstores configured, and how many assets they containRegister a bitstream already in storage.Retrieve the bits for the bitstream with ID.voidsetIncomingExternal(int incoming) Sets the number for the incoming storestore(Context context, Bitstream bitstream, InputStream is) Store a stream of bits.
-
Method Details
-
store
Store a stream of bits.If this method returns successfully, the bits have been stored, and RDBMS metadata entries are in place (the context still needs to be completed to finalize the transaction).
If this method returns successfully and the context is aborted, then the bits will be stored in the asset store and the RDBMS metadata entries will exist, but with the deleted flag set.
If this method throws an exception, then any of the following may be true:- Neither bits nor RDBMS metadata entries have been stored.
- RDBMS metadata entries with the deleted flag set have been stored, but no bits.
- RDBMS metadata entries with the deleted flag set have been stored, and some or all of the bits have also been stored.
- Parameters:
context- The current contextbitstream- The bitstream to storeis- The stream of bits to store- Returns:
- The ID of the stored bitstream
- Throws:
IOException- If a problem occurs while storing the bitsSQLException- If a problem occurs accessing the RDBMS
-
register
UUID register(Context context, Bitstream bitstream, int assetstore, String bitstreamPath) throws SQLException, IOException, AuthorizeException Register a bitstream already in storage.- Parameters:
context- The current contextbitstream- The bitstream to registerassetstore- The assetstore number for the bitstream to be registeredbitstreamPath- The relative path of the bitstream to be registered. The path is relative to the path of this assetstore.- Returns:
- The ID of the registered bitstream
- Throws:
SQLException- If a problem occurs accessing the RDBMSIOException- if IO errorAuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
computeChecksum
- Throws:
IOException
-
isRegisteredBitstream
Does the internal_id column in the bitstream row indicate the bitstream is a registered file- Parameters:
internalId- the value of the internal_id column- Returns:
- true if the bitstream is a registered file
-
retrieve
Retrieve the bits for the bitstream with ID. If the bitstream does not exist, or is marked deleted, returns null.- Parameters:
context- The current contextbitstream- The bitstream to retrieve- Returns:
- The stream of bits, or null
- Throws:
IOException- If a problem occurs while retrieving the bitsSQLException- If a problem occurs accessing the RDBMS
-
cleanup
void cleanup(boolean deleteDbRecords, boolean verbose) throws SQLException, IOException, AuthorizeException Clean up the bitstream storage area. This method deletes any bitstreams which are more than 1 hour old and marked deleted. The deletions cannot be undone.- Parameters:
deleteDbRecords- if true deletes the database records otherwise it only deletes the files and directories in the assetstoreverbose- verbosity flag- Throws:
IOException- If a problem occurs while cleaning upSQLException- If a problem occurs accessing the RDBMSAuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
clone
Bitstream clone(Context context, Bitstream bitstream) throws SQLException, IOException, AuthorizeException Clone the given bitstream to a new bitstream with a new ID. Metadata of the given bitstream are also copied to the new bitstream.- Parameters:
context- DSpace context objectbitstream- the bitstream to be cloned- Returns:
- id of the clone bitstream.
- Throws:
SQLException- if database errorIOException- if IO errorAuthorizeException- if authorization error
-
printStores
Print out (log/out) a listing of the assetstores configured, and how many assets they contain- Parameters:
context- The relevant DSpace Context.- Throws:
SQLException- if database error
-
migrate
void migrate(Context context, Integer assetstoreSource, Integer assetstoreDestination, boolean deleteOld, Integer batchCommitSize) throws IOException, SQLException, AuthorizeException Migrate all the assets from assetstoreSource to assetstoreDestination- Parameters:
context- The relevant DSpace Context.assetstoreSource- source assetstoreassetstoreDestination- destination assetstoredeleteOld- whether to delete files from the source assetstore after migrationbatchCommitSize- batch size- Throws:
IOException- A general class of exceptions produced by failed or interrupted I/O operations.SQLException- An exception that provides information on a database access error or other errors.AuthorizeException- Exception indicating the current user of the context does not have permission to perform a particular action.
-
getLastModified
Gets the last modified timestamp of the the given bitstream's content, if known.- Parameters:
bitstream- the bitstream.- Returns:
- the timestamp in milliseconds, or
nullif unknown. - Throws:
IOException- if an unexpected io error occurs.
-
setIncomingExternal
void setIncomingExternal(int incoming) Sets the number for the incoming store- Parameters:
incoming-
-