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

All Known Subinterfaces:
NonTransactionalAttachmentDataDao, TransactionalAttachmentDataDao
All Known Implementing Classes:
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.
 InputStream getDataForAttachment(Attachment attachment)
          Grabs the AttachmentData object for an Attachment
 void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
          Moves an attachment to a new file name or content object
 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 an attachment
 void replaceDataForAttachment(Attachment attachment, InputStream data)
          Sets the data for attachment This method will overwrite any existing data for the attachment.
 void saveDataForAttachment(Attachment attachment, InputStream data)
          Saves data to the attachment data store
 void saveDataForAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream data)
          Saves data to the attachment data store, for an attachment that has been updated.
 

Method Detail

getDataForAttachment

InputStream getDataForAttachment(Attachment attachment)
                                 throws AttachmentDataNotFoundException
Grabs the AttachmentData object for an Attachment

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

removeDataForAttachment

void removeDataForAttachment(Attachment attachment,
                             ContentEntityObject originalContent)
Removes all attachment data for an attachment

Parameters:
attachment - The attachment for which data should be removed
originalContent - The content the attachment belongs to
Throws:
IllegalArgumentException - if attachment is null

saveDataForAttachment

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

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

saveDataForAttachmentVersion

void saveDataForAttachmentVersion(Attachment attachment,
                                  Attachment previousVersion,
                                  InputStream data)
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().

replaceDataForAttachment

void replaceDataForAttachment(Attachment attachment,
                              InputStream data)
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().

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:
IllegalArgumentException - if attachment is null
IllegalArgumentException - if newFileName is null
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:
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:
RuntimeException - if there was a problem


Copyright © 2003-2012 Atlassian. All Rights Reserved.