public interface AttachmentManager
Modifier and Type | Method and Description |
---|---|
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.
|
void |
copyAttachments(ContentEntityObject sourceContent,
ContentEntityObject destinationContent,
SaveContext saveContext)
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
|
int |
countLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content,
Date since)
Fetches number of attachments changed on a page since a specific timestamp
|
int |
countLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
Returns a count of the number of latest versions of attachments (including trashed)
|
default Optional<Attachment> |
findAttachmentForDownloadPath(String downloadPath)
Find an
Attachment for the given downloadPath . |
List<Attachment> |
getAllVersions(Attachment attachment)
Get all versions of an attachment, starting with the current version
|
List<Attachment> |
getAllVersionsOfAttachments(ContentEntityObject content)
Returns a list of all attachments, old and new.
|
Attachment |
getAttachment(ContentEntityObject content,
String attachmentFileName)
Deprecated.
since 7.5.0, use
AttachmentService instead in plugins,
or use AttachmentManagerInternal in core where applicable |
Attachment |
getAttachment(ContentEntityObject content,
String attachmentFileName,
int version)
Deprecated.
since 7.5.0, use
AttachmentService instead in plugins,
or use AttachmentManagerInternal in core where applicable |
Attachment |
getAttachment(long id)
Deprecated.
since 7.5.0, use
AttachmentService instead in plugins,
or use AttachmentManagerInternal in core where applicable |
AttachmentDao |
getAttachmentDao()
Deprecated.
since 7.5.0, no replacement, use dependency injection where possible
|
InputStream |
getAttachmentData(Attachment attachment)
Retrieve the data for attachment
|
InputStream |
getAttachmentData(Attachment attachment,
Optional<RangeRequest> range)
Retrieve the specified range of data for attachment
|
String |
getAttachmentDownloadPath(ContentEntityObject content,
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(String downloadPath)
Deprecated.
since 7.0.1. Use
findAttachmentForDownloadPath(String) |
List<Attachment> |
getAttachments(List<Long> ids)
Deprecated.
since 7.5.0, use
AttachmentService instead in plugins,
or use AttachmentManagerInternal in core where applicable |
Optional<AttachmentStatisticsDTO> |
getAttachmentStatistics()
Fetches statistics about 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.
|
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.
|
List<Attachment> |
getLatestVersionsOfAttachments(ContentEntityObject content)
Returns a list of only latest versions of attachments.
|
List<Attachment> |
getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)
Returns a list of all the latest versions of attachments for all the CEOs provided
|
List<Attachment> |
getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
Returns a list of only latest versions of attachments (including trashed).
|
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<Attachment> |
getPreviousVersions(Attachment attachment)
Get all non-current versions of an attachment, not including the current
version.
|
Map<Long,Long> |
getRemappedAttachmentIds()
Gets a list of remapped attachment IDs.
|
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<? 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 |
removeAttachmentWithoutNotifications(Attachment attachment)
Removes an Attachment and its data from the server while suppressing notifications.
|
void |
restore(Attachment attachment)
Restores an attachment from trash.
|
void |
saveAttachment(Attachment attachment,
@Nullable Attachment previousVersion,
InputStream attachmentData)
Saves an Attachment and its data
|
void |
saveAttachment(Attachment attachment,
@Nullable Attachment previousVersion,
InputStream attachmentData,
SaveContext saveContext)
Saves an Attachment and its data, taking a
SaveContext to allow
more useful event handling. |
void |
saveAttachments(List<SavableAttachment> savableAttachments)
Saves multiple attachment and their data
|
void |
saveAttachments(List<SavableAttachment> savableAttachments,
SaveContext saveContext)
Saves multiple attachment and their data
|
void |
setAttachmentData(Attachment attachment,
InputStream attachmentData)
Set the data belonging to attachment
|
void |
trash(Attachment attachment)
Moves an attachment to the trash.
|
@Deprecated Attachment getAttachment(long id)
AttachmentService
instead in plugins,
or use AttachmentManagerInternal
in core where applicableid
- @Deprecated List<Attachment> getAttachments(List<Long> ids)
AttachmentService
instead in plugins,
or use AttachmentManagerInternal
in core where applicableids
- list of IDs to retrieve.List<Attachment> getAllVersionsOfAttachments(ContentEntityObject content)
List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject content)
List<Attachment> getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)
contentEntityObjects
- List<Attachment> getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
int countLatestVersionsOfAttachments(ContentEntityObject content)
int countLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
int countLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content, Date since)
content
- the content objectsince
- the date of earliest changeOptional<AttachmentStatisticsDTO> getAttachmentStatistics()
InputStream getAttachmentData(Attachment attachment)
attachment
- the Attachment the data belongs toRuntimeException
- if the data could not be foundInputStream getAttachmentData(Attachment attachment, Optional<RangeRequest> range)
attachment
- the Attachment the data belongs torange
- the range of data to retrieve. See ByteRanges
RuntimeException
- if the data could not be foundvoid removeAttachmentFromServer(Attachment attachment)
attachment
- the Attachment to removevoid removeAttachmentWithoutNotifications(Attachment attachment)
void removeAttachmentVersionFromServer(Attachment attachment)
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.
attachment
- the Attachment to removevoid removeAttachments(List<? extends Attachment> attachments)
attachments
- a List of AttachmentsremoveAttachmentFromServer(Attachment)
void moveAttachment(Attachment latestVersion, String fileName, ContentEntityObject newContent)
latestVersion
- The attachment to be movedfileName
- New name of the filenewContent
- The new contentEntiityObject which will be parent to the attachmentvoid copyAttachments(ContentEntityObject sourceContent, ContentEntityObject destinationContent, SaveContext saveContext) throws IOException
sourceContent
- the content with attachments to be copied.destinationContent
- the content to copy the attachments to.saveContext
- details the circumstances under which the attachments are being copied.IOException
- if there are problems reading or writing attachment data during the copy.void copyAttachments(ContentEntityObject sourceContent, ContentEntityObject destinationContent) throws IOException
sourceContent
- the content with attachments to be copied.destinationContent
- the content to copy the attachments to.IOException
- if there are problems reading or writing attachment data during the copy.void copyAttachment(Attachment attachment, ContentEntityObject destinationContent) throws IOException
attachment
- the attachmentdestinationContent
- the destinationIOException
@Deprecated Attachment getAttachment(ContentEntityObject content, String attachmentFileName, int version)
AttachmentService
instead in plugins,
or use AttachmentManagerInternal
in core where applicablecontent
- the page the attachment is attached toattachmentFileName
- the filename of the attachment to retrieveversion
- 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@Deprecated Attachment getAttachment(ContentEntityObject content, String attachmentFileName)
AttachmentService
instead in plugins,
or use AttachmentManagerInternal
in core where applicablecontent
- the page the attachment is attached toattachmentFileName
- the filename of the attachment to be retrievedString getAttachmentDownloadPath(ContentEntityObject content, String attachmentFileName)
content
- the content the attachment is attached toattachmentFileName
- the filename of the attachment to be retrievedvoid saveAttachment(Attachment attachment, @Nullable Attachment previousVersion, InputStream attachmentData, SaveContext saveContext) throws IOException
SaveContext
to allow
more useful event handling.attachment
- the modified version of the AttachmentpreviousVersion
- the original version of the Attachment (null if new)attachmentData
- an InputStream representing the data of the AttachmentsaveContext
- provides more information about the circumstances of the saveIOException
IllegalArgumentException
- if attachment's content is not setvoid saveAttachment(Attachment attachment, @Nullable Attachment previousVersion, InputStream attachmentData) throws IOException
attachment
- the modified version of the AttachmentpreviousVersion
- the original version of the Attachment (null if new)attachmentData
- an InputStream representing the data of the AttachmentIOException
IllegalArgumentException
- if attachment's content is not setvoid saveAttachments(List<SavableAttachment> savableAttachments, SaveContext saveContext) throws IOException
savableAttachments
- the modified version of the AttachmentsaveContext
- provides more details about saving. If in doubt pass DefaultSaveContext.DEFAULT
.IOException
IllegalArgumentException
- if attachment's content is not setvoid saveAttachments(List<SavableAttachment> savableAttachments) throws IOException
savableAttachments
- the modified version of the AttachmentIOException
IllegalArgumentException
- if attachment's content is not setvoid setAttachmentData(Attachment attachment, InputStream attachmentData) throws AttachmentDataExistsException
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.
attachment
- Attachment the data belongs toattachmentData
- the data to be savedAttachmentDataExistsException
- if data for attachment already existsAttachmentDao.AttachmentMigrator getMigrator(AttachmentManager destination)
destination
- the AttachmentManager the data is being moved toAttachmentDao.AttachmentCopier getCopier(AttachmentManager destination)
destination
- the AttachmentManager the data is being copied to@Deprecated AttachmentDao getAttachmentDao()
List<Attachment> getAllVersions(Attachment attachment)
List<Attachment> getPreviousVersions(Attachment attachment)
attachment
- the attachment to get all non-current versions for.List<Attachment> getLastAddedVersionsOf(Attachment attachment)
attachment
- attachment (must be the latest version)IllegalArgumentException
- if the attachment is not the latest version or nullAttachmentDataStorageType getBackingStorageType()
AttachmentDao.getBackingStorageType()
@Deprecated com.atlassian.fugue.Maybe<Attachment> getAttachmentForDownloadPath(String downloadPath)
findAttachmentForDownloadPath(String)
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
.
downloadPath
- the download path identifying an Attachment
.This value is expected to be url encoded,
with spaces converted to %20 instead of a '+'Attachment.getDownloadPath()
default Optional<Attachment> findAttachmentForDownloadPath(String downloadPath)
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
.
downloadPath
- the download path identifying an Attachment
.This value is expected to be url encoded,
with spaces converted to %20 instead of a '+'Attachment.getDownloadPath()
Map<Long,Long> getRemappedAttachmentIds()
void trash(Attachment attachment)
attachment
- the attachment to be trashedvoid restore(Attachment attachment)
attachment
- the attachment to restoreCopyright © 2003–2021 Atlassian. All rights reserved.