public class BitstreamStorageManager extends Object
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.
| Constructor and Description |
|---|
BitstreamStorageManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanup(boolean deleteDbRecords,
boolean verbose)
Clean up the bitstream storage area.
|
static void |
cleanup(org.dspace.core.Context context,
int id,
boolean deleteDbRecords,
boolean verbose) |
static int |
clone(org.dspace.core.Context context,
int id) |
static void |
delete(org.dspace.core.Context context,
int id)
Remove a bitstream from the asset store.
|
static org.dspace.storage.rdbms.TableRow |
dereferenceAbsoluteURI(org.dspace.core.Context context,
URI uri)
Translate bitstream absolute URI into values in bitstream row.
|
static URI |
getAbsoluteURI(org.dspace.core.Context context,
org.dspace.content.Bitstream bitstream)
Convenience method to get Bitstream URI off of Bitstream object
Create a URI representation of a Bitstream that can be used to accurately identify it in the
assetstore, includes support to encode the internal identifier after the #
Identifier Encoding:
/bitstrema/id/{bitstream-id}/{bitstream-name}#{store-id}:{internal-storage-id}
|
static URI |
getAbsoluteURI(int storeNumber,
String iid,
int bitstreamId,
String bitstreamName)
Create a URI representation of a Bitstream that can be used to accurately identify it in the
assetstore, includes support to encode the internal identifier after the #
Identifier Encoding:
/bitstrema/id/{bitstream-id}/{bitstream-name}#{store-id}:{internal-storage-id}
|
static URI |
getAbsoluteURI(org.dspace.storage.rdbms.TableRow bitstream,
String name)
Convenienece Method to get Bitstream URI off of Database row.
|
static boolean |
isRegisteredBitstream(String internalId)
Does the internal_id column in the bitstream row indicate the bitstream
is a registered file
|
static int |
register(org.dspace.core.Context context,
int assetstore,
String bitstreamPath)
Register a bitstream already in storage.
|
static InputStream |
retrieve(org.dspace.core.Context context,
int id)
Retrieve the bits for the bitstream with ID.
|
static BitstreamStorageOutputStream |
store(org.dspace.core.Context context) |
static BitstreamStorageOutputStream |
store(org.dspace.core.Context context,
org.dspace.content.BitstreamFormat format)
Allow creation of new Bitstream with known BitstreamFormat.
|
static int |
store(org.dspace.core.Context context,
InputStream is)
Store a stream of bits.
|
public static int store(org.dspace.core.Context context,
InputStream is)
throws SQLException,
IOException
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:context - The current contextis - The stream of bits to storeIOException - If a problem occurs while storing the bitsSQLException - If a problem occurs accessing the RDBMSpublic static BitstreamStorageOutputStream store(org.dspace.core.Context context) throws SQLException, IOException, NoSuchAlgorithmException
context - SQLExceptionIOExceptionNoSuchAlgorithmExceptionpublic static BitstreamStorageOutputStream store(org.dspace.core.Context context, org.dspace.content.BitstreamFormat format) throws SQLException, IOException, NoSuchAlgorithmException
context - format - SQLExceptionIOExceptionNoSuchAlgorithmExceptionpublic static int register(org.dspace.core.Context context,
int assetstore,
String bitstreamPath)
throws SQLException,
IOException
context - 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 RDBMSIOExceptionpublic static boolean isRegisteredBitstream(String internalId)
internalId - the value of the internal_id columnpublic static InputStream retrieve(org.dspace.core.Context context, int id) throws SQLException, IOException
context - The current contextid - The ID of the bitstream to retrieveIOException - If a problem occurs while retrieving the bitsSQLException - If a problem occurs accessing the RDBMSpublic static void delete(org.dspace.core.Context context,
int id)
throws SQLException
Remove a bitstream from the asset store. This method does not delete any bits, but simply marks the bitstreams as deleted (the context still needs to be completed to finalize the transaction).
If the context is aborted, the bitstreams deletion status remains unchanged.
context - The current contextid - The ID of the bitstream to deleteSQLException - If a problem occurs accessing the RDBMSpublic static void cleanup(org.dspace.core.Context context,
int id,
boolean deleteDbRecords,
boolean verbose)
throws SQLException,
IOException
SQLExceptionIOExceptionpublic static void cleanup(boolean deleteDbRecords,
boolean verbose)
throws SQLException,
IOException
deleteDbRecords - if true deletes the database records otherwise it
only deletes the files and directories in the assetstoreIOException - If a problem occurs while cleaning upSQLException - If a problem occurs accessing the RDBMSpublic static int clone(org.dspace.core.Context context,
int id)
throws SQLException
context - id - of the bitstream to clone.SQLExceptionpublic static URI getAbsoluteURI(org.dspace.core.Context context, org.dspace.content.Bitstream bitstream)
public static URI getAbsoluteURI(org.dspace.storage.rdbms.TableRow bitstream, String name)
public static URI getAbsoluteURI(int storeNumber, String iid, int bitstreamId, String bitstreamName)
public static org.dspace.storage.rdbms.TableRow dereferenceAbsoluteURI(org.dspace.core.Context context,
URI uri)
throws IllegalArgumentException,
SQLException
IllegalArgumentExceptionSQLExceptionCopyright © 2016 DuraSpace. All rights reserved.