com.atlassian.confluence.pages.persistence.dao.hibernate
Class HibernateAttachmentDataDao

java.lang.Object
  extended byorg.springframework.orm.hibernate.support.HibernateDaoSupport
      extended bycom.atlassian.hibernate.HibernateObjectDao
          extended bybucket.core.persistence.hibernate.CachableHibernateObjectDao
              extended bycom.atlassian.confluence.pages.persistence.dao.hibernate.HibernateAttachmentDataDao
All Implemented Interfaces:
AttachmentDataDao, org.springframework.beans.factory.InitializingBean, ObjectDao, TransactionalAttachmentDataDao

public class HibernateAttachmentDataDao
extends CachableHibernateObjectDao
implements TransactionalAttachmentDataDao

This class defines an AttachmentDataDao that stores Attachment data in a Hibernate-managed database.

As a result, it is transactional (can be rolled back), so it implements the TransactionalAttachmentDataDao interface.


Field Summary
 
Fields inherited from class bucket.core.persistence.hibernate.CachableHibernateObjectDao
cacheManager
 
Fields inherited from class com.atlassian.hibernate.HibernateObjectDao
log
 
Fields inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
logger
 
Constructor Summary
HibernateAttachmentDataDao()
           
 
Method Summary
 void afterMigrationFrom()
          Once a data migration has occurred, remove all records from the table, as they are no longer necessary, and we don't want foreign key violations to occur when removing Attachments.
 List findAll()
           
 List findAllSorted(String s)
           
protected  AttachmentData getAttachmentDataForAttachment(Attachment attachment)
           
 InputStream getDataForAttachment(Attachment attachment)
          Grabs the AttachmentData object for an Attachment
 Class getPersistentClass()
           
 void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
          Moves an attachment to a new file name or content object
 void prepareForMigrationTo()
          This implementation clears out the Attachment data table, so we have a clean base for migration.
 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 save(EntityObject objectToSave)
           
 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.
 
Methods inherited from class bucket.core.persistence.hibernate.CachableHibernateObjectDao
setCacheManager
 
Methods inherited from class com.atlassian.hibernate.HibernateObjectDao
findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getByClassId, index, refresh, reIndex, remove, replicate, saveRaw, setIndexer, unIndex, updateModificationData
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
afterPropertiesSet, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, initDao, setHibernateTemplate, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateAttachmentDataDao

public HibernateAttachmentDataDao()
Method Detail

findAll

public List findAll()
Specified by:
findAll in interface ObjectDao

findAllSorted

public List findAllSorted(String s)
Specified by:
findAllSorted in interface ObjectDao

save

public void save(EntityObject objectToSave)
Specified by:
save in interface ObjectDao

getPersistentClass

public Class getPersistentClass()
Specified by:
getPersistentClass in interface ObjectDao

getAttachmentDataForAttachment

protected AttachmentData getAttachmentDataForAttachment(Attachment attachment)
                                                 throws AttachmentDataNotFoundException
Throws:
AttachmentDataNotFoundException

getDataForAttachment

public InputStream getDataForAttachment(Attachment attachment)
                                 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)
Description copied from interface: AttachmentDataDao
Removes all attachment data for an attachment

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

saveDataForAttachment

public void saveDataForAttachment(Attachment attachment,
                                  InputStream data)
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
data - the InputStream to be written

saveDataForAttachmentVersion

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

replaceDataForAttachment

public void replaceDataForAttachment(Attachment attachment,
                                     InputStream data)
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
data - the data to be saved

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()
This implementation clears out the Attachment data table, so we have a clean base for migration.

Specified by:
prepareForMigrationTo in interface AttachmentDataDao

afterMigrationFrom

public void afterMigrationFrom()
Once a data migration has occurred, remove all records from the table, as they are no longer necessary, and we don't want foreign key violations to occur when removing Attachments.

Specified by:
afterMigrationFrom in interface AttachmentDataDao


Confluence is developed by Atlassian.