com.atlassian.confluence.pages.persistence.dao
Interface AttachmentDataDao

All Known Subinterfaces:
NonTransactionalAttachmentDataDao, TransactionalAttachmentDataDao
All Known Implementing Classes:
FileSystemAttachmentDataDao, FileSystemAttachmentDataDao, HibernateAttachmentDataDao, HierarchicalFileSystemAttachmentDataDao

public interface AttachmentDataDao

This interface defines the methods for classes acting as a DAO at the level of data storage for Attachments.


Method Summary
 void afterMigrationFrom()
          Perform any tasks necessary after Attachment data has been moved from this data store to another.
 java.io.InputStream getDataForAttachment(Attachment attachment)
          Deprecated. Since 5.5 Use getDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStreamType)
 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()
          Prepare the data store for a migration from another type of data store.
 void removeDataForAttachment(Attachment attachment, ContentEntityObject originalContent)
          Removes all attachment data for the given attachment.
 void removeDataForAttachmentVersion(Attachment attachmentVersion, 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. Since 5.5 Use replaceDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStream)
 void saveDataForAttachment(Attachment attachment, AttachmentDataStream dataStream)
          Saves data to the attachment data store
 void saveDataForAttachment(Attachment attachment, java.io.InputStream data)
          Deprecated. Since 5.5 Use saveDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStream)
 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. Since 5.5 Use saveDataForAttachmentVersion(com.atlassian.confluence.pages.Attachment, com.atlassian.confluence.pages.Attachment, AttachmentDataStream)
 

Method Detail

getDataForAttachment

@Deprecated
java.io.InputStream getDataForAttachment(Attachment attachment)
                                         throws AttachmentDataNotFoundException
Deprecated. Since 5.5 Use getDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStreamType)

Grabs the AttachmentData object for an Attachment

Parameters:
attachment - the Attachment representing the data
Returns:
an AttachmentData object
Throws:
java.lang.IllegalArgumentException - if attachment is null
AttachmentDataNotFoundException - if no data was found

getDataForAttachment

AttachmentDataStream getDataForAttachment(Attachment attachment,
                                          AttachmentDataStreamType dataStreamType)
                                          throws AttachmentDataNotFoundException
Grabs the AttachmentData object for an Attachment

Parameters:
attachment - the Attachment representing the data
Returns:
an AttachmentData object
Throws:
java.lang.IllegalArgumentException - if attachment is null
AttachmentDataNotFoundException - if no data was found

removeDataForAttachment

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.

Parameters:
attachment - the latest version of the attachment for which the data should be removed
originalContent - the content the attachment belongs to
Throws:
java.lang.IllegalArgumentException - if attachment is null

removeDataForAttachmentVersion

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

Parameters:
attachmentVersion - the version of the attachment for which the data should be removed
originalContent - the content the attachment belongs to
Throws:
java.lang.IllegalArgumentException - if attachment is null
Since:
4.3

moveDataForAttachmentVersion

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.

Parameters:
sourceAttachmentVersion - the attachment
targetAttachmentVersion -
Throws:
java.lang.IllegalArgumentException - if the Attachment.getContent() differs
Since:
4.3
See Also:
moveAttachment(Attachment, Attachment, ContentEntityObject)

saveDataForAttachment

@Deprecated
void saveDataForAttachment(Attachment attachment,
                                      java.io.InputStream data)
Deprecated. Since 5.5 Use saveDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStream)

Saves data to the attachment data store

Parameters:
attachment - the Attachment the data belongs to
data - the InputStream to be written
Throws:
java.lang.IllegalArgumentException - if attachment is null
java.lang.IllegalArgumentException - if data is null
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().

saveDataForAttachment

void saveDataForAttachment(Attachment attachment,
                           AttachmentDataStream dataStream)
Saves data to the attachment data store

Parameters:
attachment - the Attachment the data belongs to
dataStream - the data stream to be written
Throws:
java.lang.IllegalArgumentException - if attachment is null
java.lang.IllegalArgumentException - if data is null
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().
Since:
5.5

saveDataForAttachmentVersion

@Deprecated
void saveDataForAttachmentVersion(Attachment attachment,
                                             Attachment previousVersion,
                                             java.io.InputStream data)
Deprecated. Since 5.5 Use saveDataForAttachmentVersion(com.atlassian.confluence.pages.Attachment, com.atlassian.confluence.pages.Attachment, AttachmentDataStream)

Saves data to the attachment data store, for an attachment that has been updated.

This method assumes that the attachment has already been saved.

Parameters:
attachment - the new version of the attachment
previousVersion - the previous version of the attachment
data - the InputStream representing the data
Throws:
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().

saveDataForAttachmentVersion

void saveDataForAttachmentVersion(Attachment attachment,
                                  Attachment previousVersion,
                                  AttachmentDataStream dataStream)
Saves data to the attachment data store, for an attachment that has been updated.

This method assumes that the attachment has already been saved.

Parameters:
attachment - the new version of the attachment
previousVersion - the previous version of the attachment
dataStream - the InputStream representing the data
Throws:
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().
Since:
5.5

replaceDataForAttachment

@Deprecated
void replaceDataForAttachment(Attachment attachment,
                                         java.io.InputStream data)
Deprecated. Since 5.5 Use replaceDataForAttachment(com.atlassian.confluence.pages.Attachment, AttachmentDataStream)

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

Parameters:
attachment - Attachment the data belongs to
data - the data to be saved
Throws:
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().

replaceDataForAttachment

void replaceDataForAttachment(Attachment attachment,
                              AttachmentDataStream dataStream)
Sets the data for attachment This method will overwrite any existing data for the attachment.

Parameters:
attachment - Attachment the data belongs to
dataStream - the data to be saved
Throws:
AttachmentDataStreamSizeMismatchException - if bytes read from the data stream does not match Attachment.getFileSize().
Since:
5.5

isAttachmentPresent

boolean isAttachmentPresent(Attachment attachment)
Check that an attachment exists

Parameters:
attachment - the Attachment to be checked

moveAttachment

void moveAttachment(Attachment attachment,
                    Attachment oldAttachment,
                    ContentEntityObject newContent)
Moves an attachment to a new file name or content object

Parameters:
attachment - the Attachment to be moved
oldAttachment - the original version of the attachment
newContent - the new content the Attachment belongs to
Throws:
java.lang.IllegalArgumentException - if attachment is null
java.lang.IllegalArgumentException - if newFileName is null
java.lang.IllegalArgumentException - if newContent is null

prepareForMigrationTo

void prepareForMigrationTo()
Prepare the data store for a migration from another type of data store.

Classes implementing this method will perform any tasks necessary to allow the data store to be used.

Implementations may circumvent hibernate, so should only be called when nobody else can see the attachment data.

Throws:
java.lang.RuntimeException - if there was a problem

afterMigrationFrom

void afterMigrationFrom()
Perform any tasks necessary after Attachment data has been moved from this data store to another.

Implementations may circumvent hibernate, so should only be called when nobody else can see the attachment data.

Throws:
java.lang.RuntimeException - if there was a problem

getStorageType

AttachmentDataStorageType getStorageType()
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.

Returns:
the storage type
Since:
4.3


Copyright © 2003-2014 Atlassian. All Rights Reserved.