|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate.support.HibernateDaoSupport
com.atlassian.hibernate.HibernateObjectDao
com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<Attachment>
com.atlassian.confluence.pages.persistence.dao.hibernate.AbstractHibernateAttachmentDao
public abstract class AbstractHibernateAttachmentDao
Abstract class that defines the basic methods necessary for saving Attachments to a database.
The location of the storage of attachment data is dependent on the AttachmentDataDao set for this class. In some cases, since the removal of attachments is destructive, different implementations may wish to perform the removal of data in a different order. Subclasses will have to implement the #removeDataForAttachment(Attachment attachment) method.
Nested Class Summary | |
---|---|
class |
AbstractHibernateAttachmentDao.IntraHibernateAttachmentCopier
This attachment copier will copy attachment streams from the current instance of AbstractHibernateAttachmentDao to another. |
class |
AbstractHibernateAttachmentDao.IntraHibernateAttachmentMigrator
This attachment migrator will migrate attachment streams from the current instance of AbstractHibernateAttachmentDao to another. |
Nested classes/interfaces inherited from interface com.atlassian.confluence.pages.persistence.dao.AttachmentDao |
---|
AttachmentDao.AttachmentCopier, AttachmentDao.AttachmentMigrator |
Field Summary | |
---|---|
protected AttachmentDataDao |
dataDao
|
Fields inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao |
---|
cacheFactory |
Fields inherited from class org.springframework.dao.support.DaoSupport |
---|
logger |
Constructor Summary | |
---|---|
AbstractHibernateAttachmentDao()
|
Method Summary | |
---|---|
void |
afterMigrationFrom()
This implementation removes all Attachments and passes the migration tasks onto the AttachmentDataDao |
List<Attachment> |
findAllVersions(Attachment attachment)
|
void |
flush()
This implementation flushes the Hibernate session. |
Attachment |
getAttachment(ContentEntityObject content,
String fileName,
int version)
Return the attachment on the specified content with the given filename and version. |
InputStream |
getAttachmentData(Attachment attachment)
Retrieves the InputStream representing the data for attachment |
Attachment |
getById(long id)
Returns the attachment with the given persistent ID. |
AttachmentDao.AttachmentCopier |
getCopier(AttachmentDao destinationDao)
Get a copier object to copy attachments between data stores The source data store will remain untouched |
AttachmentDataDao |
getDataDao()
|
static AttachmentDao |
getInstance(AttachmentDataDao attachmentDataDao)
Returns the correct instance of AttachmentDao for the AttachmentDataDao that is given. |
List<Attachment> |
getLastAddedVersionsOf(Attachment attachment)
Retrieves all the last added versions for each user who has added a version of the attachment That is, if a user has added multiple versions, only the latest added version will be added to the list returned. |
Attachment |
getLatestAttachment(ContentEntityObject content,
String fileName)
Return the latest version of the attachment on the specified content with the given filename. |
List<Attachment> |
getLatestVersionsOfAttachments(ContentEntityObject content)
Retrieves the latest versions of all attachments to ceo |
AttachmentDao.AttachmentMigrator |
getMigrator(AttachmentDao destinationDao)
Get a migrator object to migrate attachments between attachment datastores. |
Class |
getPersistentClass()
|
void |
moveAttachment(Attachment latestVersion,
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()
This implementation removes the contents of the table and passes the migration tasks onto the AttachmentDataDao |
protected void |
removeAttachment(Attachment attachment,
ContentEntityObject content)
Severs the connection between attachment and content, and removes the attachment from the database |
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)
This implementation saves the Attachment and its previous version to the VersionedHibernateObjectDao. |
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao |
---|
findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, save, setCacheFactory, updateModificationData |
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport |
---|
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory |
Methods inherited from class org.springframework.dao.support.DaoSupport |
---|
afterPropertiesSet, initDao |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.atlassian.confluence.pages.persistence.dao.AttachmentDao |
---|
findAll, findLatestVersionsIterator, removeAttachmentFromServer |
Methods inherited from interface bucket.core.persistence.ObjectDao |
---|
findAll, refresh, remove, replicate, save, saveRaw |
Field Detail |
---|
protected AttachmentDataDao dataDao
Constructor Detail |
---|
public AbstractHibernateAttachmentDao()
Method Detail |
---|
public AttachmentDataDao getDataDao()
public static AttachmentDao getInstance(AttachmentDataDao attachmentDataDao)
attachmentDataDao
- the AttachmentDataDao that should be used
IllegalArgumentException
- if dataDao is not supportedpublic Class getPersistentClass()
getPersistentClass
in interface ObjectDao
public List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject content)
AttachmentDao
getLatestVersionsOfAttachments
in interface AttachmentDao
content
- the content to look up attachments
public Attachment getById(long id)
AttachmentDao
getById
in interface AttachmentDao
id
- the persistent ID of the attachment to retrieve
public Attachment getAttachment(ContentEntityObject content, String fileName, int version)
AttachmentDao
AttachmentManager.getAttachment(ContentEntityObject, String, int)
, this method does not accept zero as a special
flag to indicate the latest version of an attachment. To retrieve the latest version
of an attachment, use AttachmentDao.getLatestAttachment(ContentEntityObject, String)
.
getAttachment
in interface AttachmentDao
content
- the content to find the attachment onfileName
- the file name of the attachment, treated case-insensitivelyversion
- the version of the attachment
public Attachment getLatestAttachment(ContentEntityObject content, String fileName)
AttachmentDao
getLatestAttachment
in interface AttachmentDao
content
- the content to find the attachment onfileName
- the file name of the attachment
public List<Attachment> getLastAddedVersionsOf(Attachment attachment)
AttachmentDao
getLastAddedVersionsOf
in interface AttachmentDao
attachment
- attachment (must be the latest version)
public List<Attachment> findAllVersions(Attachment attachment)
findAllVersions
in interface AttachmentDao
public InputStream getAttachmentData(Attachment attachment) throws AttachmentDataNotFoundException
AttachmentDao
getAttachmentData
in interface AttachmentDao
attachment
- the attachment whose data will be returned
AttachmentDataNotFoundException
- if the data could not be foundpublic void saveNewAttachment(Attachment attachment, InputStream attachmentData)
AttachmentDao
saveNewAttachment
in interface AttachmentDao
attachment
- the Attachment to be savedattachmentData
- the attachment data to be savedpublic void saveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData)
saveNewAttachmentVersion
in interface AttachmentDao
attachment
- the attachment to be saved, a clone of the old onepreviousVersion
- the old attachment, which must be unmodifiedattachmentData
- the new attachment datapublic void moveAttachment(Attachment latestVersion, Attachment oldAttachment, ContentEntityObject newContent)
AttachmentDao
moveAttachment
in interface AttachmentDao
latestVersion
- the Attachment to be movedoldAttachment
- the Attachment before it has been updatednewContent
- the new content attachment belongs toprotected void removeAttachment(Attachment attachment, ContentEntityObject content)
attachment
- the attachment to removecontent
- the content to remove the attachment frompublic AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
AttachmentDao
getMigrator
in interface AttachmentDao
destinationDao
- dao to move attachments to
public AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
AttachmentDao
getCopier
in interface AttachmentDao
destinationDao
- dao to copy attachments to
public void prepareForMigrationTo()
prepareForMigrationTo
in interface AttachmentDao
public void afterMigrationFrom()
afterMigrationFrom
in interface AttachmentDao
public void replaceAttachmentData(Attachment attachment, InputStream attachmentData)
AttachmentDao
replaceAttachmentData
in interface AttachmentDao
attachment
- Attachment the data belongs toattachmentData
- the data to savepublic void flush()
flush
in interface FlushableCachingDao
RuntimeException
- if there was a problem flushing
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |