Class ObjectStorageAttachmentDataFileSystem
- java.lang.Object
 - 
- com.atlassian.confluence.impl.pages.attachments.objectstorage.ObjectStorageAttachmentDataFileSystem
 
 
- 
- All Implemented Interfaces:
 AttachmentDataFileSystem
public class ObjectStorageAttachmentDataFileSystem extends Object implements AttachmentDataFileSystem
An implementation ofAttachmentDataFileSystemwhich stores the attachment data in an object storage service (for example AWS S3), using theFileStore.PathAPI.The files are stored within a hierarchical prefix structure that incorporates an attachment IDs to which the attachment data belongs to. Data corresponding to each version of the attachment are stored, as are different "streams" of data for each version (see
AttachmentDataStreamType).The prefix structure is described by the following pattern: "h1/h2/attachmentId/attachmentFile"
where h1, h2 are hashcodes generated from the attachment id and attachmentFile represents a combination of the attachment id, version and the data stream type. Attachments
AttachmentDataStreamType.RAW_BINARYformat has a filename that consists of the attachment id and the version separated by a dot (eg. "123456.1").- Since:
 - 8.1.0
 
 
- 
- 
Constructor Summary
Constructors Constructor Description ObjectStorageAttachmentDataFileSystem(com.atlassian.dc.filestore.api.FileStore.Path rootDir) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleandataExistsForAttachment(AttachmentRef attachment)Check if attachment data existsvoiddeleteAllAttachmentVersions(AttachmentRef attachment, AttachmentRef.Container contentEntity)Delete all versions for a particular attachmentvoiddeleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container contentEntity)Delete the data corresponding to a single attachment versionvoiddeleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container contentEntity, AttachmentDataStreamType dataStreamType)Delete an attachment version for a particular attachmentAttachmentDataStreamgetAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType)Fetches the data for a given attachment version and data stream typeAttachmentDataStreamgetAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType, Optional<RangeRequest> range)Fetches the specified range of data for a given attachment version and data stream typeAttachmentDataFile<com.atlassian.dc.filestore.api.compat.FilesystemPath>getAttachmentDataFile(long attachmentId, Long containerId, Long spaceId, Integer attachmentVersion, AttachmentDataStreamType dataStreamType)Deprecated.since 8.3.0com.atlassian.dc.filestore.api.FileStore.PathgetRootDir()voidmoveAttachment(AttachmentRef oldAttachment, AttachmentRef newAttachment, AttachmentRef.Container newContent)Deprecated.since 8.1.0, not needed in v004 storagevoidmoveAttachments(AttachmentRef.Container contentEntity, AttachmentRef.Space oldSpace, AttachmentRef.Space newSpace)Deprecated.since 8.1.0, not needed in v004 storage because we do not move files in v004 storagevoidmoveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)Deprecated.since 8.1.0, not needed in v004 storagevoidprepareForMigrationTo()Deprecated.since 8.1.0, not needed in v004 storage because no action needed for v004 migrationbooleansaveAttachmentData(AttachmentRef attachment, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)Save attachment to S3 object storage 
 - 
 
- 
- 
Method Detail
- 
getRootDir
public com.atlassian.dc.filestore.api.FileStore.Path getRootDir()
 
- 
dataExistsForAttachment
public boolean dataExistsForAttachment(AttachmentRef attachment)
Check if attachment data exists- Specified by:
 dataExistsForAttachmentin interfaceAttachmentDataFileSystem- Parameters:
 attachment- reference to the attachment- Returns:
 - true if the attachment data is available
 
 
- 
saveAttachmentData
public boolean saveAttachmentData(AttachmentRef attachment, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)
Save attachment to S3 object storage- Specified by:
 saveAttachmentDatain interfaceAttachmentDataFileSystem- Parameters:
 attachment- reference to the attachment to be storedattachmentDataStream- source stream with attachment dataoverwrite- overwrite attachmentexpectedFileSize- expected file size to be written. Used only for RAW_BINARY stream- Returns:
 - true if the attachment was saved successfully
 
 
- 
deleteAllAttachmentVersions
public void deleteAllAttachmentVersions(AttachmentRef attachment, AttachmentRef.Container contentEntity)
Delete all versions for a particular attachment- Specified by:
 deleteAllAttachmentVersionsin interfaceAttachmentDataFileSystem- Parameters:
 attachment- the attachment for which data should be removedcontentEntity- The content entity associated with the attachment
 
- 
deleteSingleAttachmentVersion
public void deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container contentEntity)
Description copied from interface:AttachmentDataFileSystemDelete the data corresponding to a single attachment version- Specified by:
 deleteSingleAttachmentVersionin interfaceAttachmentDataFileSystem- Parameters:
 attachment- The attachment whose data should be deletedcontentEntity- The content entity associated with the attachment
 
- 
deleteSingleAttachmentVersion
public void deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container contentEntity, AttachmentDataStreamType dataStreamType)
Delete an attachment version for a particular attachment- Specified by:
 deleteSingleAttachmentVersionin interfaceAttachmentDataFileSystem- Parameters:
 attachment- the attachment from which the version should be deletedcontentEntity- The content entity associated with the attachmentdataStreamType- The attachment stream type
 
- 
getAttachmentData
public AttachmentDataStream getAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType)
Description copied from interface:AttachmentDataFileSystemFetches the data for a given attachment version and data stream type- Specified by:
 getAttachmentDatain interfaceAttachmentDataFileSystem- Parameters:
 attachment- The attachment version for which the data is to be fetcheddataStreamType- The type of the data stream to be fetched- Returns:
 - The 
AttachmentDataStreamcontaining the result 
 
- 
getAttachmentData
public AttachmentDataStream getAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType, Optional<RangeRequest> range)
Description copied from interface:AttachmentDataFileSystemFetches the specified range of data for a given attachment version and data stream type- Specified by:
 getAttachmentDatain interfaceAttachmentDataFileSystem- Parameters:
 attachment- The attachment version for which the data is to be fetcheddataStreamType- The type of the data stream to be fetchedrange- The range of the data stream to be fetched- Returns:
 - The 
AttachmentDataStreamcontaining the result 
 
- 
getAttachmentDataFile
@Deprecated(since="8.3.0") public AttachmentDataFile<com.atlassian.dc.filestore.api.compat.FilesystemPath> getAttachmentDataFile(long attachmentId, @Nullable Long containerId, @Nullable Long spaceId, Integer attachmentVersion, AttachmentDataStreamType dataStreamType)
Deprecated.since 8.3.0This method won't support S3 attachment storage. Use at your own risk.- Specified by:
 getAttachmentDataFilein interfaceAttachmentDataFileSystem
 
- 
prepareForMigrationTo
@Deprecated public void prepareForMigrationTo()
Deprecated.since 8.1.0, not needed in v004 storage because no action needed for v004 migrationDescription copied from interface:AttachmentDataFileSystemPrepare the data store for a migration from another type of data store.- Specified by:
 prepareForMigrationToin interfaceAttachmentDataFileSystem
 
- 
moveDataForAttachmentVersion
@Deprecated public void moveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)
Deprecated.since 8.1.0, not needed in v004 storageDescription copied from interface:AttachmentDataFileSystemMove the data associated with one attachment version, to being associated with a different attachment version- Specified by:
 moveDataForAttachmentVersionin interfaceAttachmentDataFileSystem- Parameters:
 sourceAttachmentVersion- The attachment version containing the datatargetAttachmentVersion- The attachment version to which the data should be moved
 
- 
moveAttachment
@Deprecated public void moveAttachment(AttachmentRef oldAttachment, AttachmentRef newAttachment, AttachmentRef.Container newContent)
Deprecated.since 8.1.0, not needed in v004 storageDescription copied from interface:AttachmentDataFileSystemMove all data relating to one attachment to a new directory corresponding to the given new attachment and content entity.- Specified by:
 moveAttachmentin interfaceAttachmentDataFileSystem- Parameters:
 oldAttachment- The attachment whose data is to be movednewAttachment- The attachment to which the data should be moved tonewContent- The content entity corresponding to the new attachment
 
- 
moveAttachments
@Deprecated public void moveAttachments(AttachmentRef.Container contentEntity, AttachmentRef.Space oldSpace, AttachmentRef.Space newSpace)
Deprecated.since 8.1.0, not needed in v004 storage because we do not move files in v004 storageDescription copied from interface:AttachmentDataFileSystemMove all data for all versions of all attachments corresponding to the given content entity in the given space, to the same entity in a different space.- Specified by:
 moveAttachmentsin interfaceAttachmentDataFileSystem- Parameters:
 contentEntity- The content entity whose attachment data is to be movedoldSpace- The original space of the content entitynewSpace- The new space of the content entity
 
 - 
 
 -