Class JCloudBitStoreService

java.lang.Object
org.dspace.storage.bitstore.BaseBitStoreService
org.dspace.storage.bitstore.JCloudBitStoreService
All Implemented Interfaces:
BitStoreService

public class JCloudBitStoreService extends BaseBitStoreService
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
  • Constructor Details

    • JCloudBitStoreService

      public JCloudBitStoreService()
      Default constructor.
    • JCloudBitStoreService

      public JCloudBitStoreService(String providerOrApi)
      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 use
      providerOrApi - 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

      public void setContainer(String container)
      Sets the container name for storing bitstreams.
      Parameters:
      container - the container name
    • getSubfolder

      public String getSubfolder()
      Gets the subfolder within the bucket where objects are stored.
      Returns:
      the subfolder name
    • setSubfolder

      public void setSubfolder(String subfolder)
      Sets the subfolder within the bucket where objects are stored.
      Parameters:
      subfolder - the subfolder name
    • setIdentity

      public void setIdentity(String identity)
      Sets the identity for cloud storage authentication.
      Parameters:
      identity - the identity
    • setCredentials

      public void setCredentials(@Nullable String credential)
      Sets the credentials for cloud storage authentication.
      Parameters:
      credential - the credentials
    • setProviderOrApi

      public void setProviderOrApi(String providerOrApi)
      Sets the provider or API for cloud storage.
      Parameters:
      providerOrApi - the provider or API
    • setEndpoint

      public void setEndpoint(String endpoint)
      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

      public void setOverrides(Properties overrides)
      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

      public void init() throws IOException
      Initializes the cloud storage context.
      Throws:
      IOException - if an error occurs during initialization
    • generateId

      public String generateId()
      Generates a unique identifier for a bitstream.
      Returns:
      the generated identifier
    • get

      public InputStream get(Bitstream bitstream) throws IOException
      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

      public void remove(Bitstream bitstream) throws IOException
      Removes a bitstream from the cloud storage.
      Parameters:
      bitstream - the bitstream to remove
      Throws:
      IOException - if an error occurs during removal
    • getFullKey

      public String getFullKey(String id)
      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

      public void put(com.google.common.io.ByteSource byteSource, Bitstream bitstream) throws IOException
      Stores a byte source as a bitstream.
      Parameters:
      byteSource - the byte source to store
      bitstream - the bitstream to store
      Throws:
      IOException - if an error occurs during storage
    • put

      public void put(Bitstream bitstream, InputStream in) throws IOException
      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 store
      in - the stream of bits to store
      Throws:
      IOException - if a problem occurs while storing the bits
    • getMIMEType

      public static String getMIMEType(Bitstream bitstream)
      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

      public Map<String,Object> about(Bitstream bitstream, List<String> attrs) throws IOException
      Retrieves metadata about a bitstream.
      Parameters:
      bitstream - the bitstream to retrieve metadata for
      attrs - the list of attributes to retrieve
      Returns:
      a map of metadata attributes and their values
      Throws:
      IOException - if an error occurs during retrieval
    • getFile

      public File getFile(Bitstream bitstream) throws IOException
      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