Class FileSystemAttachmentDataDao
- All Implemented Interfaces:
AttachmentDataDao,NonTransactionalAttachmentDataDao
AttachmentDataDao which stores the
attachment data as files on local filesystem, using the standard File API
or as blob on remote filesystem, using com.atlassian.filestore.client.api.FileStoreClient API
via the AttachmentDataFileSystem interface.- Since:
- 7.12
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIn this implementation, we leave the filesystem as is, and don't remove the attachments that have just been moved to another data store.getDataForAttachment(Attachment attachment) Grabs the AttachmentData object for an AttachmentgetDataForAttachment(Attachment attachment, AttachmentDataStreamType dataStreamType) Grabs the AttachmentData object for an AttachmentgetDataForAttachment(Attachment attachment, AttachmentDataStreamType dataStreamType, Optional<RangeRequest> range) Grabs the AttachmentData object for an AttachmentReturns the storage type.booleanisAttachmentPresent(Attachment attachment) Check that an attachment existsvoidmoveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Moves an attachment to a new file name or content objectvoidmoveDataForAttachmentVersion(Attachment sourceAttachmentVersion, Attachment targetAttachmentVersion) Moves the attachment data from oneAbstractVersionedEntityObject.getVersion()to the other.voidPrepare the data store for a migration from another type of data store.voidremoveDataForAttachment(Attachment attachment, ContentEntityObject originalContent) Removes all attachment data for the given attachment.voidremoveDataForAttachmentVersion(Attachment attachment, ContentEntityObject originalContent) Removes the attachment data for the given attachment version.voidremoveDataForAttachmentVersion(Attachment attachment, ContentEntityObject originalContent, AttachmentDataStreamType dataStreamType) Removes the attachment data of the specific stream type for the given attachment version.voidreplaceDataForAttachment(Attachment attachment, AttachmentDataStream dataStream) Sets the data for attachmentvoidreplaceDataForAttachment(Attachment attachment, InputStream data) Sets the data for attachmentvoidsaveDataForAttachment(Attachment attachment, AttachmentDataStream dataStream) Saves data to the attachment data storevoidsaveDataForAttachment(Attachment attachment, InputStream data) Saves data to the attachment data storevoidsaveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, AttachmentDataStream dataStream) Saves data to the attachment data store, for an attachment that has been updated.voidsaveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream data) Saves data to the attachment data store, for an attachment that has been updated.
-
Constructor Details
-
FileSystemAttachmentDataDao
-
-
Method Details
-
getDataForAttachment
public InputStream getDataForAttachment(Attachment attachment) throws AttachmentDataNotFoundException Grabs the AttachmentData object for an Attachment- Specified by:
getDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment representing the data- Returns:
- an AttachmentData object
- Throws:
AttachmentDataNotFoundException- if no data was found
-
getDataForAttachment
public AttachmentDataStream getDataForAttachment(Attachment attachment, AttachmentDataStreamType dataStreamType) throws AttachmentDataNotFoundException Description copied from interface:AttachmentDataDaoGrabs the AttachmentData object for an Attachment- Specified by:
getDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment representing the data- Returns:
- an AttachmentData object
- Throws:
AttachmentDataNotFoundException- if no data was found
-
getDataForAttachment
public AttachmentDataStream getDataForAttachment(Attachment attachment, AttachmentDataStreamType dataStreamType, Optional<RangeRequest> range) throws AttachmentDataNotFoundException Description copied from interface:AttachmentDataDaoGrabs the AttachmentData object for an Attachment- Specified by:
getDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment representing the datadataStreamType- the stream type of attachmentrange- the range of attachment data- Returns:
- an AttachmentData object
- Throws:
AttachmentDataNotFoundException- if no data was found
-
removeDataForAttachment
Removes all attachment data for the given attachment. Since Confluence 4.2 the contract of this method has been clarified. It now removes all versions of the given attachment.- Specified by:
removeDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the latest version of the attachment for which the data should be removedoriginalContent- the content the attachment belongs to
-
removeDataForAttachmentVersion
public void removeDataForAttachmentVersion(Attachment attachment, ContentEntityObject originalContent) Removes the attachment data for the given attachment version.- Specified by:
removeDataForAttachmentVersionin interfaceAttachmentDataDao- Parameters:
attachment- the version of the attachment for which the data should be removedoriginalContent- the content the attachment belongs to
-
removeDataForAttachmentVersion
public void removeDataForAttachmentVersion(Attachment attachment, ContentEntityObject originalContent, AttachmentDataStreamType dataStreamType) Description copied from interface:AttachmentDataDaoRemoves the attachment data of the specific stream type for the given attachment version.- Specified by:
removeDataForAttachmentVersionin interfaceAttachmentDataDao- Parameters:
attachment- the version of the attachment for which the data should be removedoriginalContent- the content the attachment belongs todataStreamType- the data stream type
-
moveDataForAttachmentVersion
public void moveDataForAttachmentVersion(Attachment sourceAttachmentVersion, Attachment targetAttachmentVersion) Moves the attachment data from oneAbstractVersionedEntityObject.getVersion()to the other.This method will overwrite any existing data for the target attachment version.
- Specified by:
moveDataForAttachmentVersionin interfaceAttachmentDataDao- Parameters:
sourceAttachmentVersion- the attachment- See Also:
-
saveDataForAttachment
Saves data to the attachment data store- Specified by:
saveDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment the data belongs todata- the InputStream to be written
-
saveDataForAttachment
Description copied from interface:AttachmentDataDaoSaves data to the attachment data store- Specified by:
saveDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment the data belongs todataStream- the data stream to be written
-
saveDataForAttachmentVersion
public void saveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream data) Saves data to the attachment data store, for an attachment that has been updated.This method assumes that the attachment has already been saved.
- Specified by:
saveDataForAttachmentVersionin interfaceAttachmentDataDao- Parameters:
attachment- the new version of the attachmentpreviousVersion- the previous version of the attachmentdata- the InputStream representing the data
-
saveDataForAttachmentVersion
public void saveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, AttachmentDataStream dataStream) Description copied from interface:AttachmentDataDaoSaves data to the attachment data store, for an attachment that has been updated.This method assumes that the attachment has already been saved.
- Specified by:
saveDataForAttachmentVersionin interfaceAttachmentDataDao- Parameters:
attachment- the new version of the attachmentpreviousVersion- the previous version of the attachmentdataStream- the InputStream representing the data
-
replaceDataForAttachment
Sets the data for attachmentThis method will overwrite any existing data for the attachment.
- Specified by:
replaceDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- Attachment the data belongs todata- the data to be saved
-
replaceDataForAttachment
Description copied from interface:AttachmentDataDaoSets the data for attachmentThis method will overwrite any existing data for the attachment.
- Specified by:
replaceDataForAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- Attachment the data belongs todataStream- the data to be saved
-
isAttachmentPresent
Description copied from interface:AttachmentDataDaoCheck that an attachment exists- Specified by:
isAttachmentPresentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment to be checked
-
moveAttachment
public void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Description copied from interface:AttachmentDataDaoMoves an attachment to a new file name or content object- Specified by:
moveAttachmentin interfaceAttachmentDataDao- Parameters:
attachment- the Attachment to be movedoldAttachment- the original version of the attachmentnewContent- the new content the Attachment belongs to
-
prepareForMigrationTo
public void prepareForMigrationTo()Description copied from interface:AttachmentDataDaoPrepare 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.
Implementations may circumvent hibernate, so should only be called when nobody else can see the attachment data.
- Specified by:
prepareForMigrationToin interfaceAttachmentDataDao
-
afterMigrationFrom
public void afterMigrationFrom()In this implementation, we leave the filesystem as is, and don't remove the attachments that have just been moved to another data store.- Specified by:
afterMigrationFromin interfaceAttachmentDataDao
-
getStorageType
Description copied from interface:AttachmentDataDaoReturns the storage type.The client code should be storage agnostic in general. Thus this method should only be used in rare cases in order to hide operations which are known to be not implemented for the specific type.
- Specified by:
getStorageTypein interfaceAttachmentDataDao- Returns:
- the storage type
-