Class ReadThroughCachingAttachmentDao
java.lang.Object
com.atlassian.confluence.pages.attachments.AbstractDelegatingAttachmentDao
com.atlassian.confluence.impl.pages.attachments.ReadThroughCachingAttachmentDao
- All Implemented Interfaces:
AttachmentDaoInternal,DelegatingAttachmentDao,AttachmentDao,FlushableCachingDao
public class ReadThroughCachingAttachmentDao
extends AbstractDelegatingAttachmentDao
implements FlushableCachingDao
Caches the IDs of attachments retrieved with
getLatestAttachment(ContentEntityObject, String)
in a cache. Other methods simply delegate to the underlying DAO.
Because the persistent ID of the latest version of an attachment never changes, there's no need to synchronise the cache when an attachment is modified. However, the cache is updated when attachments are removed through this interface.
If for some reason the cache does get out of sync with the database, the lookup using the cached ID will fail. In this situation, we fall back to using the lookup by content ID + file name.
Will also cache misses.
- 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
ConstructorsConstructorDescriptionReadThroughCachingAttachmentDao(AttachmentDaoInternal delegate, ReadThroughCache<String, Attachment> cache) -
Method Summary
Modifier and TypeMethodDescriptionlongcountLatestVersionsOfAttachmentsBySpaceAndStatuses(Space space, List<ContentStatus> statuses) Returns the number of the latest versions of attachments by their statuses in a spacelongReturns the number of the latest versions of attachments by their statusesvoidflush()Flush the caches managed by this DAO.getLatestAttachment(ContentEntityObject content, String fileName) Return the latest version of the attachment on the specified content with the given filename.voidmoveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Moves an Attachment to a new file name or content objectremoveAllVersionsFromServer(Attachment attachment) Removes all versions of an attachmentvoidremoveAttachmentFromServer(Attachment attachment) Removes attachment (and all of its versions)voidremoveAttachmentVersionFromServer(Attachment attachment) Removes an attachment version@NonNull List<Attachment>scanFilteredAttachments(Space space, List<ContentStatus> statuses, LimitedRequest pageRequest) scanFilteredAttachments(List<ContentStatus> statuses, LimitedRequest pageRequest) Methods inherited from class com.atlassian.confluence.pages.attachments.AbstractDelegatingAttachmentDao
afterMigrationFrom, countLatestVersionsOfAttachments, countLatestVersionsOfAttachmentsOnPageSince, countLatestVersionsOfAttachmentsWithAnyStatus, findAll, findAllVersions, findLatestVersionsIterator, getAttachment, getAttachmentData, getAttachmentData, getAttachmentStatistics, getBackingStorageType, getById, getByIds, getCopier, getDataDao, getDelegate, getLastAddedVersionsOf, getLatestVersionsOfAttachments, getLatestVersionsOfAttachments, getLatestVersionsOfAttachmentsForMultipleCeos, getLatestVersionsOfAttachmentsWithAnyStatus, getLatestVersionsOfAttachmentsWithAnyStatusForContainers, getMigrator, getRemappedAttachmentIds, isAttachmentPresent, prepareForMigrationTo, replaceAttachmentData, saveNewAttachment, saveNewAttachmentVersion, updateAttachment
-
Constructor Details
-
ReadThroughCachingAttachmentDao
public ReadThroughCachingAttachmentDao(AttachmentDaoInternal delegate, ReadThroughCache<String, Attachment> cache)
-
-
Method Details
-
getLatestAttachment
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- Overrides:
getLatestAttachmentin classAbstractDelegatingAttachmentDao- 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.
-
removeAttachmentFromServer
Description copied from interface:AttachmentDaoRemoves attachment (and all of its versions)- Specified by:
removeAttachmentFromServerin interfaceAttachmentDao- Overrides:
removeAttachmentFromServerin classAbstractDelegatingAttachmentDao- Parameters:
attachment- the Attachment to be removed
-
removeAllVersionsFromServer
Description copied from interface:AttachmentDaoInternalRemoves all versions of an attachment- Specified by:
removeAllVersionsFromServerin interfaceAttachmentDaoInternal- Overrides:
removeAllVersionsFromServerin classAbstractDelegatingAttachmentDao- Parameters:
attachment- the Attachment to be removed- Returns:
- all versions that have been removed
-
countLatestVersionsOfAttachmentsByStatuses
Description copied from interface:AttachmentDaoInternalReturns the number of the latest versions of attachments by their statuses- Specified by:
countLatestVersionsOfAttachmentsByStatusesin interfaceAttachmentDaoInternal- Overrides:
countLatestVersionsOfAttachmentsByStatusesin classAbstractDelegatingAttachmentDao- Parameters:
statuses- list of statuses- Returns:
- the count
-
countLatestVersionsOfAttachmentsBySpaceAndStatuses
public long countLatestVersionsOfAttachmentsBySpaceAndStatuses(Space space, List<ContentStatus> statuses) Description copied from interface:AttachmentDaoInternalReturns the number of the latest versions of attachments by their statuses in a space- Specified by:
countLatestVersionsOfAttachmentsBySpaceAndStatusesin interfaceAttachmentDaoInternal- Overrides:
countLatestVersionsOfAttachmentsBySpaceAndStatusesin classAbstractDelegatingAttachmentDao- Parameters:
space- space which the attachments belong tostatuses- list of statuses- Returns:
- the count
-
scanFilteredAttachments
public @NonNull List<Attachment> scanFilteredAttachments(Space space, List<ContentStatus> statuses, LimitedRequest pageRequest) - Specified by:
scanFilteredAttachmentsin interfaceAttachmentDaoInternal- Overrides:
scanFilteredAttachmentsin classAbstractDelegatingAttachmentDao- Parameters:
space- space which the attachments belong tostatuses- list of statusespageRequest- the page being requested- Returns:
- the paginated list of
Attachmententities in the given space
-
scanFilteredAttachments
public List<Attachment> scanFilteredAttachments(List<ContentStatus> statuses, LimitedRequest pageRequest) - Specified by:
scanFilteredAttachmentsin interfaceAttachmentDaoInternal- Overrides:
scanFilteredAttachmentsin classAbstractDelegatingAttachmentDao- Parameters:
statuses- list of statusespageRequest- the page being requested- Returns:
- the paginated list of
Attachmententities in the given space
-
removeAttachmentVersionFromServer
Description copied from interface:AttachmentDaoRemoves an attachment version- Specified by:
removeAttachmentVersionFromServerin interfaceAttachmentDao- Overrides:
removeAttachmentVersionFromServerin classAbstractDelegatingAttachmentDao- Parameters:
attachment- the Attachment version to be removed
-
flush
public void flush()Description copied from interface:FlushableCachingDaoFlush the caches managed by this DAO.- Specified by:
flushin interfaceFlushableCachingDao
-
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- Overrides:
moveAttachmentin classAbstractDelegatingAttachmentDao- Parameters:
attachment- the Attachment to be movedoldAttachment- the Attachment before it has been updatednewContent- the new content attachment belongs to
-