Class ContentDirectoryStructureAttachmentDataFileSystemAdapter
- java.lang.Object
-
- com.atlassian.confluence.impl.pages.attachments.filesystem.ContentDirectoryStructureAttachmentDataFileSystemAdapter
-
- All Implemented Interfaces:
AttachmentDataFileSystem
public final class ContentDirectoryStructureAttachmentDataFileSystemAdapter extends Object implements AttachmentDataFileSystem
The purpose of this adapter is to switch between different attachment storage structures implementationsAttachmentDataFileSystem
. The version 003 needs to be supported while the migration to version 004 is in progress. The class prioritises version 004 and if it can't find a file then it will fallback to version 003.- Since:
- 8.1.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ContentDirectoryStructureAttachmentDataFileSystemAdapter
create(ContentDirectoryStructureAttachmentDataFileSystemV003 structureV003, ContentDirectoryStructureAttachmentDataFileSystemV004 structureV004, ZduManager zduManager)
boolean
dataExistsForAttachment(AttachmentRef attachment)
Indicates whether the filesystem contains data for the given attachmentvoid
deleteAllAttachmentVersions(AttachmentRef attachment, AttachmentRef.Container originalContent)
Delete all data corresponding to all versions of the given attachmentvoid
deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container originalContent)
Delete the data corresponding to a single attachment versionvoid
deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container originalContent, AttachmentDataStreamType dataStreamType)
Delete the data of the specified stream type corresponding to a single attachment versionAttachmentDataStream
getAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType)
Fetches the data for a given attachment version and data stream typeAttachmentDataStream
getAttachmentData(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)
This method won't support S3 attachment storage.AttachmentStorageVersion
getStructureVersion()
Version of the attachment storage structure.void
moveAttachment(AttachmentRef oldAttachment, AttachmentRef newAttachment, AttachmentRef.Container newContent)
Deprecated.since 8.1.0void
moveAttachments(AttachmentRef.Container contentEntity, AttachmentRef.Space oldSpace, AttachmentRef.Space newSpace)
Deprecated.since 8.1.0.void
moveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)
Deprecated.since 8.1.0void
prepareForMigrationTo()
Deprecated.since 8.1.0.boolean
saveAttachmentData(AttachmentRef attachmentVersion, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)
Save new data corresponding to the given attachment.
-
-
-
Method Detail
-
create
public static ContentDirectoryStructureAttachmentDataFileSystemAdapter create(ContentDirectoryStructureAttachmentDataFileSystemV003 structureV003, ContentDirectoryStructureAttachmentDataFileSystemV004 structureV004, ZduManager zduManager)
-
dataExistsForAttachment
public boolean dataExistsForAttachment(AttachmentRef attachment)
Description copied from interface:AttachmentDataFileSystem
Indicates whether the filesystem contains data for the given attachment- Specified by:
dataExistsForAttachment
in interfaceAttachmentDataFileSystem
-
moveAttachment
@Deprecated public void moveAttachment(AttachmentRef oldAttachment, AttachmentRef newAttachment, AttachmentRef.Container newContent)
Deprecated.since 8.1.0Description copied from interface:AttachmentDataFileSystem
Move all data relating to one attachment to a new directory corresponding to the given new attachment and content entity.- Specified by:
moveAttachment
in 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
-
saveAttachmentData
public boolean saveAttachmentData(AttachmentRef attachmentVersion, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)
Description copied from interface:AttachmentDataFileSystem
Save new data corresponding to the given attachment.- Specified by:
saveAttachmentData
in interfaceAttachmentDataFileSystem
- Parameters:
attachmentVersion
- The attachment to which the data should be associatedattachmentDataStream
- The new dataoverwrite
- If true, any existing data will be overwritten. If false, does nothing if data already exists.expectedFileSize
- The expected size of the data being written- Returns:
- true if the data was written, false otherwise (e.g. no overwrite)
-
getAttachmentDataFile
public AttachmentDataFile<com.atlassian.dc.filestore.api.compat.FilesystemPath> getAttachmentDataFile(long attachmentId, @Nullable Long containerId, @Nullable Long spaceId, Integer attachmentVersion, AttachmentDataStreamType dataStreamType)
Description copied from interface:AttachmentDataFileSystem
This method won't support S3 attachment storage. Use at your own risk.- Specified by:
getAttachmentDataFile
in interfaceAttachmentDataFileSystem
-
deleteAllAttachmentVersions
public void deleteAllAttachmentVersions(AttachmentRef attachment, AttachmentRef.Container originalContent)
Delete all data corresponding to all versions of the given attachmentThis method will remove any empty folders left after removing the attachment data.
- Specified by:
deleteAllAttachmentVersions
in interfaceAttachmentDataFileSystem
- Parameters:
attachment
- the attachment for which data should be removedoriginalContent
- the content the attachment belongs to
-
moveDataForAttachmentVersion
@Deprecated public void moveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)
Deprecated.since 8.1.0Description copied from interface:AttachmentDataFileSystem
Move the data associated with one attachment version, to being associated with a different attachment version- Specified by:
moveDataForAttachmentVersion
in interfaceAttachmentDataFileSystem
- Parameters:
sourceAttachmentVersion
- The attachment version containing the datatargetAttachmentVersion
- The attachment version to which the data should be moved
-
deleteSingleAttachmentVersion
public void deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container originalContent)
Delete the data corresponding to a single attachment versionThis method will remove all attachment files and any empty folders left after removing the attachment data.
- Specified by:
deleteSingleAttachmentVersion
in interfaceAttachmentDataFileSystem
- Parameters:
attachment
- the attachment for which data should be removedoriginalContent
- the content the attachment belongs to
-
deleteSingleAttachmentVersion
public void deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container originalContent, AttachmentDataStreamType dataStreamType)
Description copied from interface:AttachmentDataFileSystem
Delete the data of the specified stream type corresponding to a single attachment version- Specified by:
deleteSingleAttachmentVersion
in interfaceAttachmentDataFileSystem
- Parameters:
attachment
- The attachment whose data should be deletedoriginalContent
- The content entity associated with the attachmentdataStreamType
- The attachment stream type
-
getAttachmentData
public AttachmentDataStream getAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType)
Description copied from interface:AttachmentDataFileSystem
Fetches the data for a given attachment version and data stream type- Specified by:
getAttachmentData
in 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
AttachmentDataStream
containing the result
-
getAttachmentData
public AttachmentDataStream getAttachmentData(AttachmentRef attachment, AttachmentDataStreamType dataStreamType, Optional<RangeRequest> range)
Description copied from interface:AttachmentDataFileSystem
Fetches the specified range of data for a given attachment version and data stream type- Specified by:
getAttachmentData
in 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
AttachmentDataStream
containing the result
-
moveAttachments
@Deprecated public void moveAttachments(AttachmentRef.Container contentEntity, AttachmentRef.Space oldSpace, AttachmentRef.Space newSpace)
Deprecated.since 8.1.0. Space is no longer a part of the attachment path since storage v004.Description copied from interface:AttachmentDataFileSystem
Move 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:
moveAttachments
in 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
-
prepareForMigrationTo
@Deprecated public void prepareForMigrationTo()
Deprecated.since 8.1.0. Migration DB <-> FS should be already done and is not supported in 8.1.Description copied from interface:AttachmentDataFileSystem
Prepare the data store for a migration from another type of data store.- Specified by:
prepareForMigrationTo
in interfaceAttachmentDataFileSystem
-
getStructureVersion
public AttachmentStorageVersion getStructureVersion()
Description copied from interface:AttachmentDataFileSystem
Version of the attachment storage structure.- Specified by:
getStructureVersion
in interfaceAttachmentDataFileSystem
-
-