public class BitstreamStorageServiceImpl extends Object implements BitstreamStorageService, org.springframework.beans.factory.InitializingBean
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.
| Modifier and Type | Field and Description |
|---|---|
protected BitstreamService |
bitstreamService |
protected ChecksumHistoryService |
checksumHistoryService |
protected String |
REGISTERED_FLAG
This prefix string marks registered bitstreams in internal_id
|
| Modifier | Constructor and Description |
|---|---|
protected |
BitstreamStorageServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
cleanup(boolean deleteDbRecords,
boolean verbose)
Clean up the bitstream storage area.
|
Bitstream |
clone(Context context,
Bitstream bitstream) |
Map |
computeChecksum(Context context,
Bitstream bitstream) |
int |
getIncoming() |
Map<Integer,BitStoreService> |
getStores() |
protected boolean |
isRecent(Long lastModified)
Return true if this file is too recent to be deleted, false otherwise.
|
boolean |
isRegisteredBitstream(String internalId)
Does the internal_id column in the bitstream row indicate the bitstream
is a registered file
|
void |
migrate(Context context,
Integer assetstoreSource,
Integer assetstoreDestination,
boolean deleteOld,
Integer batchCommitSize)
Migrates all assets off of one assetstore to another
|
void |
printStores(Context context)
Print out (log/out) a listing of the assetstores configured, and how many assets they contain
|
UUID |
register(Context context,
Bitstream bitstream,
int assetstore,
String bitstreamPath)
Register a bitstream already in storage.
|
InputStream |
retrieve(Context context,
Bitstream bitstream)
Retrieve the bits for the bitstream with ID.
|
void |
setIncoming(int incoming) |
void |
setStores(Map<Integer,BitStoreService> stores) |
UUID |
store(Context context,
Bitstream bitstream,
InputStream is)
Store a stream of bits.
|
@Autowired(required=true) protected BitstreamService bitstreamService
@Autowired(required=true) protected ChecksumHistoryService checksumHistoryService
protected final String REGISTERED_FLAG
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic UUID store(Context context, Bitstream bitstream, InputStream is) throws SQLException, IOException
BitstreamStorageServiceIf 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:store in interface BitstreamStorageServicecontext - The current contextis - The stream of bits to storeSQLException - If a problem occurs accessing the RDBMSIOException - If a problem occurs while storing the bitspublic UUID register(Context context, Bitstream bitstream, int assetstore, String bitstreamPath) throws SQLException, IOException, AuthorizeException
register in interface BitstreamStorageServicecontext - The current contextassetstore - 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 ths assetstore.SQLException - If a problem occurs accessing the RDBMSIOException - if IO errorAuthorizeExceptionpublic Map computeChecksum(Context context, Bitstream bitstream) throws IOException
computeChecksum in interface BitstreamStorageServiceIOExceptionpublic boolean isRegisteredBitstream(String internalId)
BitstreamStorageServiceisRegisteredBitstream in interface BitstreamStorageServiceinternalId - the value of the internal_id columnpublic InputStream retrieve(Context context, Bitstream bitstream) throws SQLException, IOException
BitstreamStorageServiceretrieve in interface BitstreamStorageServicecontext - The current contextbitstream - The bitstream to retrieveSQLException - If a problem occurs accessing the RDBMSIOException - If a problem occurs while retrieving the bitspublic void cleanup(boolean deleteDbRecords,
boolean verbose)
throws SQLException,
IOException,
AuthorizeException
BitstreamStorageServicecleanup in interface BitstreamStorageServicedeleteDbRecords - if true deletes the database records otherwise it
only deletes the files and directories in the assetstoreSQLException - If a problem occurs accessing the RDBMSIOException - If a problem occurs while cleaning upAuthorizeExceptionpublic Bitstream clone(Context context, Bitstream bitstream) throws SQLException, IOException, AuthorizeException
clone in interface BitstreamStorageServicecontext - bitstream - the bitstream to be clonedSQLException - if database errorIOExceptionAuthorizeExceptionpublic void migrate(Context context, Integer assetstoreSource, Integer assetstoreDestination, boolean deleteOld, Integer batchCommitSize) throws IOException, SQLException, AuthorizeException
migrate in interface BitstreamStorageServiceassetstoreSource - assetstoreDestination - IOExceptionSQLExceptionAuthorizeExceptionpublic void printStores(Context context)
BitstreamStorageServiceprintStores in interface BitstreamStorageServicepublic int getIncoming()
public void setIncoming(int incoming)
public void setStores(Map<Integer,BitStoreService> stores)
public Map<Integer,BitStoreService> getStores()
protected boolean isRecent(Long lastModified)
lastModified - The time asset was last modifiedCopyright © 2016 DuraSpace. All rights reserved.