public class FileSystemAttachmentDataDao extends Object implements NonTransactionalAttachmentDataDao
AttachmentDataDao which stores the
attachment data as files on a filesystem, using the standard File API via the
AttachmentDataFileSystem interface.
This class replaces HierarchicalFileSystemAttachmentDataDao,
but stores attachment data in the same structure and in a backwards-compatible way.
See HierarchicalMultiStreamAttachmentDataFileSystem| Modifier and Type | Field and Description |
|---|---|
static String |
ATTACHMENT_SUBDIRECTORY_NAME |
| Constructor and Description |
|---|
FileSystemAttachmentDataDao(FileLocationResolver attachmentsDirResolver,
HierarchicalMultiStreamAttachmentDataFileSystem fileSystem) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
InputStream |
getDataForAttachment(Attachment attachment)
Deprecated.
|
AttachmentDataStream |
getDataForAttachment(Attachment attachment,
AttachmentDataStreamType dataStreamType)
Grabs the AttachmentData object for an Attachment
|
AttachmentDataStorageType |
getStorageType()
Returns the storage type.
|
boolean |
isAttachmentPresent(Attachment attachment)
Check that an attachment exists
|
void |
moveAttachment(Attachment attachment,
Attachment oldAttachment,
ContentEntityObject newContent)
Moves an attachment to a new file name or content object
|
void |
moveDataForAttachmentVersion(Attachment sourceAttachmentVersion,
Attachment targetAttachmentVersion)
Moves the attachment data from one
AbstractVersionedEntityObject.getVersion() to the other. |
void |
prepareForMigrationTo()
In this implementation, we want to make sure the attachments directory is empty,
otherwise we will have attachments or files that don't belong.
|
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 |
replaceDataForAttachment(Attachment attachment,
AttachmentDataStream dataStream)
Sets the data for attachment
This method will overwrite any existing data for the attachment.
|
void |
replaceDataForAttachment(Attachment attachment,
InputStream data)
Deprecated.
|
void |
saveDataForAttachment(Attachment attachment,
AttachmentDataStream dataStream)
Saves data to the attachment data store
|
void |
saveDataForAttachment(Attachment attachment,
InputStream data)
Deprecated.
|
void |
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)
Deprecated.
|
public static final String ATTACHMENT_SUBDIRECTORY_NAME
public FileSystemAttachmentDataDao(FileLocationResolver attachmentsDirResolver, HierarchicalMultiStreamAttachmentDataFileSystem fileSystem)
@Deprecated public InputStream getDataForAttachment(Attachment attachment) throws AttachmentDataNotFoundException
getDataForAttachment in interface AttachmentDataDaoattachment - the Attachment representing the dataAttachmentDataNotFoundException - if no data was foundpublic AttachmentDataStream getDataForAttachment(Attachment attachment, AttachmentDataStreamType dataStreamType) throws AttachmentDataNotFoundException
AttachmentDataDaogetDataForAttachment in interface AttachmentDataDaoattachment - the Attachment representing the dataAttachmentDataNotFoundException - if no data was foundpublic void removeDataForAttachment(Attachment attachment, ContentEntityObject originalContent)
This method will remove any empty folders left after removing the attachment data.
removeDataForAttachment in interface AttachmentDataDaoattachment - the attachment for which data should be removedoriginalContent - the content the attachment belongs topublic void removeDataForAttachmentVersion(Attachment attachment, ContentEntityObject originalContent)
This method will remove any empty folders left after removing the attachment data.
removeDataForAttachmentVersion in interface AttachmentDataDaoattachment - the attachment for which data should be removedoriginalContent - the content the attachment belongs topublic void moveDataForAttachmentVersion(Attachment sourceAttachmentVersion, Attachment targetAttachmentVersion)
AbstractVersionedEntityObject.getVersion() to the other.
This method will overwrite any existing data for the target attachment version.moveDataForAttachmentVersion in interface AttachmentDataDaosourceAttachmentVersion - the attachmentAttachmentDataDao.moveAttachment(Attachment, Attachment, ContentEntityObject)@Deprecated public void saveDataForAttachment(Attachment attachment, InputStream data)
saveDataForAttachment in interface AttachmentDataDaoattachment - the Attachment the data belongs todata - the InputStream to be writtenpublic void saveDataForAttachment(Attachment attachment, AttachmentDataStream dataStream)
AttachmentDataDaosaveDataForAttachment in interface AttachmentDataDaoattachment - the Attachment the data belongs todataStream - the data stream to be written@Deprecated public void saveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream data)
saveDataForAttachmentVersion in interface AttachmentDataDaoattachment - the new version of the attachmentpreviousVersion - the previous version of the attachmentdata - the InputStream representing the datapublic void saveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, AttachmentDataStream dataStream)
AttachmentDataDaosaveDataForAttachmentVersion in interface AttachmentDataDaoattachment - the new version of the attachmentpreviousVersion - the previous version of the attachmentdataStream - the InputStream representing the data@Deprecated public void replaceDataForAttachment(Attachment attachment, InputStream data)
replaceDataForAttachment in interface AttachmentDataDaoattachment - Attachment the data belongs todata - the data to be savedpublic void replaceDataForAttachment(Attachment attachment, AttachmentDataStream dataStream)
AttachmentDataDaoreplaceDataForAttachment in interface AttachmentDataDaoattachment - Attachment the data belongs todataStream - the data to be savedpublic boolean isAttachmentPresent(Attachment attachment)
AttachmentDataDaoisAttachmentPresent in interface AttachmentDataDaoattachment - the Attachment to be checkedpublic void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
AttachmentDataDaomoveAttachment in interface AttachmentDataDaoattachment - the Attachment to be movedoldAttachment - the original version of the attachmentnewContent - the new content the Attachment belongs topublic void prepareForMigrationTo()
prepareForMigrationTo in interface AttachmentDataDaopublic void afterMigrationFrom()
afterMigrationFrom in interface AttachmentDataDaopublic final AttachmentDataStorageType getStorageType()
AttachmentDataDaoThe 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.
getStorageType in interface AttachmentDataDaoCopyright © 2003–2016 Atlassian. All rights reserved.