Class BasicReadOnlyBlobStore

  • All Implemented Interfaces:
    java.lang.AutoCloseable, BlobStore

    public class BasicReadOnlyBlobStore
    extends java.lang.Object
    implements BlobStore
    Utility BlobStore implementation to be used in tooling that can work with a FileStore without the need of the DataStore being present locally
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.lang.String getBlobId​(@NotNull java.lang.String reference)
      Returns the blobId that referred by the given binary reference.
      long getBlobLength​(java.lang.String blobId)
      Get the length of the blob.
      java.io.InputStream getInputStream​(java.lang.String blobId)
      Returns a new stream for given blobId.
      java.lang.String getReference​(@NotNull java.lang.String blobId)
      Returns a secure reference to blob referred by blobid, or null if no such reference is available.
      int readBlob​(java.lang.String blobId, long pos, byte[] buff, int off, int length)
      Read a number of bytes from a blob.
      java.lang.String writeBlob​(java.io.InputStream in)
      Write a blob from an input stream.
      java.lang.String writeBlob​(java.io.InputStream in, BlobOptions options)
      Ignores the options provided and delegates to writeBlob(InputStream).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BasicReadOnlyBlobStore

        public BasicReadOnlyBlobStore()
    • Method Detail

      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream in)
                                   throws java.io.IOException
        Description copied from interface: BlobStore
        Write a blob from an input stream. This method closes the input stream.
        Specified by:
        writeBlob in interface BlobStore
        Parameters:
        in - the input stream
        Returns:
        the blob id
        Throws:
        java.io.IOException
      • writeBlob

        public java.lang.String writeBlob​(java.io.InputStream in,
                                          BlobOptions options)
                                   throws java.io.IOException
        Ignores the options provided and delegates to writeBlob(InputStream).
        Specified by:
        writeBlob in interface BlobStore
        Parameters:
        in - the input stream to write
        options - the options to use
        Returns:
        Throws:
        java.io.IOException
      • readBlob

        public int readBlob​(java.lang.String blobId,
                            long pos,
                            byte[] buff,
                            int off,
                            int length)
                     throws java.io.IOException
        Description copied from interface: BlobStore
        Read a number of bytes from a blob.
        Specified by:
        readBlob in interface BlobStore
        Parameters:
        blobId - the blob id
        pos - the position within the blob
        buff - the target byte array
        off - the offset within the target array
        length - the number of bytes to read
        Returns:
        the number of bytes read
        Throws:
        java.io.IOException
      • getBlobLength

        public long getBlobLength​(java.lang.String blobId)
                           throws java.io.IOException
        Description copied from interface: BlobStore
        Get the length of the blob.
        Specified by:
        getBlobLength in interface BlobStore
        Parameters:
        blobId - the blob id
        Returns:
        the length
        Throws:
        java.io.IOException
      • getInputStream

        public java.io.InputStream getInputStream​(java.lang.String blobId)
                                           throws java.io.IOException
        Description copied from interface: BlobStore
        Returns a new stream for given blobId. The streams returned from multiple calls to this method are byte wise equals. That is, subsequent calls to read return the same sequence of bytes as long as neither call throws an exception.
        Specified by:
        getInputStream in interface BlobStore
        Parameters:
        blobId - the blob id
        Returns:
        a new stream for given blobId
        Throws:
        java.io.IOException
      • getBlobId

        public java.lang.String getBlobId​(@NotNull
                                          @NotNull java.lang.String reference)
        Description copied from interface: BlobStore
        Returns the blobId that referred by the given binary reference. Returns null if the reference is invalid, for example if it points to a blob that does not exist.
        Specified by:
        getBlobId in interface BlobStore
        Parameters:
        reference - binary reference
        Returns:
        matching blobId, or null
      • getReference

        public java.lang.String getReference​(@NotNull
                                             @NotNull java.lang.String blobId)
        Description copied from interface: BlobStore
        Returns a secure reference to blob referred by blobid, or null if no such reference is available.
        Specified by:
        getReference in interface BlobStore
        Parameters:
        blobId - blobId referring the blob for which reference is required
        Returns:
        binary reference, or null
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception