Class AbstractDelegatingAttachmentDao
- java.lang.Object
-
- com.atlassian.confluence.pages.attachments.AbstractDelegatingAttachmentDao
-
- All Implemented Interfaces:
AttachmentDaoInternal,DelegatingAttachmentDao,AttachmentDao
- Direct Known Subclasses:
ReadThroughCachingAttachmentDao
@Internal public abstract class AbstractDelegatingAttachmentDao extends Object implements AttachmentDaoInternal, DelegatingAttachmentDao
AnAttachmentDaoInternalimplementation that just delegates to anotherAttachmentDaoInternal. 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
Constructors Modifier Constructor Description protectedAbstractDelegatingAttachmentDao(AttachmentDaoInternal delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidafterMigrationFrom()Perform any tasks necessary after Attachment data has been moved from this data store to another.intcountLatestVersionsOfAttachments(ContentEntityObject content)intcountLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content, Date since)intcountLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)List<Attachment>findAll()Retrieves the latest versions of all AttachmentsList<Attachment>findAllVersions(Attachment attachment)Iterator<Attachment>findLatestVersionsIterator()Retrieves the latest versions of all Attachments and returns an Iterator to the results.AttachmentgetAttachment(ContentEntityObject content, String fileName, int version)Return the attachment on the specified content with the given filename and version.InputStreamgetAttachmentData(Attachment attachment)Retrieves the InputStream representing the data for attachmentInputStreamgetAttachmentData(Attachment attachment, Optional<RangeRequest> range)Retrieves the InputStream representing the specified range of data for attachmentOptional<AttachmentStatisticsDTO>getAttachmentStatistics()Fetches statistics about attachmentsAttachmentDataStorageTypegetBackingStorageType()Returns the backing storage type.AttachmentgetById(long id)Returns the attachment with the given persistent ID.List<Attachment>getByIds(List<Long> ids)Returns a list of attachments matching the given list of IDs.AttachmentDao.AttachmentCopiergetCopier(AttachmentDao destinationDao)Get a copier object to copy attachments between data storesAttachmentDataDaogetDataDao()AttachmentDaogetDelegate()Returns the attachment DAO which this instance delegates to.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.AttachmentgetLatestAttachment(ContentEntityObject content, String fileName)Return the latest version of the attachment on the specified content with the given filename.List<Attachment>getLatestVersionsOfAttachments(ContentEntityObject ceo)Retrieves the latest versions of all attachments to ceoPageResponse<Attachment>getLatestVersionsOfAttachments(ContentEntityObject ceo, LimitedRequest pageRequest, com.google.common.base.Predicate<? super Attachment> predicate)Deprecated.List<Attachment>getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)Retrieves the latest versions of all attachments for all CEOs providedList<Attachment>getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject ceo)Retrieves the latest versions of all attachments to ceo (including trashed)List<Attachment>getLatestVersionsOfAttachmentsWithAnyStatusForContainers(Iterable<? extends ContentEntityObject> contentEntityObjects)Retrieves the latest versions of all attachments for all CEOs provided (including trashed)AttachmentDao.AttachmentMigratorgetMigrator(AttachmentDao destinationDao)Get a migrator object to migrate attachments between attachment datastores.Map<Long,Long>getRemappedAttachmentIds()Gets a list of remapped attachment IDs.booleanisAttachmentPresent(Attachment attachment)Check that an attachment existsvoidmoveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)Moves an Attachment to a new file name or content objectvoidprepareForMigrationTo()Prepare the data store for a migration from another type of data store.List<Attachment>removeAllVersionsFromServer(Attachment attachment)Removes all versions of an attachmentvoidremoveAttachmentFromServer(Attachment attachment)Removes attachment (and all of its versions)voidremoveAttachmentVersionFromServer(Attachment attachment)Removes an attachment versionvoidreplaceAttachmentData(Attachment attachment, InputStream attachmentData)Sets the attachment data for attachmentvoidsaveNewAttachment(Attachment attachment, InputStream attachmentData)Saves a new attachmentvoidsaveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData)Saves a new version of attachmentvoidupdateAttachment(Attachment attachment)Update an existing attachment without creating a new version-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.internal.pages.persistence.AttachmentDaoInternal
getFilteredLatestVersionsOfAttachments
-
-
-
-
Constructor Detail
-
AbstractDelegatingAttachmentDao
protected AbstractDelegatingAttachmentDao(AttachmentDaoInternal delegate)
-
-
Method Detail
-
getDelegate
public AttachmentDao getDelegate()
Description copied from interface:DelegatingAttachmentDaoReturns the attachment DAO which this instance delegates to.- Specified by:
getDelegatein interfaceDelegatingAttachmentDao
-
getById
public Attachment getById(long id)
Description copied from interface:AttachmentDaoReturns the attachment with the given persistent ID. Returns null if no such attachment exists.- Specified by:
getByIdin 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
public List<Attachment> getByIds(List<Long> ids)
Description copied from interface:AttachmentDaoReturns 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:
getByIdsin 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
public Attachment getLatestAttachment(ContentEntityObject content, String fileName)
Description copied from interface:AttachmentDaoReturn 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:
getLatestAttachmentin 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
public List<Attachment> getLastAddedVersionsOf(Attachment attachment)
Description copied from interface:AttachmentDaoRetrieves 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:
getLastAddedVersionsOfin 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
public void removeAttachmentFromServer(Attachment attachment)
Description copied from interface:AttachmentDaoRemoves attachment (and all of its versions)- Specified by:
removeAttachmentFromServerin interfaceAttachmentDao- Parameters:
attachment- the Attachment to be removed
-
removeAllVersionsFromServer
public List<Attachment> removeAllVersionsFromServer(Attachment attachment)
Description copied from interface:AttachmentDaoInternalRemoves all versions of an attachment- Specified by:
removeAllVersionsFromServerin interfaceAttachmentDaoInternal- Parameters:
attachment- the Attachment to be removed- Returns:
- all versions that have been removed
-
removeAttachmentVersionFromServer
public void removeAttachmentVersionFromServer(Attachment attachment)
Description copied from interface:AttachmentDaoRemoves an attachment version- Specified by:
removeAttachmentVersionFromServerin interfaceAttachmentDao- Parameters:
attachment- the Attachment version to be removed
-
getLatestVersionsOfAttachments
public List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo)
Description copied from interface:AttachmentDaoRetrieves the latest versions of all attachments to ceo- Specified by:
getLatestVersionsOfAttachmentsin interfaceAttachmentDao- Parameters:
ceo- the content to look up attachments- Returns:
- a List of Attachment objects
- See Also:
AttachmentDao.countLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
-
getLatestVersionsOfAttachmentsForMultipleCeos
public List<Attachment> getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)
Description copied from interface:AttachmentDaoRetrieves the latest versions of all attachments for all CEOs provided- Specified by:
getLatestVersionsOfAttachmentsForMultipleCeosin 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:AttachmentDaoInternalRetrieves the latest versions of all attachments for all CEOs provided (including trashed)- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatusForContainersin interfaceAttachmentDaoInternal- Parameters:
contentEntityObjects- CEOs to retrieve attachements for- Returns:
- a List of Attachment objects
-
getLatestVersionsOfAttachmentsWithAnyStatus
public List<Attachment> getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject ceo)
Description copied from interface:AttachmentDaoRetrieves the latest versions of all attachments to ceo (including trashed)- Specified by:
getLatestVersionsOfAttachmentsWithAnyStatusin interfaceAttachmentDao- Parameters:
ceo- the content to look up attachments- Returns:
- a List of Attachment objects
- See Also:
AttachmentDao.countLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
-
getLatestVersionsOfAttachments
@Deprecated public PageResponse<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo, LimitedRequest pageRequest, com.google.common.base.Predicate<? super Attachment> predicate)
Deprecated.Description copied from interface:AttachmentDaoRetrieves a paginated list of the latest version of attachments to the ceo filtered by the predicate- Specified by:
getLatestVersionsOfAttachmentsin interfaceAttachmentDao- Parameters:
ceo- the content to find attachments onpageRequest- the pagination requestpredicate- a predicate to filter the results by- Returns:
- a paginated list of attachments
-
countLatestVersionsOfAttachments
public int countLatestVersionsOfAttachments(ContentEntityObject content)
- Specified by:
countLatestVersionsOfAttachmentsin interfaceAttachmentDao- Parameters:
content- the content object- Returns:
- the number of current attachments on a content object
- See Also:
AttachmentDao.getLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
-
countLatestVersionsOfAttachmentsOnPageSince
public int countLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content, Date since)
- Specified by:
countLatestVersionsOfAttachmentsOnPageSincein 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:
AttachmentDao.getLatestVersionsOfAttachmentsForMultipleCeos(Iterable)
-
countLatestVersionsOfAttachmentsWithAnyStatus
public int countLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
- Specified by:
countLatestVersionsOfAttachmentsWithAnyStatusin interfaceAttachmentDao- Parameters:
content- the content object- Returns:
- the number of current attachments on a content object (including trashed)
-
getAttachmentStatistics
public Optional<AttachmentStatisticsDTO> getAttachmentStatistics()
Description copied from interface:AttachmentDaoFetches statistics about attachments- Specified by:
getAttachmentStatisticsin interfaceAttachmentDao- Returns:
- an AttachmentStatisticsDTO with statistics about attachments such as total and current count
-
findAll
public List<Attachment> findAll()
Description copied from interface:AttachmentDaoRetrieves the latest versions of all AttachmentsUse of this method is discouraged when there are a large amount of Attachments.
- Specified by:
findAllin interfaceAttachmentDao- Returns:
- A List of Attachment objects
- See Also:
AttachmentDao.findLatestVersionsIterator()
-
findLatestVersionsIterator
public Iterator<Attachment> findLatestVersionsIterator()
Description copied from interface:AttachmentDaoRetrieves the latest versions of all Attachments and returns an Iterator to the results.- Specified by:
findLatestVersionsIteratorin interfaceAttachmentDao- Returns:
- Iterator to the results
-
getAttachmentData
public InputStream getAttachmentData(Attachment attachment) throws AttachmentDataNotFoundException
Description copied from interface:AttachmentDaoRetrieves the InputStream representing the data for attachment- Specified by:
getAttachmentDatain 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:AttachmentDaoRetrieves the InputStream representing the specified range of data for attachment- Specified by:
getAttachmentDatain 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
public void saveNewAttachment(Attachment attachment, InputStream attachmentData)
Description copied from interface:AttachmentDaoSaves a new attachment- Specified by:
saveNewAttachmentin 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:AttachmentDaoSaves a new version of attachment- Specified by:
saveNewAttachmentVersionin interfaceAttachmentDao- Parameters:
attachment- the Attachment to be savedpreviousVersion- the previous version of the AttachmentattachmentData- the attachment data to be saved
-
isAttachmentPresent
public boolean isAttachmentPresent(Attachment attachment)
Description copied from interface:AttachmentDaoCheck that an attachment exists- Specified by:
isAttachmentPresentin interfaceAttachmentDao- Parameters:
attachment- the Attachment to be checked
-
moveAttachment
public void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
Description copied from interface:AttachmentDaoMoves 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:
moveAttachmentin interfaceAttachmentDao- Parameters:
attachment- the Attachment to be movedoldAttachment- the Attachment before it has been updatednewContent- the new content attachment belongs to
-
replaceAttachmentData
public void replaceAttachmentData(Attachment attachment, InputStream attachmentData)
Description copied from interface:AttachmentDaoSets the attachment data for attachmentThis method will overwrite any existing data for the attachment version.
- Specified by:
replaceAttachmentDatain interfaceAttachmentDao- Parameters:
attachment- Attachment the data belongs toattachmentData- the data to save
-
getMigrator
public AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
Description copied from interface:AttachmentDaoGet a migrator object to migrate attachments between attachment datastores.To be used when switching datastore implementations
- Specified by:
getMigratorin interfaceAttachmentDao- Parameters:
destinationDao- dao to move attachments to- Returns:
- A migrator
-
getCopier
public AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
Description copied from interface:AttachmentDaoGet a copier object to copy attachments between data storesThe source data store will remain untouched
- Specified by:
getCopierin interfaceAttachmentDao- Parameters:
destinationDao- dao to copy attachments to- Returns:
- A copier
-
prepareForMigrationTo
public void prepareForMigrationTo()
Description copied from interface:AttachmentDaoPrepare 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:
prepareForMigrationToin interfaceAttachmentDao
-
afterMigrationFrom
public void afterMigrationFrom()
Description copied from interface:AttachmentDaoPerform 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:
afterMigrationFromin interfaceAttachmentDao
-
findAllVersions
public List<Attachment> findAllVersions(Attachment attachment)
- Specified by:
findAllVersionsin interfaceAttachmentDao
-
getAttachment
public Attachment getAttachment(ContentEntityObject content, String fileName, int version)
Description copied from interface:AttachmentDaoReturn 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:
getAttachmentin 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
public AttachmentDataStorageType getBackingStorageType()
Description copied from interface:AttachmentDaoReturns the backing storage type.- Specified by:
getBackingStorageTypein interfaceAttachmentDao- Returns:
- the backing storage type
- See Also:
AttachmentDataDao.getStorageType()
-
updateAttachment
public void updateAttachment(Attachment attachment)
Description copied from interface:AttachmentDaoUpdate an existing attachment without creating a new version- Specified by:
updateAttachmentin interfaceAttachmentDao
-
getRemappedAttachmentIds
public Map<Long,Long> getRemappedAttachmentIds()
Description copied from interface:AttachmentDaoGets a list of remapped attachment IDs. The key is the old ID and the value is the new ID.- Specified by:
getRemappedAttachmentIdsin interfaceAttachmentDao- Returns:
- A map where the key is the original ID and the value is the new ID.
-
getDataDao
public AttachmentDataDao getDataDao()
- Specified by:
getDataDaoin interfaceAttachmentDao
-
-