Class HttpHeadersInitializer

java.lang.Object
org.dspace.app.rest.utils.HttpHeadersInitializer

public class HttpHeadersInitializer extends Object
This class takes data from the Bitstream/File that has to be send. It'll then digest this input and save it in its local variables. When calling {initialiseHeaders()}, the input and information will be used to set the proper headers with this info and return an Object of HttpHeaders to be used in the response that'll be generated
  • Field Details

  • Constructor Details

    • HttpHeadersInitializer

      public HttpHeadersInitializer()
  • Method Details

    • with

      public HttpHeadersInitializer with(jakarta.servlet.http.HttpServletRequest httpRequest)
    • with

      public HttpHeadersInitializer with(jakarta.servlet.http.HttpServletResponse httpResponse)
    • withLength

      public HttpHeadersInitializer withLength(long length)
    • withFileName

      public HttpHeadersInitializer withFileName(String fileName)
    • withChecksum

      public HttpHeadersInitializer withChecksum(String checksum)
    • withMimetype

      public HttpHeadersInitializer withMimetype(String mimetype)
    • withLastModified

      public HttpHeadersInitializer withLastModified(long lastModified)
    • withBufferSize

      public HttpHeadersInitializer withBufferSize(int bufferSize)
    • withDisposition

      public HttpHeadersInitializer withDisposition(String contentDisposition)
    • initialiseHeaders

      public HttpHeaders initialiseHeaders() throws IOException
      This method will be called to create a HttpHeaders object which will contain the headers needed to form a proper response when returning the Bitstream/File
      Returns:
      A HttpHeaders object containing the information for the Bitstream/File to be sent
      Throws:
      IOException - If something goes wrong
    • isValid

      public boolean isValid() throws IOException
      This method will validate whether or not the given Response/Request/Information/Variables are valid. If they're invalid, the Response shouldn't be given. This will do null checks on the response, request, inputstream and filename. Other than this, it'll check Request headers to see if their information is correct.
      Returns:
      Throws:
      IOException