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 ClassesModifier and TypeClassDescriptionprotected classSpring transactional callback that calls getStreamForDownload within a database transaction -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDecodedPathInfo(jakarta.servlet.http.HttpServletRequest httpServletRequest) protected abstract @Nullable InputStreamgetStreamForDownload(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) final voidserveFile(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) protected voidstreamResponse(InputStream fromStream, OutputStream toStream) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-
serveFile
public final void serveFile(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) throws com.atlassian.plugin.servlet.DownloadException - Specified by:
serveFilein interfacecom.atlassian.plugin.servlet.DownloadStrategy- Throws:
com.atlassian.plugin.servlet.DownloadException
-
streamResponse
- Throws:
IOException- Since:
- 7.12
-
getStreamResultCallback
protected org.springframework.transaction.support.TransactionCallback<com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload.StreamResult> getStreamResultCallback(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
getStreamForDownload
protected abstract @Nullable InputStream getStreamForDownload(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.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
-