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

All Known Implementing Classes:
AbstractHibernateAttachmentDao, WebDavAttachmentDao

public interface AttachmentDao

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


Nested Class Summary
static interface AttachmentDao.AttachmentCopier
           
static interface AttachmentDao.AttachmentMigrator
           
 
Method Summary
 void afterMigrationFrom()
          Perform any tasks necessary after Attachment data has been moved from this data store to another.
 List findAll()
          Retrieves the latest versions of all Attachments Use of this method is discouraged when there are a large amount of Attachments.
 List findAllVersions(Attachment attachment)
           
 Iterator findLatestVersionsIterator()
          Retrieves the latest versions of all Attachments and returns an Iterator to the results.
 List getAttachmentByQuery(ListQuery query, int firstResult)
           
 InputStream getAttachmentData(Attachment attachment)
          Retrieves the InputStream representing the data for attachment
 AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
          Get a copier object to copy attachments between data stores The source data store will remain untouched
 List getLatestVersionsOfAttachments(ContentEntityObject ceo)
          Retrieves the latest versions of all attachments to ceo
 AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
          Get a migrator object to migrate attachments between attachment datastores.
 void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
          Moves an Attachment to a new file name or content object

This method assumes that the filename and/or content of the attachment (and its previous versions) have already been updated.

 void prepareForMigrationTo()
          Prepare the data store for a migration from another type of data store.
 void removeAttachmentFromServer(Attachment attachment)
          Removes attachment (and all of its versions)
 void replaceAttachmentData(Attachment attachment, InputStream attachmentData)
          Sets the attachment data for attachment This method will overwrite any existing data for the attachment version.
 void saveNewAttachment(Attachment attachment, InputStream attachmentData)
          Saves a new attachment
 void saveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData)
          Saves a new version of attachment
 

Method Detail

getLatestVersionsOfAttachments

public List getLatestVersionsOfAttachments(ContentEntityObject ceo)
Retrieves the latest versions of all attachments to ceo

Parameters:
ceo - the content to look up attachments
Returns:
a List of Attachment objects

findAll

public List findAll()
Retrieves the latest versions of all Attachments Use of this method is discouraged when there are a large amount of Attachments.

Returns:
A List of Attachment objects
See Also:
findLatestVersionsIterator()

findLatestVersionsIterator

public Iterator findLatestVersionsIterator()
Retrieves the latest versions of all Attachments and returns an Iterator to the results.

Returns:
Iterator to the results

getAttachmentData

public InputStream getAttachmentData(Attachment attachment)
                              throws AttachmentDataNotFoundException
Retrieves the InputStream representing the data for attachment

Parameters:
attachment -
Returns:
InputStream of the data
Throws:
AttachmentDataNotFoundException - if the data could not be found

getAttachmentByQuery

public List getAttachmentByQuery(ListQuery query,
                                 int firstResult)

saveNewAttachment

public void saveNewAttachment(Attachment attachment,
                              InputStream attachmentData)
Saves a new attachment

Parameters:
attachment - the Attachment to be saved
attachmentData - the attachment data to be saved

saveNewAttachmentVersion

public void saveNewAttachmentVersion(Attachment attachment,
                                     Attachment previousVersion,
                                     InputStream attachmentData)
Saves a new version of attachment

Parameters:
attachment - the Attachment to be saved
previousVersion - the previous version of the Attachment
attachmentData - the attachment data to be saved

moveAttachment

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

This method assumes that the filename and/or content of the attachment (and its previous versions) have already been updated.

Parameters:
attachment - the Attachment to be moved
oldAttachment - the Attachment before it has been updated
newContent - the new content attachment belongs to
Throws:
IllegalArgumentException - if attachment is not the latest version

removeAttachmentFromServer

public void removeAttachmentFromServer(Attachment attachment)
Removes attachment (and all of its versions)

Parameters:
attachment - the Attachment to be removed

replaceAttachmentData

public void replaceAttachmentData(Attachment attachment,
                                  InputStream attachmentData)
Sets the attachment data for attachment This method will overwrite any existing data for the attachment version.

Parameters:
attachment - Attachment the data belongs to
attachmentData - the data to save

getMigrator

public AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
Get a migrator object to migrate attachments between attachment datastores. To be used when switching datastore implementations

Parameters:
destinationDao - dao to move attachments to
Returns:
A migrator

getCopier

public AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
Get a copier object to copy attachments between data stores The source data store will remain untouched

Parameters:
destinationDao - dao to copy attachments to
Returns:
A copier

prepareForMigrationTo

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

Throws:
RuntimeException - if there was a problem

afterMigrationFrom

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

Throws:
RuntimeException - if there was a problem

findAllVersions

public List findAllVersions(Attachment attachment)


Confluence is developed by Atlassian.