com.atlassian.confluence.pages
Interface AttachmentManager

All Known Implementing Classes:
AbstractAttachmentManager, DelegatorAttachmentManager

public interface AttachmentManager


Method Summary
 List getAllVersions(Attachment attachment)
          Get all versions of an attachment, starting with the current version
 Attachment getAttachment(ContentEntityObject content, String attachmentFileName)
          Get the most recent version of an attachment with a given name for a particular page
 Attachment getAttachment(ContentEntityObject content, String attachmentFileName, int version)
          Retrieve a named attachment from a page
 AttachmentDao getAttachmentDao()
          Retrieves the AttachmentDao for the AttachmentManager
 InputStream getAttachmentData(Attachment attachment)
          Retrieve the data for attachment
 List getAttachments(ContentEntityObject content)
          Returns a list of all attachments, old and new.
 List getAttachments(ListQuery query, int firstResult)
           
 AttachmentDao.AttachmentCopier getCopier(AttachmentManager destination)
          Retrieves a AttachmentDao.AttachmentCopier that will allow the attachments from one data store to be copied across to another.
 List getLatestVersionsOfAttachments(ContentEntityObject content)
          b Returns a list of only latest versions of attachments.
 AttachmentDao.AttachmentMigrator getMigrator(AttachmentManager destination)
          Retrieves a AttachmentDao.AttachmentMigrator that will allow the attachments from one data store to be moved across to another.
 List getPreviousVersions(Attachment attachment)
          Get all non-current versions of an attachment, not including the current version.
 void moveAttachment(Attachment latestVersion, String fileName, ContentEntityObject newContent)
           
 void removeAttachmentFromServer(Attachment attachment)
          Removes an Attachment and its data from the server and data store
 void removeAttachments(List attachments)
          Removes the contents of attachments from the server
 void saveAttachment(Attachment attachment, Attachment previousVersion, InputStream attachmentData)
          Saves an Attachment and its data
 void setAttachmentData(Attachment attachment, InputStream attachmentData)
          Set the data belonging to attachment This method can be used when there is missing data for an Attachment (e.g.
 

Method Detail

getAttachments

public List getAttachments(ContentEntityObject content)
Returns a list of all attachments, old and new.


getAttachments

public List getAttachments(ListQuery query,
                           int firstResult)

getLatestVersionsOfAttachments

public List getLatestVersionsOfAttachments(ContentEntityObject content)
b Returns a list of only latest versions of attachments.


getAttachmentData

public InputStream getAttachmentData(Attachment attachment)
Retrieve the data for attachment

Parameters:
attachment - the Attachment the data belongs to
Returns:
InputStream representing the data
Throws:
RuntimeException - if the data could not be found

removeAttachmentFromServer

public void removeAttachmentFromServer(Attachment attachment)
Removes an Attachment and its data from the server and data store

Parameters:
attachment - the Attachment to remove

removeAttachments

public void removeAttachments(List attachments)
Removes the contents of attachments from the server

Parameters:
attachments - a List of Attachments
See Also:
removeAttachmentFromServer(Attachment)

moveAttachment

public void moveAttachment(Attachment latestVersion,
                           String fileName,
                           ContentEntityObject newContent)
Parameters:
latestVersion - The attachment to be moved
fileName - New name of the file
newContent - The new contentEntiityObject which will be parent to the attachment

getAttachment

public Attachment getAttachment(ContentEntityObject content,
                                String attachmentFileName,
                                int version)
Retrieve a named attachment from a page

Parameters:
content - the page the attachment is attached to
attachmentFileName - the filename of the attachment to retrieve
version - the version of the attachment to retrieve. If you provide a version of 0 or less, you'll get the most recent version, but you should probably use #getAttachment(AbstractPage, String) instead for that purpose instead
Returns:
the requested attachment, or null if the requested attachment does not exist.

getAttachment

public Attachment getAttachment(ContentEntityObject content,
                                String attachmentFileName)
Get the most recent version of an attachment with a given name for a particular page

Parameters:
content - the page the attachment is attached to
attachmentFileName - the filename of the attachment to be retrieved
Returns:
the appropriate attachment, or null if no such attachment exists

saveAttachment

public void saveAttachment(Attachment attachment,
                           Attachment previousVersion,
                           InputStream attachmentData)
                    throws IOException
Saves an Attachment and its data

Parameters:
attachment - the modified version of the Attachment
previousVersion - the original version of the Attachment (null if new)
attachmentData - an InputStream representing the data of the Attachment
Throws:
IOException
IllegalArgumentException - if attachment's content is not set

setAttachmentData

public void setAttachmentData(Attachment attachment,
                              InputStream attachmentData)
                       throws AttachmentDataExistsException
Set the data belonging to attachment This method can be used when there is missing data for an Attachment (e.g. during imports) and the data needs to be set manually.

Parameters:
attachment - Attachment the data belongs to
attachmentData - the data to be saved
Throws:
AttachmentDataExistsException - if data for attachment already exists

getMigrator

public AttachmentDao.AttachmentMigrator getMigrator(AttachmentManager destination)
Retrieves a AttachmentDao.AttachmentMigrator that will allow the attachments from one data store to be moved across to another.

Parameters:
destination - the AttachmentManager the data is being moved to
Returns:
an AttachmentMigrator object

getCopier

public AttachmentDao.AttachmentCopier getCopier(AttachmentManager destination)
Retrieves a AttachmentDao.AttachmentCopier that will allow the attachments from one data store to be copied across to another.

Parameters:
destination - the AttachmentManager the data is being copied to
Returns:
an AttachmentCopier object

getAttachmentDao

public AttachmentDao getAttachmentDao()
Retrieves the AttachmentDao for the AttachmentManager

Returns:
An AttachmentDao instance

getAllVersions

public List getAllVersions(Attachment attachment)
Get all versions of an attachment, starting with the current version


getPreviousVersions

public List getPreviousVersions(Attachment attachment)
Get all non-current versions of an attachment, not including the current version. (ordered from most recent)

Parameters:
attachment - the attachment to get all non-current versions for.


Confluence is developed by Atlassian.