Class ContentDirectoryStructureAttachmentDataFileSystemV004
- java.lang.Object
-
- com.atlassian.confluence.impl.pages.attachments.filesystem.ContentDirectoryStructureAttachmentDataFileSystemV004
-
- All Implemented Interfaces:
AttachmentDataFileSystem
,AttachmentDataFileSystemInternals
public class ContentDirectoryStructureAttachmentDataFileSystemV004 extends Object implements AttachmentDataFileSystem, AttachmentDataFileSystemInternals
An implementation ofAttachmentDataFileSystem
which stores the attachment data as files on a filesystem, using the standardFile
API.The files are stored within a hierarchical directory 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 directory structure is described by the following pattern: "a1/a2/ax/attachmentId.a/attachmentFile"
where a1, a2, ax are subdirectories generated from the attachment id by splitting the attachment id into up to 3 digits long substrings, and attachmentFile represents a combination of the attachment id, version and the data stream type. Attachments
AttachmentDataStreamType.RAW_BINARY
format has a filename that consists of the attachment id and the version separated by a dot (eg. "123456.1"). For other stream types, the filename is "id.version.streamType" (e.g. "123456.1.extracted_text"). Suffix ".a" in the attachment versions folder name is added to avoid clashes between attachment id and subdirectories' name.- Since:
- 8.1.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.atlassian.dc.filestore.api.compat.FilesystemPath
containerPathForAttachmentVersions(long latestVersionAttachmentId, long contentId, Long spaceId)
Get theFilesystemPath
representing the directory that contains all the versions of an attachmentstatic ContentDirectoryStructureAttachmentDataFileSystemV004
create(AttachmentDataStorageLocationResolver rootDir)
boolean
dataExistsForAttachment(AttachmentRef attachment)
Check if attachment data existsvoid
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
getAttachmentDataFile(long attachmentId, Long containerId, Long spaceId, Integer attachmentVersion, AttachmentDataStreamType dataStreamType)
com.atlassian.dc.filestore.api.compat.FilesystemPath
getPathForSpace(Long spaceId)
Deprecated.since 8.1.0, not needed in v004 storagevoid
moveAttachment(AttachmentRef oldAttachment, AttachmentRef newAttachment, AttachmentRef.Container newContent)
Deprecated.since 8.1.0, not needed in v004 storagevoid
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 storagevoid
moveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)
Deprecated.since 8.1.0, not needed in v004 storagevoid
prepareForMigrationTo()
Deprecated.since 8.1.0, not needed in v004 storage because no action needed for v004 migrationboolean
saveAttachmentData(AttachmentRef attachmentVersion, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)
Save attachment to the file system storage-
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.impl.pages.attachments.filesystem.AttachmentDataFileSystemInternals
containerDirectoryForAttachmentVersions, getDirectoryForSpace
-
-
-
-
Method Detail
-
create
public static ContentDirectoryStructureAttachmentDataFileSystemV004 create(AttachmentDataStorageLocationResolver rootDir)
-
dataExistsForAttachment
public boolean dataExistsForAttachment(AttachmentRef attachment)
Check if attachment data exists- Specified by:
dataExistsForAttachment
in interfaceAttachmentDataFileSystem
- Parameters:
attachment
- reference to the attachment- Returns:
- true if the attachment data is available
-
saveAttachmentData
public boolean saveAttachmentData(AttachmentRef attachmentVersion, AttachmentDataStream attachmentDataStream, boolean overwrite, org.springframework.util.unit.DataSize expectedFileSize)
Save attachment to the file system storage- Specified by:
saveAttachmentData
in interfaceAttachmentDataFileSystem
- Parameters:
attachmentVersion
- 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:
- the
FilesystemPath
representing the directory that contains all the versions of an attachment
-
containerPathForAttachmentVersions
public com.atlassian.dc.filestore.api.compat.FilesystemPath containerPathForAttachmentVersions(long latestVersionAttachmentId, long contentId, @Nullable Long spaceId)
Get theFilesystemPath
representing the directory that contains all the versions of an attachment- Specified by:
containerPathForAttachmentVersions
in interfaceAttachmentDataFileSystemInternals
- Parameters:
latestVersionAttachmentId
- this should be the ID of the latest version or the directory will not existcontentId
- not usedspaceId
- not used- Returns:
- the
FilesystemPath
representing the directory that contains all the versions of an attachment
-
getAttachmentDataFile
public AttachmentDataFile getAttachmentDataFile(long attachmentId, @Nullable Long containerId, @Nullable Long spaceId, @Nullable Integer attachmentVersion, AttachmentDataStreamType dataStreamType)
- Specified by:
getAttachmentDataFile
in interfaceAttachmentDataFileSystemInternals
-
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
- not used
-
deleteSingleAttachmentVersion
public void deleteSingleAttachmentVersion(AttachmentRef attachment, AttachmentRef.Container originalContent)
Delete the data corresponding to a single attachment versionThis method will remove any empty folders left after removing the attachment data.
- Specified by:
deleteSingleAttachmentVersion
in interfaceAttachmentDataFileSystem
- Parameters:
attachment
- the attachment for which data should be removedoriginalContent
- not used
-
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
-
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: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
-
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: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, not needed in v004 storage because no action needed for v004 migrationDescription copied from interface:AttachmentDataFileSystem
Prepare the data store for a migration from another type of data store.- Specified by:
prepareForMigrationTo
in interfaceAttachmentDataFileSystem
-
getPathForSpace
@Deprecated public com.atlassian.dc.filestore.api.compat.FilesystemPath getPathForSpace(@Nullable Long spaceId)
Deprecated.since 8.1.0, not needed in v004 storage- Specified by:
getPathForSpace
in interfaceAttachmentDataFileSystemInternals
-
moveDataForAttachmentVersion
@Deprecated public void moveDataForAttachmentVersion(AttachmentRef sourceAttachmentVersion, AttachmentRef targetAttachmentVersion)
Deprecated.since 8.1.0, not needed in v004 storageDescription 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
-
-