Class ServeAfterTransactionDownload

java.lang.Object
com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload
All Implemented Interfaces:
com.atlassian.plugin.servlet.DownloadStrategy
Direct Known Subclasses:
AttachmentDownload, ExportDownload

public abstract class ServeAfterTransactionDownload extends Object implements com.atlassian.plugin.servlet.DownloadStrategy
This abstract download strategy allows implementors to gather necessary information from a database and set HTTP headers within a database transaction. Streaming of the actual download is done after the transaction is finished so that the database connection lifetime is not bound to the entire request lifetime.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    Spring transactional callback that calls getStreamForDownload within a database transaction
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getDecodedPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
     
    protected abstract @Nullable InputStream
    getStreamForDownload(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
    Get the input stream to serve to the client outside of the database transaction.
    protected org.springframework.transaction.support.TransactionCallback<com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload.StreamResult>
    getStreamResultCallback(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
     
    final void
    serveFile(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
     
    void
    setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
     
    protected void
    streamResponse(InputStream fromStream, OutputStream toStream)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.atlassian.plugin.servlet.DownloadStrategy

    matches
  • Constructor Details

    • ServeAfterTransactionDownload

      public ServeAfterTransactionDownload()
  • Method Details

    • setTransactionManager

      public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
    • getDecodedPathInfo

      public static String getDecodedPathInfo(javax.servlet.http.HttpServletRequest httpServletRequest)
    • serveFile

      public final void serveFile(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws com.atlassian.plugin.servlet.DownloadException
      Specified by:
      serveFile in interface com.atlassian.plugin.servlet.DownloadStrategy
      Throws:
      com.atlassian.plugin.servlet.DownloadException
    • streamResponse

      protected void streamResponse(InputStream fromStream, OutputStream toStream) throws IOException
      Throws:
      IOException
      Since:
      7.12
    • getStreamResultCallback

      protected org.springframework.transaction.support.TransactionCallback<com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload.StreamResult> getStreamResultCallback(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    • getStreamForDownload

      protected abstract @Nullable InputStream getStreamForDownload(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws IOException
      Get the input stream to serve to the client outside of the database transaction. The inputstream must be useable outside of the database transaction that created it
      Returns:
      The input stream to serve, or null if nothing to serve.
      Throws:
      IOException