com.atlassian.confluence.pages
Interface AttachmentManager

All Known Subinterfaces:
AttachmentManagerInternal
All Known Implementing Classes:
CachingAttachmentManager, DefaultAttachmentManager, DelegatorAttachmentManager, WebDavAttachmentManager

public interface AttachmentManager


Method Summary
 void copyAttachment(Attachment attachment, ContentEntityObject destinationContent)
          Copy specified attachment to specified destination content.
 void copyAttachments(ContentEntityObject sourceContent, ContentEntityObject destinationContent)
          Copy the latest version of all the attachments on the sourceContent to the destinationContent.
 int countLatestVersionsOfAttachments(ContentEntityObject content)
          Returns a count of the number of latest versions of attachments
 java.util.List<Attachment> getAllVersions(Attachment attachment)
          Get all versions of an attachment, starting with the current version
 java.util.List<Attachment> getAllVersionsOfAttachments(ContentEntityObject content)
          Returns a list of all attachments, old and new.
 Attachment getAttachment(ContentEntityObject content, java.lang.String attachmentFileName)
          Get the most recent version of an attachment with a given name for a particular page
 Attachment getAttachment(ContentEntityObject content, java.lang.String attachmentFileName, int version)
          Retrieve a named attachment from a page
 Attachment getAttachment(long id)
           
 AttachmentDao getAttachmentDao()
          Retrieves the AttachmentDao for the AttachmentManager
 java.io.InputStream getAttachmentData(Attachment attachment)
          Retrieve the data for attachment
 java.lang.String getAttachmentDownloadPath(ContentEntityObject content, java.lang.String attachmentFileName)
          Get the download path for the most recent version of an attachment with the given name for some content
 com.atlassian.fugue.Maybe<Attachment> getAttachmentForDownloadPath(java.lang.String downloadPath)
          Find an Attachment for the given downloadPath.
 java.util.List<Attachment> getAttachments(ContentEntityObject content)
          Deprecated. since 5.5 - method name is confusing/inconsistent. Use getAllVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject) to get old and new attachments.
 AttachmentDataStorageType getBackingStorageType()
          Returns the currently active storage type.
 AttachmentDao.AttachmentCopier getCopier(AttachmentManager destination)
          Retrieves a AttachmentDao.AttachmentCopier that will allow the attachments from one data store to be copied across to another.
 java.util.List<Attachment> getLastAddedVersionsOf(Attachment attachment)
          Retrieves all the last added versions for each user who has added a version of the attachment That is, if a user has added multiple versions, only the latest added version will be added to the list returned.
 java.util.List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject content)
          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.
 java.util.List<Attachment> getPreviousVersions(Attachment attachment)
          Get all non-current versions of an attachment, not including the current version.
 void moveAttachment(Attachment latestVersion, java.lang.String fileName, ContentEntityObject newContent)
           
 void removeAttachmentFromServer(Attachment attachment)
          Removes an Attachment and its data from the server and data store.
 void removeAttachments(java.util.List<? extends Attachment> attachments)
          Removes the contents of attachments from the server
 void removeAttachmentVersionFromServer(Attachment attachment)
          Removes the given version of the Attachment and its data from the server and data store.
 void saveAttachment(Attachment attachment, Attachment previousVersion, java.io.InputStream attachmentData)
          Saves an Attachment and its data
 void saveAttachments(java.util.List<SavableAttachment> savableAttachments)
          Saves multiple attachment and their data
 void setAttachmentData(Attachment attachment, java.io.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

getAttachment

Attachment getAttachment(long id)
Parameters:
id -
Returns:
attachment with id

getAttachments

@Deprecated
java.util.List<Attachment> getAttachments(ContentEntityObject content)
Deprecated. since 5.5 - method name is confusing/inconsistent. Use getAllVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject) to get old and new attachments.

Returns a list of all attachments, old and new.


getAllVersionsOfAttachments

java.util.List<Attachment> getAllVersionsOfAttachments(ContentEntityObject content)
Returns a list of all attachments, old and new.


getLatestVersionsOfAttachments

java.util.List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject content)
Returns a list of only latest versions of attachments.


countLatestVersionsOfAttachments

int countLatestVersionsOfAttachments(ContentEntityObject content)
Returns a count of the number of latest versions of attachments


