com.atlassian.confluence.pages.persistence.dao.filesystem
Class FileSystemAttachmentDataDao

java.lang.Object
  extended by com.atlassian.confluence.pages.persistence.dao.filesystem.FileSystemAttachmentDataDao
All Implemented Interfaces:
AttachmentDataDao, NonTransactionalAttachmentDataDao

public class FileSystemAttachmentDataDao
extends java.lang.Object
implements NonTransactionalAttachmentDataDao

An implementation of 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

Since:
5.5

Field Summary
static java.lang.String ATTACHMENT_SUBDIRECTORY_NAME
           
 
Constructor Summary
FileSystemAttachmentDataDao(FileLocationResolver attachmentsDirResolver)
           
 
Method Summary
 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.
 java.io.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, java.io.InputStream data)
          Deprecated. 
 void saveDataForAttachment(Attachment attachment, AttachmentDataStream dataStream)
          Saves data to the attachment data store
 void saveDataForAttachment(Attachment attachment, java.io.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, java.io.InputStream data)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTACHMENT_SUBDIRECTORY_NAME

public static final java.lang.String ATTACHMENT_SUBDIRECTORY_NAME
See Also:
Constant Field Values
Constructor Detail

FileSystemAttachmentDataDao

public FileSystemAttachmentDataDao(FileLocationResolver attachmentsDirResolver)
Method Detail

getDataForAttachment

@Deprecated
public java.io.InputStream getDataForAttachment(Attachment attachment)
                                         throws AttachmentDataNotFoundException
Deprecated. 

Grabs the AttachmentData object for an Attachment

Specified by:
getDataForAttachment in interface AttachmentDataDao
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 interface AttachmentDataDao
Parameters:
attachment - the Attachment representing the data
Returns:
an AttachmentData object
Throws:
AttachmentDataNotFoundException - if no data was found

removeDataForAttachment

public void removeDataForAttachment(Attachment attachment,
                                    ContentEntityObject originalContent)
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.

This method will remove any empty folders left after removing the attachment data.

Specified by:
removeDataForAttachment in interface AttachmentDataDao
Parameters:
attachment - the attachment for which data should be removed
originalContent - the content the attachment belongs to

removeDataForAttachmentVersion

public void removeDataForAttachmentVersion(Attachment attachment,
                                           ContentEntityObject originalContent)
Removes the attachment data for the given attachment version.

This method will remove any empty folders left after removing the attachment data.

Specified by:
removeDataForAttachmentVersion in interface AttachmentDataDao
Parameters:
attachment - the attachment for which data should be removed
originalContent - the content the attachment belongs to

moveDataForAttachmentVersion

public void moveDataForAttachmentVersion(Attachment sourceAttachmentVersion,
                                         Attachment targetAttachmentVersion)
Moves the attachment data from one AbstractVersionedEntityObject.getVersion() to the other.

This method will overwrite any existing data for the target attachment version.

Specified by:
moveDataForAttachmentVersion in interface AttachmentDataDao
Parameters:
sourceAttachmentVersion - the attachment
See Also:
AttachmentDataDao.moveAttachment(Attachment, Attachment, ContentEntityObject)

saveDataForAttachment

@Deprecated
public void saveDataForAttachment(Attachment attachment,
                                             java.io.InputStream data)
Deprecated. 

Saves data to the attachment data store

Specified by:
saveDataForAttachment in interface AttachmentDataDao
Parameters:
attachment - the Attachment the data belongs to
data - the InputStream to be written

saveDataForAttachment

public void saveDataForAttachment(Attachment attachment,
                                  AttachmentDataStream dataStream)
Description copied from interface: AttachmentDataDao
Saves data to the attachment data store

Specified by:
saveDataForAttachment in interface AttachmentDataDao
Parameters:
attachment - the Attachment the data belongs to
dataStream - the data stream to be written

saveDataForAttachmentVersion

@Deprecated
public void saveDataForAttachmentVersion(Attachment attachment,
                                                    Attachment previousVersion,
                                                    java.io.InputStream data)
Deprecated. 

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 interface AttachmentDataDao
Parameters:
attachment - the new version of the attachment
previousVersion - the previous version of the attachment
data - 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 interface AttachmentDataDao
Parameters:
attachment - the new version of the attachment
previousVersion - the previous version of the attachment
dataStream - the InputStream representing the data

replaceDataForAttachment

@Deprecated
public void replaceDataForAttachment(Attachment attachment,
                                                java.io.InputStream data)
Deprecated. 

Sets the data for attachment This method will overwrite any existing data for the attachment.

Specified by:
replaceDataForAttachment in interface AttachmentDataDao
Parameters:
attachment - Attachment the data belongs to
data - the data to be saved

replaceDataForAttachment

public void replaceDataForAttachment(Attachment attachment,
                                     AttachmentDataStream dataStream)
Description copied from interface: AttachmentDataDao
Sets the data for attachment This method will overwrite any existing data for the attachment.

Specified by:
replaceDataForAttachment in interface AttachmentDataDao
Parameters:
attachment - Attachment the data belongs to
dataStream - the data to be saved

isAttachmentPresent

public boolean isAttachmentPresent(Attachment attachment)
Description copied from interface: AttachmentDataDao
Check that an attachment exists

Specified by:
isAttachmentPresent in interface AttachmentDataDao
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 interface AttachmentDataDao
Parameters:
attachment - the Attachment to be moved
oldAttachment - the original version of the attachment
newContent - the new content the Attachment belongs to

prepareForMigrationTo

public 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.

We also want to make sure the attachments directory actually exists, prior to moving data across.

It is the responsibility of the action performing the migration to warn the user about this.

Specified by:
prepareForMigrationTo in interface AttachmentDataDao

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 interface AttachmentDataDao

getStorageType

public final AttachmentDataStorageType 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 interface AttachmentDataDao
Returns:
the storage type


Copyright © 2003-2014 Atlassian. All Rights Reserved.