com.atlassian.confluence.pages.persistence.dao
Class WebDavAttachmentDao

java.lang.Object
  extended by com.atlassian.confluence.pages.persistence.dao.WebDavAttachmentDao
All Implemented Interfaces:
AttachmentDao

Deprecated. since 2.7 WebDav attachment storage is no longer supported

public class WebDavAttachmentDao
extends Object
implements AttachmentDao

Legacy AttachmentDAO implementation for a WebDAV backend only maintained in the codebase for the purpose of upgrading *from* WebDAV.

This class handles authentication and communication with a WebDAV server when it is being used for Attachment storage.

This implementation is different to the default (AbstractHibernateAttachmentDao), as it does not store the Attachment data in the Hibernate-managed Confluence database. Instead, we construct the Attachment information from the properties stored by the WebDAV server. While this may result in decreased performance, it allows the WebDAV server to be accessed independently of Confluence and attachments changes to be reflected in Confluence.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.confluence.pages.persistence.dao.AttachmentDao
AttachmentDao.AttachmentCopier, AttachmentDao.AttachmentMigrator
 
Constructor Summary
WebDavAttachmentDao()
          Deprecated.  
 
Method Summary
 void afterMigrationFrom()
          Deprecated. The contents of the WebDAV store may be used by other applications or users, so we do not clean it out after migrating away from it.
 List<Attachment> findAll()
          Deprecated. 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)
          Deprecated.  
 Iterator<Attachment> findLatestVersionsIterator()
          Deprecated. This implementation is technically dodgy.
 Attachment getAttachment(ContentEntityObject content, String fileName, int version)
          Deprecated. Return the attachment on the specified content with the given filename and version.
 InputStream getAttachmentData(Attachment attachment)
          Deprecated. Retrieves the InputStream representing the data for attachment
 Attachment getById(long id)
          Deprecated. Returns the attachment with the given persistent ID.
 AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
          Deprecated. This method is not supported by the implementation.
 List<Attachment> getLastAddedVersionsOf(Attachment attachment)
          Deprecated. 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)
          Deprecated. Return the latest version of the attachment on the specified content with the given filename.
 List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo)
          Deprecated. Retrieves the latest versions of all attachments to ceo
 AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
          Deprecated. This method is not supported by the implementation.
 void moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
          Deprecated. 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()
          Deprecated. In this implementation, there may be existing files on the WebDAV store, so no deletion will occur.
 void removeAttachmentFromServer(Attachment attachment)
          Deprecated. todo: Should i remove the files from the webdav server?! should i remove the parent folder when folder's empty?
 void renameAttachment(Attachment attachment, String newName)
          Deprecated.  
 void replaceAttachmentData(Attachment attachment, InputStream attachmentData)
          Deprecated. Technically, this method is supposed to overwrite existing data without incrementing the version, due to the nature of WebDAV, we can't avoid that.
 void saveNewAttachment(Attachment attachment, InputStream attachmentData)
          Deprecated. This implementation saves a new Attachment to the appropriate path.
 void saveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData)
          Deprecated. Saves a new version of attachment
 void setConfig(WebDavConfiguration config)
          Deprecated.  
 void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebDavAttachmentDao

public WebDavAttachmentDao()
Deprecated. 
Method Detail

setConfig

public void setConfig(WebDavConfiguration config)
Deprecated. 

getLatestVersionsOfAttachments

public List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo)
Deprecated. 
Description copied from interface: AttachmentDao
Retrieves the latest versions of all attachments to ceo

Specified by:
getLatestVersionsOfAttachments in interface AttachmentDao
Parameters:
ceo - the content to look up attachments
Returns:
a List of Attachment objects

findAll

public List<Attachment> findAll()
Deprecated. 
Description copied from interface: AttachmentDao
Retrieves the latest versions of all Attachments Use of this method is discouraged when there are a large amount of Attachments.

Specified by:
findAll in interface AttachmentDao
Returns:
A List of Attachment objects
See Also:
AttachmentDao.findLatestVersionsIterator()

findLatestVersionsIterator

public Iterator<Attachment> findLatestVersionsIterator()
Deprecated. 
This implementation is technically dodgy. In other (Hibernate) implementations, we get an iterator of the results from the database, so we don't have to load all of the attachments into memory at the same time.

