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 withgetLatestAttachment(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
Constructors Constructor Description ReadThroughCachingAttachmentDao(AttachmentDaoInternal delegate, ReadThroughCache<String,Attachment> cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
Flush the caches managed by this DAO.Attachment
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 objectList<Attachment>
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 version-
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
-
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.pages.persistence.dao.AttachmentDao
getLatestVersionsOfAttachments
-
Methods inherited from interface com.atlassian.confluence.internal.pages.persistence.AttachmentDaoInternal
getFilteredLatestVersionsOfAttachments
-
-
-
-
Constructor Detail
-
ReadThroughCachingAttachmentDao
public ReadThroughCachingAttachmentDao(AttachmentDaoInternal delegate, ReadThroughCache<String,Attachment> cache)
-
-
Method Detail
-
getLatestAttachment
public Attachment getLatestAttachment(ContentEntityObject content, String fileName)
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
public void removeAttachmentFromServer(Attachment attachment)
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
public List<Attachment> removeAllVersionsFromServer(Attachment attachment)
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
public void removeAttachmentVersionFromServer(Attachment attachment)
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
-
-