com.atlassian.confluence.servlet.download
Class AttachmentDownload

java.lang.Object
  extended bycom.atlassian.confluence.servlet.download.ServeAfterTransactionDownload
      extended bycom.atlassian.confluence.servlet.download.AttachmentDownload
All Implemented Interfaces:
DownloadStrategy
Direct Known Subclasses:
ThumbnailDownload

public class AttachmentDownload
extends ServeAfterTransactionDownload


Nested Class Summary
 
Nested classes inherited from class com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload
ServeAfterTransactionDownload.StreamResultCallback
 
Field Summary
protected  AttachmentManager attachmentManager
           
protected  ContentEntityObjectDao contentEntityObjectDao
           
protected  EventManager eventManager
           
protected  PermissionManager permissionManager
           
protected  UserAccessor userAccessor
           
 
Constructor Summary
AttachmentDownload()
           
 
Method Summary
protected  String extractAttachmentFileName(javax.servlet.http.HttpServletRequest httpServletRequest)
           
protected  long extractObjectId(javax.servlet.http.HttpServletRequest httpServletRequest, String prefix)
           
protected  int extractVersion(javax.servlet.http.HttpServletRequest httpServletRequest)
           
protected  void generateAttachmentDownloadEvent(Attachment attachment)
           
protected  Attachment getAttachment(ContentEntityObject entity, javax.servlet.http.HttpServletRequest httpServletRequest)
           
protected  InputStream getAttachmentStream(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Attachment attachment)
           
protected  ContentEntityObject getEntity(javax.servlet.http.HttpServletRequest httpServletRequest)
           
protected  Date getLastModificationDate(Attachment attachment)
           
 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  String getUrlPrefix()
           
 UserAccessor getUserAccessor()
           
protected  boolean hasUserPrivilegeForDownload(javax.servlet.http.HttpServletRequest httpServletRequest, ContentEntityObject entity)
           
 boolean matches(String urlPath)
           
 void setAttachmentManager(AttachmentManager attachmentManager)
           
 void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)
           
 void setEventManager(EventManager eventManager)
           
protected  void setFileNameHeader(javax.servlet.http.HttpServletResponse httpServletResponse, String downloadFileName, String userAgent)
          We should be able to encode the filename header per RFC 2047, but no browsers currently support it.
protected  void setHeadersForAttachment(Attachment attachment, javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)
           
 void setPermissionManager(PermissionManager permissionManager)
           
 void setUserAccessor(UserAccessor userAccessor)
           
 
Methods inherited from class com.atlassian.confluence.servlet.download.ServeAfterTransactionDownload
getDecodedPathInfo, getStreamResultCallback, serveFile, setTransactionManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentEntityObjectDao

protected ContentEntityObjectDao contentEntityObjectDao

attachmentManager

protected AttachmentManager attachmentManager

permissionManager

protected PermissionManager permissionManager

eventManager

protected EventManager eventManager

userAccessor

protected UserAccessor userAccessor
Constructor Detail

AttachmentDownload

public AttachmentDownload()
Method Detail

matches

public boolean matches(String urlPath)

setContentEntityObjectDao

public void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)

setAttachmentManager

public void setAttachmentManager(AttachmentManager attachmentManager)

setPermissionManager

public void setPermissionManager(PermissionManager permissionManager)

setEventManager

public void setEventManager(EventManager eventManager)

getStreamForDownload

public InputStream getStreamForDownload(javax.servlet.http.HttpServletRequest httpServletRequest,
                                        javax.servlet.http.HttpServletResponse httpServletResponse)
                                 throws IOException
Description copied from class: ServeAfterTransactionDownload
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

Specified by:
getStreamForDownload in class ServeAfterTransactionDownload
Parameters:
httpServletRequest -
httpServletResponse -
Returns:
The input stream to serve, or null if nothing to serve.
Throws:
IOException

getLastModificationDate

protected Date getLastModificationDate(Attachment attachment)

getEntity

protected ContentEntityObject getEntity(javax.servlet.http.HttpServletRequest httpServletRequest)

getUrlPrefix

protected String getUrlPrefix()

getAttachment

protected Attachment getAttachment(ContentEntityObject entity,
                                   javax.servlet.http.HttpServletRequest httpServletRequest)

setHeadersForAttachment

protected void setHeadersForAttachment(Attachment attachment,
                                       javax.servlet.http.HttpServletRequest httpServletRequest,
                                       javax.servlet.http.HttpServletResponse httpServletResponse)

getAttachmentStream

protected InputStream getAttachmentStream(javax.servlet.http.HttpServletRequest httpServletRequest,
                                          javax.servlet.http.HttpServletResponse httpServletResponse,
                                          Attachment attachment)
                                   throws IOException
Throws:
IOException

setFileNameHeader

protected void setFileNameHeader(javax.servlet.http.HttpServletResponse httpServletResponse,
                                 String downloadFileName,
                                 String userAgent)
We should be able to encode the filename header per RFC 2047, but no browsers currently support it. So for non-ASCII filenames, we'll omit this header, and good browsers will use the filename from the URL, for which they know the proper encoding. MSIE will only understand a filename URL-encoded in the header, which is weird, but some user-agent matching fixes that.


extractObjectId

protected long extractObjectId(javax.servlet.http.HttpServletRequest httpServletRequest,
                               String prefix)

extractAttachmentFileName

protected String extractAttachmentFileName(javax.servlet.http.HttpServletRequest httpServletRequest)

extractVersion

protected int extractVersion(javax.servlet.http.HttpServletRequest httpServletRequest)

hasUserPrivilegeForDownload

protected boolean hasUserPrivilegeForDownload(javax.servlet.http.HttpServletRequest httpServletRequest,
                                              ContentEntityObject entity)

generateAttachmentDownloadEvent

protected void generateAttachmentDownloadEvent(Attachment attachment)

setUserAccessor

public void setUserAccessor(UserAccessor userAccessor)

getUserAccessor

public UserAccessor getUserAccessor()


Confluence is developed by Atlassian.