Class AbstractDelegatingAttachmentDao
- All Implemented Interfaces:
AttachmentDaoInternal
,DelegatingAttachmentDao
,AttachmentDao
- Direct Known Subclasses:
ReadThroughCachingAttachmentDao
AttachmentDaoInternal
implementation that just delegates to another AttachmentDaoInternal
.
This is intended for subclassing to add specific behaviour.- Since:
- 7.5
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.confluence.pages.persistence.dao.AttachmentDao
AttachmentDao.AttachmentCopier, AttachmentDao.AttachmentMigrator
-
Constructor Summary
ModifierConstructorDescriptionprotected
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform any tasks necessary after Attachment data has been moved from this data store to another.int
int
countLatestVersionsOfAttachmentsOnPageSince
(ContentEntityObject content, Date since) int
findAll()
Retrieves the latest versions of all AttachmentsfindAllVersions
(Attachment attachment) Returns an iterator for the latest versions of the current persistent class.getAttachment
(ContentEntityObject content, String fileName, int version) Return the attachment on the specified content with the given filename and version.getAttachmentData
(Attachment attachment) Retrieves the InputStream representing the data for attachmentgetAttachmentData
(Attachment attachment, Optional<RangeRequest> range) Retrieves the InputStream representing the specified range of data for attachmentFetches statistics about attachmentsReturns the backing storage type.getById
(long id) Returns the attachment with the given persistent ID.Returns a list of attachments matching the given list of IDs.getCopier
(AttachmentDao destinationDao) Get a copier object to copy attachments between data storesReturns the attachment DAO which this instance delegates to.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.getLatestAttachment
(ContentEntityObject content, String fileName) Return the latest version of the attachment on the specified content with the given filename.Retrieves the latest versions of all attachments to ceogetLatestVersionsOfAttachments
(ContentEntityObject ceo, LimitedRequest pageRequest) getLatestVersionsOfAttachmentsForMultipleCeos
(Iterable<? extends ContentEntityObject> contentEntityObjects) Retrieves the latest versions of all attachments for all CEOs providedRetrieves the latest versions of all attachments to ceo (including trashed)getLatestVersionsOfAttachmentsWithAnyStatusForContainers
(Iterable<? extends ContentEntityObject> contentEntityObjects) Retrieves the latest versions of all attachments for all CEOs provided (including trashed)getMigrator
(AttachmentDao destinationDao) Get a migrator object to migrate attachments between attachment datastores.Gets a list of remapped attachment IDs.boolean
isAttachmentPresent
(Attachment attachment) Check that an attachment existsvoid
moveAttachment
(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Moves an Attachment to a new file name or content objectvoid
Prepare the data store for a migration from another type of data store.removeAllVersionsFromServer
(Attachment attachment) Removes all versions of an attachmentvoid
removeAttachmentFromServer
(Attachment attachment) Removes attachment (and all of its versions)void
removeAttachmentVersionFromServer
(Attachment attachment) Removes an attachment versionvoid
replaceAttachmentData
(Attachment attachment, InputStream attachmentData) Sets the attachment data for attachmentvoid
saveNewAttachment
(Attachment attachment, InputStream attachmentData) Saves a new attachmentvoid
saveNewAttachmentVersion
(Attachment attachment, Attachment previousVersion, InputStream attachmentData) Saves a new version of attachmentvoid
updateAttachment
(Attachment attachment) Update an existing attachment without creating a new version
-
Constructor Details
-
AbstractDelegatingAttachmentDao
-
-
Method Details
-
getDelegate
Description copied from interface:DelegatingAttachmentDao
Returns the attachment DAO which this instance delegates to.- Specified by:
getDelegate
in interfaceDelegatingAttachmentDao
-
getById
Description copied from interface:AttachmentDao
Returns the attachment with the given persistent ID. Returns null if no such attachment exists.- Specified by:
getById
in interfaceAttachmentDao
- Parameters:
id
- the persistent ID of the attachment to retrieve- Returns:
- the attachment with the given ID, or null if no attachment exists with the provided ID.
-
getByIds
Description copied from interface:AttachmentDao
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:
getByIds
in interfaceAttachmentDao
- Parameters:
ids
- list of IDs to retrieve- Returns:
- the attachments with the given IDs, or an empty list if no attachments exist with the provided IDs.
-
getLatestAttachment
Description copied from interface:AttachmentDao
Return the latest version of the attachment on the specified content with the given filename. Returns null if no attachment with that name on the content exists.- Specified by:
getLatestAttachment
in interfaceAttachmentDao
- Parameters:
content
- the content to find the attachment onfileName
- the file name of the attachment- Returns:
- the latest version of attachment with the given name attached to that content, or null if the attachment does not exist.
-
getLastAddedVersionsOf
Description copied from interface:AttachmentDao
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 interfaceAttachmentDao
- Parameters:
attachment
- attachment (must be the latest version)- Returns:
- the last added versions for each user who has added a version of the attachment
-
removeAttachmentFromServer
Description copied from interface:AttachmentDao
Removes attachment (and all of its versions)- Specified by:
removeAttachmentFromServer
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment to be removed
-
removeAllVersionsFromServer
Description copied from interface:AttachmentDaoInternal
Removes all versions of an attachment- Specified by:
removeAllVersionsFromServer
in interfaceAttachmentDaoInternal
- Parameters:
attachment
- the Attachment to be removed- Returns:
- all versions that have been removed
-
removeAttachmentVersionFromServer
Description copied from interface:AttachmentDao
Removes an attachment version- Specified by:
removeAttachmentVersionFromServer
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment version to be removed
-
getLatestVersionsOfAttachments
Description copied from interface:AttachmentDao
Retrieves the latest versions of all attachments to ceo- Specified by:
getLatestVersionsOfAttachments
in interfaceAttachmentDao
- Parameters:
ceo
- the content to look up attachments- Returns:
- a List of Attachment objects
- See Also:
-
getLatestVersionsOfAttachmentsForMultipleCeos
public List<Attachment> getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects) Description copied from interface:AttachmentDao
Retrieves the latest versions of all attachments for all CEOs provided- Specified by:
getLatestVersionsOfAttachmentsForMultipleCeos
in interfaceAttachmentDao
- Parameters:
contentEntityObjects
- CEOs to retrieve attachements for- Returns:
- a List of Attachment objects
-
getLatestVersionsOfAttachmentsWithAnyStatusForContainers
public List<Attachment> getLatestVersionsOfAttachmentsWithAnyStatusForContainers(Iterable<? extends ContentEntityObject> contentEntityObjects) Description copied from interface:AttachmentDaoInternal
Retrieves the latest versions of all attachments for all CEOs provided (including trashed)- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatusForContainers
in interfaceAttachmentDaoInternal
- Parameters:
contentEntityObjects
- CEOs to retrieve attachements for- Returns:
- a List of Attachment objects
-
getLatestVersionsOfAttachmentsWithAnyStatus
Description copied from interface:AttachmentDao
Retrieves the latest versions of all attachments to ceo (including trashed)- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatus
in interfaceAttachmentDao
- Parameters:
ceo
- the content to look up attachments- Returns:
- a List of Attachment objects
- See Also:
-
getLatestVersionsOfAttachments
public List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo, LimitedRequest pageRequest) - Specified by:
getLatestVersionsOfAttachments
in interfaceAttachmentDao
-
countLatestVersionsOfAttachments
- Specified by:
countLatestVersionsOfAttachments
in interfaceAttachmentDao
- Parameters:
content
- the content object- Returns:
- the number of current attachments on a content object
- See Also:
-
countLatestVersionsOfAttachmentsOnPageSince
- Specified by:
countLatestVersionsOfAttachmentsOnPageSince
in interfaceAttachmentDao
- Parameters:
content
- the content objectsince
- the date of earliest change- Returns:
- the number of attachments on a content object (including trashed) changed since
- See Also:
-
countLatestVersionsOfAttachmentsWithAnyStatus
- Specified by:
countLatestVersionsOfAttachmentsWithAnyStatus
in interfaceAttachmentDao
- Parameters:
content
- the content object- Returns:
- the number of current attachments on a content object (including trashed)
-
getAttachmentStatistics
Description copied from interface:AttachmentDao
Fetches statistics about attachments- Specified by:
getAttachmentStatistics
in interfaceAttachmentDao
- Returns:
- an AttachmentStatisticsDTO with statistics about attachments such as total and current count
-
findAll
Description copied from interface:AttachmentDao
Retrieves the latest versions of all AttachmentsUse of this method is discouraged when there are a large amount of Attachments.
- Specified by:
findAll
in interfaceAttachmentDao
- Returns:
- A List of Attachment objects
- See Also:
-
findLatestVersionsIterator
Description copied from interface:AttachmentDaoInternal
Returns an iterator for the latest versions of the current persistent class.- Specified by:
findLatestVersionsIterator
in interfaceAttachmentDao
- Specified by:
findLatestVersionsIterator
in interfaceAttachmentDaoInternal
- Returns:
- Iterator to the results
-
getAttachmentData
Description copied from interface:AttachmentDao
Retrieves the InputStream representing the data for attachment- Specified by:
getAttachmentData
in interfaceAttachmentDao
- Parameters:
attachment
- the attachment whose data will be returned- Returns:
- InputStream of the data
- Throws:
AttachmentDataNotFoundException
- if the data could not be found
-
getAttachmentData
public InputStream getAttachmentData(Attachment attachment, Optional<RangeRequest> range) throws AttachmentDataNotFoundException Description copied from interface:AttachmentDao
Retrieves the InputStream representing the specified range of data for attachment- Specified by:
getAttachmentData
in interfaceAttachmentDao
- Parameters:
attachment
- the attachment whose data will be returnedrange
- the range of data to retrieve. Seecom.atlassian.filestore.client.api.entity.ByteRanges
- Returns:
- InputStream of the data
- Throws:
AttachmentDataNotFoundException
- if the data could not be found
-
saveNewAttachment
Description copied from interface:AttachmentDao
Saves a new attachment- Specified by:
saveNewAttachment
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment to be savedattachmentData
- the attachment data to be saved
-
saveNewAttachmentVersion
public void saveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData) Description copied from interface:AttachmentDao
Saves a new version of attachment- Specified by:
saveNewAttachmentVersion
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment to be savedpreviousVersion
- the previous version of the AttachmentattachmentData
- the attachment data to be saved
-
isAttachmentPresent
Description copied from interface:AttachmentDao
Check that an attachment exists- Specified by:
isAttachmentPresent
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment to be checked
-
moveAttachment
public void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Description copied from interface:AttachmentDao
Moves an Attachment to a new file name or content objectThis method assumes that the filename and/or content of the attachment (and its previous versions) have already been updated.
- Specified by:
moveAttachment
in interfaceAttachmentDao
- Parameters:
attachment
- the Attachment to be movedoldAttachment
- the Attachment before it has been updatednewContent
- the new content attachment belongs to
-
replaceAttachmentData
Description copied from interface:AttachmentDao
Sets the attachment data for attachmentThis method will overwrite any existing data for the attachment version.
- Specified by:
replaceAttachmentData
in interfaceAttachmentDao
- Parameters:
attachment
- Attachment the data belongs toattachmentData
- the data to save
-
getMigrator
Description copied from interface:AttachmentDao
Get a migrator object to migrate attachments between attachment datastores.To be used when switching datastore implementations
- Specified by:
getMigrator
in interfaceAttachmentDao
- Parameters:
destinationDao
- dao to move attachments to- Returns:
- A migrator
-
getCopier
Description copied from interface:AttachmentDao
Get a copier object to copy attachments between data storesThe source data store will remain untouched
- Specified by:
getCopier
in interfaceAttachmentDao
- Parameters:
destinationDao
- dao to copy attachments to- Returns:
- A copier
-
prepareForMigrationTo
public void prepareForMigrationTo()Description copied from interface:AttachmentDao
Prepare the data store for a migration from another type of data store.Classes implementing this method will perform any tasks necessary to allow the data store to be used. These tasks may assume that users are locked out of the system.
- Specified by:
prepareForMigrationTo
in interfaceAttachmentDao
-
afterMigrationFrom
public void afterMigrationFrom()Description copied from interface:AttachmentDao
Perform any tasks necessary after Attachment data has been moved from this data store to another. These tasks may assume that users are locked out of the system.- Specified by:
afterMigrationFrom
in interfaceAttachmentDao
-
findAllVersions
- Specified by:
findAllVersions
in interfaceAttachmentDao
-
getAttachment
Description copied from interface:AttachmentDao
Return the attachment on the specified content with the given filename and version. Returns null if no such attachment exists.Note: unlike
AttachmentManager.getAttachment(ContentEntityObject, String, int)
, this method does not accept zero as a special flag to indicate the latest version of an attachment. To retrieve the latest version of an attachment, useAttachmentDao.getLatestAttachment(ContentEntityObject, String)
.- Specified by:
getAttachment
in interfaceAttachmentDao
- Parameters:
content
- the content to find the attachment onfileName
- the file name of the attachment, treated case-insensitivelyversion
- the version of the attachment- Returns:
- the attachment with the given name and version attached to that content, or null if the attachment does not exist.
-
getBackingStorageType
Description copied from interface:AttachmentDao
Returns the backing storage type.- Specified by:
getBackingStorageType
in interfaceAttachmentDao
- Returns:
- the backing storage type
- See Also:
-
updateAttachment
Description copied from interface:AttachmentDao
Update an existing attachment without creating a new version- Specified by:
updateAttachment
in interfaceAttachmentDao
-
getRemappedAttachmentIds
Description copied from interface:AttachmentDao
Gets a list of remapped attachment IDs. The key is the old ID and the value is the new ID.- Specified by:
getRemappedAttachmentIds
in interfaceAttachmentDao
- Returns:
- A map where the key is the original ID and the value is the new ID.
-
getDataDao
- Specified by:
getDataDao
in interfaceAttachmentDao
-