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 Link icon

  • Constructor Details Link icon

    • StreamHandlerAbstract Link icon

      protected StreamHandlerAbstract()
  • Method Details Link icon

    • postSetup Link icon

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

      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 Link icon

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

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

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

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

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

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

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

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

      protected void clear()
      Clear all context
    • setResultFromRemote Link icon

      protected void setResultFromRemote(O businessOut)
    • endPush Link icon

      protected void endPush()
    • checkEndOfPush Link icon

      protected void checkEndOfPush(boolean remote)
    • throwTrappedException Link icon

      protected void throwTrappedException()
    • isUpload Link icon

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

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

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

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

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

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

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

      public boolean isKeepAlive()
    • isKeepInputStreamCompressed Link icon

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

      public void setKeepInputStreamCompressed(boolean change)
    • isResponseCompressed Link icon

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

      public void setResponseCompressed(boolean change)
    • getOriginalHash Link icon

      public String getOriginalHash()
    • getVertx Link icon

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

      public long getInputStreamLength()
    • isExternal Link icon

      public boolean isExternal()
    • getCloser Link icon

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

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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...)