However, due to the nature of WebDAV (and the fact that we don't have a store for Attachment meta-data internal to Confluence), we can't do that, so just return an Iterator over the results of #findAll.

Specified by:
findLatestVersionsIterator in interface AttachmentDao
Returns:
an Iterator for the results of #findAll

getAttachmentData

public InputStream getAttachmentData(Attachment attachment)
                              throws AttachmentDataNotFoundException
Deprecated. 
Description copied from interface: AttachmentDao
Retrieves the InputStream representing the data for attachment

Specified by:
getAttachmentData in interface AttachmentDao
Parameters:
attachment - the attachment whose data will be returned
Returns:
InputStream of the data
Throws:
AttachmentDataNotFoundException - if the data could not be found

saveNewAttachment

public void saveNewAttachment(Attachment attachment,
                              InputStream attachmentData)
Deprecated. 
This implementation saves a new Attachment to the appropriate path.

It also removes the ContentEntityObject from the Attachment, in order to prevent cascade problems with Hibernate trying to store the Attachment and the CEO.

Specified by:
saveNewAttachment in interface AttachmentDao
Parameters:
attachment - the Attachment to save
attachmentData - the data to save for the Attachment

saveNewAttachmentVersion

public void saveNewAttachmentVersion(Attachment attachment,
                                     Attachment previousVersion,
                                     InputStream attachmentData)
Deprecated. 
Description copied from interface: AttachmentDao
Saves a new version of attachment

Specified by:
saveNewAttachmentVersion in interface AttachmentDao
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)
Deprecated. 
Description copied from interface: AttachmentDao
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.

Specified by:
moveAttachment in interface AttachmentDao
Parameters:
attachment - the Attachment to be moved
oldAttachment - the Attachment before it has been updated
newContent - the new content attachment belongs to

removeAttachmentFromServer

public void removeAttachmentFromServer(Attachment attachment)
Deprecated. 
todo: Should i remove the files from the webdav server?! should i remove the parent folder when folder's empty?

Specified by:
removeAttachmentFromServer in interface AttachmentDao
Parameters:
attachment - the Attachment to be removed

replaceAttachmentData

public void replaceAttachmentData(Attachment attachment,
                                  InputStream attachmentData)
Deprecated. 
Technically, this method is supposed to overwrite existing data without incrementing the version, due to the nature of WebDAV, we can't avoid that.

Specified by:
replaceAttachmentData in interface AttachmentDao
Parameters:
attachment - the Attachment to replace the data
attachmentData - the data to write

getMigrator

public AttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
Deprecated. 
This method is not supported by the implementation.

Specified by:
getMigrator in interface AttachmentDao
Parameters:
destinationDao - the destination AttachmentDAO
Returns:
throws UnsupportedOperationException
See Also:
GeneralAttachmentMigrator

getCopier

public AttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
Deprecated. 
This method is not supported by the implementation.

Specified by:
getCopier in interface AttachmentDao
Parameters:
destinationDao - the destination AttachmentDAO
Returns:
throws UnsupportedOperationException
See Also:
GeneralAttachmentCopier

prepareForMigrationTo

public void prepareForMigrationTo()
Deprecated. 
In this implementation, there may be existing files on the WebDAV store, so no deletion will occur. However, existing files will be overwritten.

Specified by:
prepareForMigrationTo in interface AttachmentDao

afterMigrationFrom

public void afterMigrationFrom()
Deprecated. 
The contents of the WebDAV store may be used by other applications or users, so we do not clean it out after migrating away from it.

Specified by:
afterMigrationFrom in interface AttachmentDao

renameAttachment

public void renameAttachment(Attachment attachment,
                             String newName)
                      throws IOException
Deprecated. 
Throws:
IOException

setContentEntityObjectDao

public void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)
Deprecated. 

findAllVersions

public List findAllVersions(Attachment attachment)
Deprecated. 
Specified by:
findAllVersions in interface AttachmentDao

getAttachment

public Attachment getAttachment(ContentEntityObject content,
                                String fileName,
                                int version)
Deprecated. 
Description copied from interface: AttachmentDao
Return the attachment on the specified content with the given filename and version. Returns null if no such attachment exists.

Note: unlike 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).

Specified by:
getAttachment in interface AttachmentDao
Parameters:
content - the content to find the attachment on
fileName - the file name of the attachment, treated case-insensitively
version - the version of the attachment
Returns:
the attachment with the given name and version attached to that content, or null if the attachment does not exist.

getLatestAttachment

public Attachment getLatestAttachment(ContentEntityObject content,
                                      String fileName)
Deprecated. 
Description copied from interface: AttachmentDao
Return the latest version of the attachment on the specified content with the given filename. Returns null if no attachment with that name on the content exists.

Specified by:
getLatestAttachment in interface AttachmentDao
Parameters:
content - the content to find the attachment on
fileName - the file name of the attachment
Returns:
the latest version of attachment with the given name attached to that content, or null if the attachment does not exist.

getById

public Attachment getById(long id)
Deprecated. 
Description copied from interface: AttachmentDao
Returns the attachment with the given persistent ID. Returns null if no such attachment exists.

Specified by:
getById in interface AttachmentDao
Parameters:
id - the persistent ID of the attachment to retrieve
Returns:
the attachment with the given ID, or null if no attachment exists with the provided ID.

getLastAddedVersionsOf

public List<Attachment> getLastAddedVersionsOf(Attachment attachment)
Deprecated. 
Description copied from interface: AttachmentDao
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. Result will be sorted with the earliest version coming first.

Specified by:
getLastAddedVersionsOf in interface AttachmentDao
Parameters:
attachment - attachment (must be the latest version)
Returns:
the last added versions for each user who has added a version of the attachment


Copyright © 2003-2010 Atlassian. All Rights Reserved.