Class 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.
    • Constructor Detail

      • ServeAfterTransactionDownload

        public ServeAfterTransactionDownload()
    • Method Detail

      • 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
      • 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

        @Nullable
        protected abstract 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