Class StreamHandlerAbstract<I,O>

java.lang.Object
io.clonecloudstore.common.quarkus.server.service.StreamHandlerAbstract<I,O>
Direct Known Subclasses:
AbstractObjectStreamHandler, FakeStreamHandlerAbstract, LocalReplicatorStreamHandler, RemoteReplicatorStreamHandler

@Dependent public abstract class StreamHandlerAbstract<I,O> extends Object
  • Field Details

  • Constructor Details

    • StreamHandlerAbstract

      protected StreamHandlerAbstract()
  • Method Details

    • postSetup

      protected void postSetup()
      Method to override for post setup
    • setup

      public void setup(io.vertx.core.http.HttpServerRequest request, io.quarkus.resteasy.reactive.server.Closer closer, boolean isUpload, I businessIn, long inputLength, String optionalHash, boolean keepInputStreamCompressed, boolean external)
      Constructor, while inputLength could be 0 (valid for both POST and GET, signifying the posted InputStream length or the supposed returned InputStream length). When the stream is incoming (server side, so using POST, stream coming from client), if compressed, the configuration shall decide if the stream is kept compressed or decompressed before passing the stream to its final usage.
      Parameters:
      isUpload - True for incoming InputStream, False for outgoing InputStream
      inputLength - might be 0 if unknown size
      optionalHash - Hash optional (might be null); if POST InputStream, if empty, Hash will be computed
      keepInputStreamCompressed - True means the stream will be kept compressed if source (from client) is compressed (for push only)
      external -
    • pullList

      public jakarta.ws.rs.core.Response pullList() throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • pull

      public jakarta.ws.rs.core.Response pull() throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • upload

      public jakarta.ws.rs.core.Response upload(InputStream inputStream) throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • doGetInputStream

      protected jakarta.ws.rs.core.Response doGetInputStream()
    • preparePull

      protected void preparePull() throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • sendError

      protected void sendError(int status, Exception cause) throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • sendError

      protected void sendError(jakarta.ws.rs.core.Response.Status status, Throwable t) throws ServerStreamHandlerResponseException
      Throws:
      ServerStreamHandlerResponseException
    • getServerStreamHandlerResponseException

      protected ServerStreamHandlerResponseException getServerStreamHandlerResponseException(jakarta.ws.rs.core.Response.Status status)
    • clear

      protected void clear()
      Clear all context
    • setResultFromRemote

      protected void setResultFromRemote(O businessOut)
    • endPush

      protected void endPush()
    • checkEndOfPush

      protected void checkEndOfPush(boolean remote)
    • throwTrappedException

      protected void throwTrappedException()
    • isUpload

      protected boolean isUpload()
      Returns:
      True if Write (client sends an InputStream), False if Read (client receives an InputStream)
    • getOpId

      protected String getOpId()
      Returns:
      the Operation Id (unique)
    • isAlreadyCompressed

      protected boolean isAlreadyCompressed()
      Returns:
      True if the InputStream is already compressed (POST)
    • shallCompress

      public boolean shallCompress()
      Returns:
      True if the InputStream shall be compressed (GET)
    • shallDecompress

      protected boolean shallDecompress()
      Returns:
      True if the InputStream shall be decompressed (GET and POST)
    • getBusinessIn

      protected I getBusinessIn()
      Returns:
      the passed BusinessIn during construction
    • getRequest

      public io.vertx.core.http.HttpServerRequest getRequest()
    • isKeepAlive

      public boolean isKeepAlive()
    • isKeepInputStreamCompressed

      public boolean isKeepInputStreamCompressed()
      True means the stream will be kept compressed if source (from client) is compressed or do not recompress getInputStream
    • setKeepInputStreamCompressed

      public void setKeepInputStreamCompressed(boolean change)
    • isResponseCompressed

      public boolean isResponseCompressed()
      True means the incoming stream is compressed (ZSTD)
    • setResponseCompressed

      public void setResponseCompressed(boolean change)
    • getOriginalHash

      public String getOriginalHash()
    • getVertx

      public io.vertx.mutiny.core.Vertx getVertx()
    • getInputStreamLength

      public long getInputStreamLength()
    • isExternal

      public boolean isExternal()
    • getCloser

      protected io.quarkus.resteasy.reactive.server.Closer getCloser()
    • checkDigestToCompute

      protected boolean checkDigestToCompute(I businessIn)
      Default based on QuarkusProperties.serverComputeSha256
      Returns:
      True if the digest is to be computed on the fly
    • checkPushAble

      protected abstract void checkPushAble(I businessIn, MultipleActionsInputStream inputStream) throws CcsClientGenericException, CcsServerGenericException
      Check if the request for POST is valid, and if so, adapt the given MultipleActionsInputStream that will be used to consume the original InputStream. The implementation shall use the business logic to check the validity for this InputStream reception (from client to server) and, if valid, use the MultipleActionsInputStream, either as is or as a standard InputStream. (example: check through Object Storage that object does not exist yet, and if so add the consumption of the stream for the Object Storage object creation). Note that the stream might be kept compressed if keepInputStreamCompressed was specified at construction.
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • getAnswerPushInputStream

      protected abstract O getAnswerPushInputStream(I businessIn, String finalHash, long size) throws CcsClientGenericException, CcsServerGenericException
      Returns a BusinessOut in case of POST (receiving InputStream on server side). The implementation shall use the business logic to get the right BusinessOut object to return. (example: getting the StorageObject object, including the computed or given Hash)
      Parameters:
      businessIn - businessIn as passed in constructor
      finalHash - the final Hash if computed on the fly, or the original given one
      size - the real size read (from received stream, could be compressed size if decompression is off at construction)
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • getHeaderPushInputStream

      protected abstract Map<String,String> getHeaderPushInputStream(I businessIn, String finalHash, long size, O businessOut) throws CcsClientGenericException, CcsServerGenericException
      Returns a Map for Headers response in case of POST (receiving InputStream on server side). (example: headers for object name, object size, ...)
      Parameters:
      businessIn - businessIn as passed in constructor
      finalHash - the final Hash if computed on the fly, or the original given one
      size - the real size read
      businessOut - previously constructed from getAnswerPushInputStream
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • checkPullAble

      protected abstract boolean checkPullAble(I businessIn, io.vertx.core.MultiMap headers) throws CcsClientGenericException, CcsServerGenericException
      The implementation must check using business object that get inputStream request (server sending InputStream as result) is valid according to the businessIn from te Rest API and the headers. (example: ObjectStorage check of existence of object)
      Returns:
      True if the read action is valid for this businessIn object and headers
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • getPullInputStream

      protected abstract InputStream getPullInputStream(I businessIn) throws CcsClientGenericException, CcsServerGenericException
      Returns the InputStream required for GET (server is sending the InputStream back to the client). The implementation shall use the business logic and controls to get the InputStream to return. (example: getting the Object Storage object stream)
      Parameters:
      businessIn - businessIn as passed in constructor
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • getHeaderPullInputStream

      protected abstract Map<String,String> getHeaderPullInputStream(I businessIn) throws CcsClientGenericException, CcsServerGenericException
      Returns a Map for Headers response in case of GET, added to InputStream get above (server is sending the InputStream back to the client) (example: headers for object name, object size...)
      Parameters:
      businessIn - businessIn as passed in constructor
      Throws:
      CcsClientGenericException
      CcsServerGenericException
    • getHeaderError

      protected abstract Map<String,String> getHeaderError(I businessIn, int status)
      Return headers for error message. (example: get headers in case of error as Object name, Bucket name...)