Package org.dspace.storage.bitstore
Class JCloudBitStoreService
java.lang.Object
org.dspace.storage.bitstore.BaseBitStoreService
org.dspace.storage.bitstore.JCloudBitStoreService
- All Implemented Interfaces:
BitStoreService
JCloudBitstream asset store service
This class provides an implementation of the BitstreamStorageService using JClouds for cloud storage.
It supports storing, retrieving, and removing bitstreams in a cloud storage container.
The class also handles initialization and configuration of the JClouds BlobStoreContext.
Additional details regarding configuration can be found at:
Blobstore Configuration https://jclouds.apache.org/start/blobstore/
Providers and API https://jclouds.apache.org/reference/providers/#blobstore
Author: Mark Diggory, Nathan Buckingham
-
Field Summary
Fields inherited from class org.dspace.storage.bitstore.BaseBitStoreService
CHECKSUM, CHECKSUM_ALGORITHM, digitsPerLevel, directoryLevels, initialized, MODIFIED, SIZE_BYTES -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor.JCloudBitStoreService(String providerOrApi) Constructor with provider or API.protectedJCloudBitStoreService(org.jclouds.blobstore.BlobStoreContext blobStoreContext, String providerOrApi) Protected constructor with BlobStoreContext and provider or API. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves metadata about a bitstream.Generates a unique identifier for a bitstream.Retrieves a bitstream as an InputStream.Gets the file corresponding to a bitstream.getFullKey(String id) Utility Method: Prefix the key with a subfolder, if this instance assets are stored within subfolderstatic StringgetMIMEType(Bitstream bitstream) Gets the MIME type of a bitstream.Gets the subfolder within the bucket where objects are stored.voidinit()Initializes the cloud storage context.booleanChecks if the service is enabled.voidStores a byte source as a bitstream.voidput(Bitstream bitstream, InputStream in) Stores a stream of bits.voidRemoves a bitstream from the cloud storage.voidsetContainer(String container) Sets the container name for storing bitstreams.voidsetCredentials(String credential) Sets the credentials for cloud storage authentication.voidsetEnabled(boolean enabled) Sets whether the service is enabled.voidsetEndpoint(String endpoint) Sets the endpoint for cloud storage.voidsetIdentity(String identity) Sets the identity for cloud storage authentication.voidsetMaxCounter(int maxCounter) Sets the maximum counter value for refreshing the context.voidsetOverrides(Properties overrides) Sets the properties for cloud storage configuration.voidsetProviderOrApi(String providerOrApi) Sets the provider or API for cloud storage.voidsetSubfolder(String subfolder) Sets the subfolder within the bucket where objects are stored.voidsetUseRelativePath(boolean useRelativePath) Sets whether to use relative paths for storing bitstreams.Methods inherited from class org.dspace.storage.bitstore.BaseBitStoreService
about, appendSeparator, endsWithSeparator, extractSubstringFrom, getIntermediatePath, isInitialized, isLonger, populatePathSplittingId, putValueIfExistsKey, sanitizeIdentifier
-
Constructor Details
-
JCloudBitStoreService
public JCloudBitStoreService()Default constructor. -
JCloudBitStoreService
Constructor with provider or API.- Parameters:
providerOrApi- the provider or API to use for cloud storage
-
JCloudBitStoreService
protected JCloudBitStoreService(org.jclouds.blobstore.BlobStoreContext blobStoreContext, String providerOrApi) Protected constructor with BlobStoreContext and provider or API.- Parameters:
blobStoreContext- the BlobStoreContext to useproviderOrApi- the provider or API to use for cloud storage
-
-
Method Details
-
setUseRelativePath
public void setUseRelativePath(boolean useRelativePath) Sets whether to use relative paths for storing bitstreams.- Parameters:
useRelativePath- true to use relative paths, false otherwise
-
setEnabled
public void setEnabled(boolean enabled) Sets whether the service is enabled.- Parameters:
enabled- true to enable the service, false otherwise
-
setContainer
Sets the container name for storing bitstreams.- Parameters:
container- the container name
-
getSubfolder
Gets the subfolder within the bucket where objects are stored.- Returns:
- the subfolder name
-
setSubfolder
Sets the subfolder within the bucket where objects are stored.- Parameters:
subfolder- the subfolder name
-
setIdentity
Sets the identity for cloud storage authentication.- Parameters:
identity- the identity
-
setCredentials
Sets the credentials for cloud storage authentication.- Parameters:
credential- the credentials
-
setProviderOrApi
Sets the provider or API for cloud storage.- Parameters:
providerOrApi- the provider or API
-
setEndpoint
Sets the endpoint for cloud storage.- Parameters:
endpoint- the endpoint
-
setMaxCounter
public void setMaxCounter(int maxCounter) Sets the maximum counter value for refreshing the context.- Parameters:
maxCounter- the maximum counter value
-
setOverrides
Sets the properties for cloud storage configuration.- Parameters:
overrides- the properties
-
isEnabled
public boolean isEnabled()Checks if the service is enabled.- Returns:
- true if the service is enabled, false otherwise
-
init
Initializes the cloud storage context.- Throws:
IOException- if an error occurs during initialization
-
generateId
Generates a unique identifier for a bitstream.- Returns:
- the generated identifier
-
get
Retrieves a bitstream as an InputStream.- Parameters:
bitstream- the bitstream to retrieve- Returns:
- the InputStream of the bitstream
- Throws:
IOException- if an error occurs during retrieval
-
remove
Removes a bitstream from the cloud storage.- Parameters:
bitstream- the bitstream to remove- Throws:
IOException- if an error occurs during removal
-
getFullKey
Utility Method: Prefix the key with a subfolder, if this instance assets are stored within subfolder- Parameters:
id- DSpace bitstream internal ID- Returns:
- full key prefixed with a subfolder, if applicable
-
put
Stores a byte source as a bitstream.- Parameters:
byteSource- the byte source to storebitstream- the bitstream to store- Throws:
IOException- if an error occurs during storage
-
put
Stores 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.
- Parameters:
bitstream- the bitstream to storein- the stream of bits to store- Throws:
IOException- if a problem occurs while storing the bits
-
getMIMEType
Gets the MIME type of a bitstream.- Parameters:
bitstream- the bitstream to get the MIME type for- Returns:
- the MIME type of the bitstream
-
about
Retrieves metadata about a bitstream.- Parameters:
bitstream- the bitstream to retrieve metadata forattrs- the list of attributes to retrieve- Returns:
- a map of metadata attributes and their values
- Throws:
IOException- if an error occurs during retrieval
-
getFile
Gets the file corresponding to a bitstream.- Parameters:
bitstream- the bitstream to get the file for- Returns:
- the file corresponding to the bitstream
- Throws:
IOException- if an error occurs during retrieval
-