Class DelegatorAttachmentManager
- All Implemented Interfaces:
AttachmentManagerInternal
,AttachmentManager
,DelegatingAttachmentManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Returns a count of the number of latest versions of attachmentsint
countLatestVersionsOfAttachmentsOnPageSince
(ContentEntityObject content, Date since) Fetches number of attachments changed on a page since a specific timestampint
Returns a count of the number of latest versions of attachments (including trashed)void
deepAttachmentDelete
(AttachmentDeleteOptions attachmentDeleteOptions) Support delete multiple attachments in batchfindAttachmentForDownloadPath
(String downloadPath) Find anAttachment
for the givendownloadPath
.getAllVersions
(Attachment attachment) Get all versions of an attachment, starting with the current versionReturns a list of all attachments, old and new.getAttachment
(long id) getAttachment
(ContentEntityObject content, String attachmentFileName) Get the most recent version of an attachment with a given name for a particular pagegetAttachment
(ContentEntityObject content, String attachmentFileName, int version) Retrieve a named attachment from a pageProvides a back door to the underlyingAttachmentDao
.getAttachmentData
(Attachment attachment) Retrieve the data for attachmentgetAttachmentData
(Attachment attachment, Optional<RangeRequest> range) Retrieve the specified range of data for attachmentgetAttachmentDownloadPath
(ContentEntityObject content, String attachmentFileName) Get the download path for the most recent version of an attachment with the given name for some contentReturn the AttachmentManager implementation that the delegator wrapsgetAttachments
(List<Long> ids) Returns a list of attachments matching the given list of IDs.Fetches statistics about attachmentsReturns the currently active storage type.getCopier
(AttachmentManagerInternal destination) Retrieves a AttachmentDao.AttachmentCopier that will allow the attachments from one data store to be copied across to another.getFilteredAttachments
(ContentEntityObject content, LimitedRequest pageRequest, Predicate<? super Attachment> filterPredicate) Returns the current attachments under the CEO.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.Returns a list of only latest versions of attachments.getLatestVersionsOfAttachmentsForMultipleCeos
(Iterable<? extends ContentEntityObject> contentEntityObjects) Returns a list of all the latest versions of attachments for all the CEOs providedReturns a list of only latest versions of attachments (including trashed).getLatestVersionsOfAttachmentsWithAnyStatusForContainers
(Iterable<? extends ContentEntityObject> contentEntityObjects) Returns a list of all the latest versions of attachments for all the CEOs provided (including trashed)getPreviousVersions
(Attachment attachment) Get all non-current versions of an attachment, not including the current version.Gets a list of remapped attachment IDs.void
moveAttachment
(Attachment attachment, ContentEntityObject newContainer) Moves an attachment to a differentContentEntityObject
container.void
moveAttachment
(Attachment attachment, String newFileName, ContentEntityObject newName) 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 servervoid
removeAttachmentVersionFromServer
(Attachment attachment) Removes the given version of the Attachment and its data from the server and data store.void
Removes the given version of the Attachment and its data from the server and data store while suppressing notifications.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, Attachment previousVersion, InputStream attachmentData) Saves an Attachment and its datavoid
saveAttachment
(Attachment attachment, Attachment previousVersion, InputStream attachmentData, SaveContext saveContext) Saves an Attachment and its data, taking aSaveContext
to allow more useful event handling.void
saveAttachments
(List<SavableAttachment> savableAttachments) Saves multiple attachment and their datavoid
saveAttachments
(List<SavableAttachment> savableAttachments, SaveContext saveContext) Saves multiple attachment and their datavoid
setAttachmentData
(Attachment attachment, InputStream attachmentData) Set the data belonging to attachmentvoid
setDatabaseAttachmentManager
(AttachmentManagerInternal databaseAttachmentManager) void
setDefaultAttachmentManager
(AttachmentManagerInternal defaultAttachmentManager) void
setSettingsManager
(SettingsManager settingsManager) void
trash
(Attachment attachment) Moves an attachment to the trash.
-
Constructor Details
-
DelegatorAttachmentManager
public DelegatorAttachmentManager()
-
-
Method Details
-
getAttachmentManager
Description copied from interface:DelegatingAttachmentManager
Return the AttachmentManager implementation that the delegator wraps- Specified by:
getAttachmentManager
in interfaceDelegatingAttachmentManager
- Returns:
- an AttachmentManager instance
-
deepAttachmentDelete
Description copied from interface:AttachmentManager
Support delete multiple attachments in batch- Specified by:
deepAttachmentDelete
in interfaceAttachmentManager
-
getAttachment
- Specified by:
getAttachment
in interfaceAttachmentManager
- Returns:
- attachment with id
-
getAttachments
Description copied from interface:AttachmentManager
Returns a list of attachments matching the given list of IDs. Returns an empty list if no such attachments exist. In the case where some IDs exist and some don't, only the existing Attachments will be returned.- Specified by:
getAttachments
in interfaceAttachmentManager
- Parameters:
ids
- list of IDs to retrieve.- Returns:
- attachments matching ids in the list
-
getAllVersionsOfAttachments
Description copied from interface:AttachmentManager
Returns a list of all attachments, old and new.- Specified by:
getAllVersionsOfAttachments
in interfaceAttachmentManager
-
getLatestVersionsOfAttachments
Description copied from interface:AttachmentManager
Returns a list of only latest versions of attachments.- Specified by:
getLatestVersionsOfAttachments
in interfaceAttachmentManager
-
getLatestVersionsOfAttachmentsForMultipleCeos
public List<Attachment> getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects) Description copied from interface:AttachmentManager
Returns a list of all the latest versions of attachments for all the CEOs provided- Specified by:
getLatestVersionsOfAttachmentsForMultipleCeos
in interfaceAttachmentManager
-
getLatestVersionsOfAttachmentsWithAnyStatus
Description copied from interface:AttachmentManager
Returns a list of only latest versions of attachments (including trashed).- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatus
in interfaceAttachmentManager
-
getLatestVersionsOfAttachmentsWithAnyStatusForContainers
public List<Attachment> getLatestVersionsOfAttachmentsWithAnyStatusForContainers(Iterable<? extends ContentEntityObject> contentEntityObjects) Description copied from interface:AttachmentManagerInternal
Returns a list of all the latest versions of attachments for all the CEOs provided (including trashed)- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatusForContainers
in interfaceAttachmentManagerInternal
-
getFilteredAttachments
public PageResponse<Attachment> getFilteredAttachments(ContentEntityObject content, LimitedRequest pageRequest, Predicate<? super Attachment> filterPredicate) Returns the current attachments under the CEO.- Specified by:
getFilteredAttachments
in interfaceAttachmentManagerInternal
- Parameters:
content
- the content to return attachments forpageRequest
- the pagination requestedfilterPredicate
- the predicate for filtering found attachments- Returns:
- the paginated response of Page entities
-
countLatestVersionsOfAttachments
Description copied from interface:AttachmentManager
Returns a count of the number of latest versions of attachments- Specified by:
countLatestVersionsOfAttachments
in interfaceAttachmentManager
-
countLatestVersionsOfAttachmentsWithAnyStatus
Description copied from interface:AttachmentManager
Returns a count of the number of latest versions of attachments (including trashed)- Specified by:
countLatestVersionsOfAttachmentsWithAnyStatus
in interfaceAttachmentManager
-
countLatestVersionsOfAttachmentsOnPageSince
Description copied from interface:AttachmentManager
Fetches number of attachments changed on a page since a specific timestamp- Specified by:
countLatestVersionsOfAttachmentsOnPageSince
in interfaceAttachmentManager
- Parameters:
content
- the content objectsince
- the date of earliest change- Returns:
- the number of attachments on a content object (including trashed) changed since
-
getAttachmentStatistics
Description copied from interface:AttachmentManager
Fetches statistics about attachments- Specified by:
getAttachmentStatistics
in interfaceAttachmentManager
- Returns:
- an AttachmentStatisticsDTO object with statistics about attachments such as total and current count
-
getAttachment
public Attachment getAttachment(ContentEntityObject content, String attachmentFileName, int version) Description copied from interface:AttachmentManager
Retrieve a named attachment from a page- Specified by:
getAttachment
in interfaceAttachmentManager
- Parameters:
content
- 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- Returns:
- the requested attachment, or null if the requested attachment does not exist.
-
getAttachment
Description copied from interface:AttachmentManager
Get the most recent version of an attachment with a given name for a particular page- Specified by:
getAttachment
in interfaceAttachmentManager
- Parameters:
content
- the page the attachment is attached toattachmentFileName
- the filename of the attachment to be retrieved- Returns:
- the appropriate attachment, or null if no such attachment exists
-
getAttachmentDownloadPath
Description copied from interface:AttachmentManager
Get the download path for the most recent version of an attachment with the given name for some content- Specified by:
getAttachmentDownloadPath
in interfaceAttachmentManager
- Parameters:
content
- the content the attachment is attached toattachmentFileName
- the filename of the attachment to be retrieved- Returns:
- the appropriate attachment download path, or null if no such attachment exists
-
getAttachmentData
Description copied from interface:AttachmentManager
Retrieve the data for attachment- Specified by:
getAttachmentData
in interfaceAttachmentManager
- Parameters:
attachment
- the Attachment the data belongs to- Returns:
- InputStream representing the data
-
getAttachmentData
Description copied from interface:AttachmentManager
Retrieve the specified range of data for attachment- Specified by:
getAttachmentData
in interfaceAttachmentManager
- Parameters:
attachment
- the Attachment the data belongs torange
- the range of data to retrieve. Seecom.atlassian.filestore.client.api.entity.ByteRanges
- Returns:
- InputStream representing the data
-
removeAttachmentWithoutNotifications
Description copied from interface:AttachmentManager
Removes an Attachment and its data from the server while suppressing notifications. This is useful when you don't want to send notifications when removing the file.- Specified by:
removeAttachmentWithoutNotifications
in interfaceAttachmentManager
-
removeAttachmentFromServer
Description copied from interface:AttachmentManager
Removes an Attachment and its data from the server and data store.- Specified by:
removeAttachmentFromServer
in interfaceAttachmentManager
- Parameters:
attachment
- the Attachment to remove
-
removeAttachmentVersionFromServer
Description copied from interface:AttachmentManager
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.
- Specified by:
removeAttachmentVersionFromServer
in interfaceAttachmentManager
- Parameters:
attachment
- the Attachment to remove
-
removeAttachmentVersionFromServerWithoutNotifications
Description copied from interface:AttachmentManager
Removes the given version of the Attachment and its data from the server and data store while suppressing notifications. This is useful when you don't want to send notifications when removing the file.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.
- Specified by:
removeAttachmentVersionFromServerWithoutNotifications
in interfaceAttachmentManager
- Parameters:
attachment
- the Attachment to remove
-
saveAttachment
public void saveAttachment(Attachment attachment, Attachment previousVersion, InputStream attachmentData, SaveContext saveContext) throws IOException Description copied from interface:AttachmentManager
Saves an Attachment and its data, taking aSaveContext
to allow more useful event handling.- Specified by:
saveAttachment
in interfaceAttachmentManager
- Parameters:
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 save- Throws:
IOException
-
saveAttachment
public void saveAttachment(Attachment attachment, Attachment previousVersion, InputStream attachmentData) throws IOException Description copied from interface:AttachmentManager
Saves an Attachment and its data- Specified by:
saveAttachment
in interfaceAttachmentManager
- Parameters:
attachment
- the modified version of the AttachmentpreviousVersion
- the original version of the Attachment (null if new)attachmentData
- an InputStream representing the data of the Attachment- Throws:
IOException
-
saveAttachments
public void saveAttachments(List<SavableAttachment> savableAttachments, SaveContext saveContext) throws IOException Description copied from interface:AttachmentManager
Saves multiple attachment and their data- Specified by:
saveAttachments
in interfaceAttachmentManager
- Parameters:
savableAttachments
- the modified version of the AttachmentsaveContext
- provides more details about saving. If in doubt passDefaultSaveContext.DEFAULT
.- Throws:
IOException
-
saveAttachments
Description copied from interface:AttachmentManager
Saves multiple attachment and their data- Specified by:
saveAttachments
in interfaceAttachmentManager
- Parameters:
savableAttachments
- the modified version of the Attachment- Throws:
IOException
-
setAttachmentData
public void setAttachmentData(Attachment attachment, InputStream attachmentData) throws AttachmentDataExistsException Description copied from interface:AttachmentManager
Set the data belonging to attachmentThis method can be used when there is missing data for an Attachment (e.g. during imports) and the data needs to be set manually.
- Specified by:
setAttachmentData
in interfaceAttachmentManager
- Parameters:
attachment
- Attachment the data belongs toattachmentData
- the data to be saved- Throws:
AttachmentDataExistsException
- if data for attachment already exists
-
moveAttachment
- Specified by:
moveAttachment
in interfaceAttachmentManager
- Parameters:
attachment
- The attachment to be movednewFileName
- New name of the filenewName
- The new contentEntiityObject which will be parent to the attachment
-
moveAttachment
Description copied from interface:AttachmentManagerInternal
Moves an attachment to a differentContentEntityObject
container.- Specified by:
moveAttachment
in interfaceAttachmentManagerInternal
- Parameters:
attachment
- The attachment to be movednewContainer
- The new ContentEntiityObject which will be parent to the attachment
-
copyAttachments
public void copyAttachments(ContentEntityObject sourceContent, ContentEntityObject destinationContent, SaveContext saveContext) throws IOException Description copied from interface:AttachmentManager
Copy the latest version of all the attachments on the sourceContent to the destinationContent.- Specified by:
copyAttachments
in interfaceAttachmentManager
- Parameters:
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.- Throws:
IOException
- if there are problems reading or writing attachment data during the copy.
-
copyAttachments
public void copyAttachments(ContentEntityObject sourceContent, ContentEntityObject destinationContent) throws IOException Description copied from interface:AttachmentManager
Copy the latest version of all the attachments on the sourceContent to the destinationContent.- Specified by:
copyAttachments
in interfaceAttachmentManager
- Parameters:
sourceContent
- the content with attachments to be copied.destinationContent
- the content to copy the attachments to.- Throws:
IOException
- if there are problems reading or writing attachment data during the copy.
-
copyAttachment
public void copyAttachment(Attachment attachment, ContentEntityObject destinationContent) throws IOException Description copied from interface:AttachmentManager
Copy specified attachment to specified destination content.- Specified by:
copyAttachment
in interfaceAttachmentManager
- Parameters:
attachment
- the attachmentdestinationContent
- the destination- Throws:
IOException
-
getAllVersions
Description copied from interface:AttachmentManager
Get all versions of an attachment, starting with the current version- Specified by:
getAllVersions
in interfaceAttachmentManager
-
getPreviousVersions
Description copied from interface:AttachmentManager
Get all non-current versions of an attachment, not including the current version. (ordered from most recent)- Specified by:
getPreviousVersions
in interfaceAttachmentManager
- Parameters:
attachment
- the attachment to get all non-current versions for.
-
getLastAddedVersionsOf
Description copied from interface:AttachmentManager
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.- Specified by:
getLastAddedVersionsOf
in interfaceAttachmentManager
- Parameters:
attachment
- attachment (must be the latest version)- Returns:
- the last added versions for each user who has added a version of the attachment
-
removeAttachments
Description copied from interface:AttachmentManager
Removes the contents of attachments from the server- Specified by:
removeAttachments
in interfaceAttachmentManager
- Parameters:
attachments
- a List of Attachments- See Also:
-
getCopier
Description copied from interface:AttachmentManagerInternal
Retrieves a AttachmentDao.AttachmentCopier that will allow the attachments from one data store to be copied across to another.- Specified by:
getCopier
in interfaceAttachmentManagerInternal
- Parameters:
destination
- the AttachmentManager the data is being copied to- Returns:
- an AttachmentCopier object
-
getAttachmentDao
Description copied from interface:AttachmentManagerInternal
Provides a back door to the underlyingAttachmentDao
. Obviously it's better access the DAO directly, so this is deprecated.- Specified by:
getAttachmentDao
in interfaceAttachmentManagerInternal
-
setSettingsManager
-
setDefaultAttachmentManager
-
setDatabaseAttachmentManager
-
getBackingStorageType
Description copied from interface:AttachmentManager
Returns the currently active storage type.- Specified by:
getBackingStorageType
in interfaceAttachmentManager
- See Also:
-
findAttachmentForDownloadPath
Description copied from interface:AttachmentManager
Find anAttachment
for the givendownloadPath
.The path must at least contain the segment produced by
Attachment.getDownloadPath()
, that is /download/attachments/<contentId>/<fileName> where <contentId> identifies a validContentEntityObject
and <fileName> identifies a validAttachment
attached to thatContentEntityObject
.- Specified by:
findAttachmentForDownloadPath
in interfaceAttachmentManager
- Parameters:
downloadPath
- the download path identifying anAttachment
.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
- See Also:
-
getRemappedAttachmentIds
Description copied from interface:AttachmentManager
Gets a list of remapped attachment IDs. The key is the old ID and the value is the new ID.- Specified by:
getRemappedAttachmentIds
in interfaceAttachmentManager
- Returns:
- A map where the key is the original ID and the value is the new ID.
-
trash
Description copied from interface:AttachmentManager
Moves an attachment to the trash.- Specified by:
trash
in interfaceAttachmentManager
- Parameters:
attachment
- the attachment to be trashed
-
restore
Description copied from interface:AttachmentManager
Restores an attachment from trash.- Specified by:
restore
in interfaceAttachmentManager
- Parameters:
attachment
- the attachment to restore
-