getAttachmentData

java.io.InputStream getAttachmentData(Attachment attachment)
Retrieve the data for attachment

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

removeAttachmentFromServer

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

Parameters:
attachment - the Attachment to remove

removeAttachmentVersionFromServer

void removeAttachmentVersionFromServer(Attachment attachment)
Removes the given version of the Attachment and its data from the server and data store.

In case of the given attachment being the latest version, the previous version (if any) gets removed and the given object impersonates the previous version as the latest version.

Parameters:
attachment - the Attachment to remove
Since:
4.3

removeAttachments

void removeAttachments(java.util.List<? extends Attachment> attachments)
Removes the contents of attachments from the server

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

moveAttachment

void moveAttachment(Attachment latestVersion,
                    java.lang.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

copyAttachments

void copyAttachments(ContentEntityObject sourceContent,
                     ContentEntityObject destinationContent)
                     throws java.io.IOException
Copy the latest version of all the attachments on the sourceContent to the destinationContent.

Parameters:
sourceContent - the content with attachments to be copied.
destinationContent - the content to copy the attachments to.
Throws:
java.io.IOException - if there are problems reading or writing attachment data during the copy.

copyAttachment

void copyAttachment(Attachment attachment,
                    ContentEntityObject destinationContent)
                    throws java.io.IOException
Copy specified attachment to specified destination content.

Parameters:
attachment - the attachment
destinationContent - the destination
Throws:
java.io.IOException

getAttachment

Attachment getAttachment(ContentEntityObject content,
                         java.lang.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

Attachment getAttachment(ContentEntityObject content,
                         java.lang.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

getAttachmentDownloadPath

java.lang.String getAttachmentDownloadPath(ContentEntityObject content,
                                           java.lang.String attachmentFileName)
Get the download path for the most recent version of an attachment with the given name for some content

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

saveAttachment

void saveAttachment(Attachment attachment,
                    Attachment previousVersion,
                    java.io.InputStream attachmentData)
                    throws java.io.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:
java.io.IOException
java.lang.IllegalArgumentException - if attachment's content is not set

saveAttachments

void saveAttachments(java.util.List<SavableAttachment> savableAttachments)
                     throws java.io.IOException
Saves multiple attachment and their data

Parameters:
savableAttachments - 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:
java.io.IOException
java.lang.IllegalArgumentException - if attachment's content is not set

setAttachmentData

void setAttachmentData(Attachment attachment,
                       java.io.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

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

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

AttachmentDao getAttachmentDao()
Retrieves the AttachmentDao for the AttachmentManager

Returns:
An AttachmentDao instance

getAllVersions

java.util.List<Attachment> getAllVersions(Attachment attachment)
Get all versions of an attachment, starting with the current version


getPreviousVersions

java.util.List<Attachment> 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.

getLastAddedVersionsOf

java.util.List<Attachment> getLastAddedVersionsOf(Attachment attachment)
Retrieves all the last added versions for each user who has added a version of the attachment That is, if a user has added multiple versions, only the latest added version will be added to the list returned. Result will be sorted with the earliest version coming first.

Parameters:
attachment - attachment (must be the latest version)
Returns:
the last added versions for each user who has added a version of the attachment
Throws:
java.lang.IllegalArgumentException - if the attachment is not the latest version or null

getBackingStorageType

AttachmentDataStorageType getBackingStorageType()
Returns the currently active storage type.

Since:
4.3
See Also:
AttachmentDao.getBackingStorageType()

getAttachmentForDownloadPath

com.atlassian.fugue.Maybe<Attachment> getAttachmentForDownloadPath(java.lang.String downloadPath)
Find an Attachment for the given downloadPath.

The path must at least contain the segment produced by Attachment.getDownloadPath(), that is /download/attachments/<contentId>/<fileName> where <contentId> identifies a valid ContentEntityObject and <fileName> identifies a valid Attachment attached to that ContentEntityObject.

Parameters:
downloadPath - the download path identifying an Attachment.This value is expected to be url encoded, with spaces converted to %20 instead of a '+'
Returns:
maybe the attachment if the given download path matches the criteria as described above and the referenced objects are known to the system
Since:
5.2
See Also:
Attachment.getDownloadPath()


Copyright © 2003-2014 Atlassian. All Rights Reserved.