Class ReadThroughCachingAttachmentDao
- All Implemented Interfaces:
AttachmentDaoInternal
,DelegatingAttachmentDao
,AttachmentDao
,FlushableCachingDao
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 TypeMethodDescriptionvoid
flush()
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.void
moveAttachment
(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Moves an Attachment to a new file name or content objectremoveAllVersionsFromServer
(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 versionMethods 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: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
- Overrides:
getLatestAttachment
in 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:AttachmentDao
Removes attachment (and all of its versions)- Specified by:
removeAttachmentFromServer
in interfaceAttachmentDao
- Overrides:
removeAttachmentFromServer
in classAbstractDelegatingAttachmentDao
- Parameters:
attachment
- the Attachment to be removed
-
removeAllVersionsFromServer
Description copied from interface:AttachmentDaoInternal
Removes all versions of an attachment- Specified by:
removeAllVersionsFromServer
in interfaceAttachmentDaoInternal
- Overrides:
removeAllVersionsFromServer
in classAbstractDelegatingAttachmentDao
- 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
- Overrides:
removeAttachmentVersionFromServer
in classAbstractDelegatingAttachmentDao
- Parameters:
attachment
- the Attachment version to be removed
-
flush
public void flush()Description copied from interface:FlushableCachingDao
Flush the caches managed by this DAO.- Specified by:
flush
in interfaceFlushableCachingDao
-
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
- Overrides:
moveAttachment
in classAbstractDelegatingAttachmentDao
- Parameters:
attachment
- the Attachment to be movedoldAttachment
- the Attachment before it has been updatednewContent
- the new content attachment belongs to
-