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
ServeAfterTransactionDownload.StreamResultCallback
Spring transactional callback that calls getStreamForDownload within a database transaction
-
Constructor Summary
Constructors Constructor Description ServeAfterTransactionDownload()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 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)
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)
-
-
-
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 interfacecom.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
-
-