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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
In 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.boolean
isAttachmentPresent
(Attachment attachment) Check that an attachment existsvoid
moveAttachment
(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Moves an attachment to a new file name or content objectvoid
moveDataForAttachmentVersion
(Attachment sourceAttachmentVersion, Attachment targetAttachmentVersion) Moves the attachment data from oneAbstractVersionedEntityObject.getVersion()
to the other.void
Prepare the data store for a migration from another type of data store.void
removeDataForAttachment
(Attachment attachment, ContentEntityObject originalContent) Removes all attachment data for the given attachment.void
removeDataForAttachmentVersion
(Attachment attachment, ContentEntityObject originalContent) Removes the attachment data for the given attachment version.void
removeDataForAttachmentVersion
(Attachment attachment, ContentEntityObject originalContent, AttachmentDataStreamType dataStreamType) Removes the attachment data of the specific stream type for the given attachment version.void
replaceDataForAttachment
(Attachment attachment, AttachmentDataStream dataStream) Sets the data for attachmentvoid
replaceDataForAttachment
(Attachment attachment, InputStream data) Sets the data for attachmentvoid
saveDataForAttachment
(Attachment attachment, AttachmentDataStream dataStream) Saves data to the attachment data storevoid
saveDataForAttachment
(Attachment attachment, InputStream data) Saves data to the attachment data storevoid
saveDataForAttachmentVersion
(Attachment attachment, Attachment previousVersion, AttachmentDataStream dataStream) Saves data to the attachment data store, for an attachment that has been updated.void
saveDataForAttachmentVersion
(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:
getDataForAttachment
in 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:AttachmentDataDao
Grabs the AttachmentData object for an Attachment- Specified by:
getDataForAttachment
in 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:AttachmentDataDao
Grabs the AttachmentData object for an Attachment- Specified by:
getDataForAttachment
in 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:
removeDataForAttachment
in 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:
removeDataForAttachmentVersion
in 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:AttachmentDataDao
Removes the attachment data of the specific stream type for the given attachment version.- Specified by:
removeDataForAttachmentVersion
in 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:
moveDataForAttachmentVersion
in interfaceAttachmentDataDao
- Parameters:
sourceAttachmentVersion
- the attachment- See Also:
-
saveDataForAttachment
Saves data to the attachment data store- Specified by:
saveDataForAttachment
in interfaceAttachmentDataDao
- Parameters:
attachment
- the Attachment the data belongs todata
- the InputStream to be written
-
saveDataForAttachment
Description copied from interface:AttachmentDataDao
Saves data to the attachment data store- Specified by:
saveDataForAttachment
in 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:
saveDataForAttachmentVersion
in 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:AttachmentDataDao
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:
saveDataForAttachmentVersion
in 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:
replaceDataForAttachment
in interfaceAttachmentDataDao
- Parameters:
attachment
- Attachment the data belongs todata
- the data to be saved
-
replaceDataForAttachment
Description copied from interface:AttachmentDataDao
Sets the data for attachmentThis method will overwrite any existing data for the attachment.
- Specified by:
replaceDataForAttachment
in interfaceAttachmentDataDao
- Parameters:
attachment
- Attachment the data belongs todataStream
- the data to be saved
-
isAttachmentPresent
Description copied from interface:AttachmentDataDao
Check that an attachment exists- Specified by:
isAttachmentPresent
in interfaceAttachmentDataDao
- Parameters:
attachment
- the Attachment to be checked
-
moveAttachment
public void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent) Description copied from interface:AttachmentDataDao
Moves an attachment to a new file name or content object- Specified by:
moveAttachment
in 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:AttachmentDataDao
Prepare 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:
prepareForMigrationTo
in 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:
afterMigrationFrom
in interfaceAttachmentDataDao
-
getStorageType
Description copied from interface:AttachmentDataDao
Returns 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:
getStorageType
in interfaceAttachmentDataDao
- Returns:
- the storage type
-