public interface AttachmentDao
Modifier and Type | Interface and Description |
---|---|
static interface |
AttachmentDao.AttachmentCopier |
static interface |
AttachmentDao.AttachmentMigrator |
Modifier and Type | Method and Description |
---|---|
void |
afterMigrationFrom()
Perform any tasks necessary after Attachment data has been moved from
this data store to another.
|
int |
countLatestVersionsOfAttachments(ContentEntityObject content) |
int |
countLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content,
Date since) |
int |
countLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content) |
List<Attachment> |
findAll()
Retrieves the latest versions of all Attachments
|
List<Attachment> |
findAllVersions(Attachment attachment) |
Iterator<Attachment> |
findLatestVersionsIterator()
Retrieves the latest versions of all Attachments and returns an
Iterator to the results.
|
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
|
InputStream |
getAttachmentData(Attachment attachment,
Optional<RangeRequest> range)
Retrieves the InputStream representing the specified range of data for attachment
|
Optional<AttachmentStatisticsDTO> |
getAttachmentStatistics()
Fetches statistics about attachments
|
AttachmentDataStorageType |
getBackingStorageType()
Returns the backing storage type.
|
Attachment |
getById(long id)
Returns the attachment with the given persistent ID.
|
List<Attachment> |
getByIds(List<Long> ids)
Returns a list of attachments matching the given list of IDs.
|
AttachmentDao.AttachmentCopier |
getCopier(AttachmentDao destinationDao)
Get a copier object to copy attachments between data stores
|
AttachmentDataDao |
getDataDao() |
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 ceo)
Retrieves the latest versions of all attachments to ceo
|
PageResponse<Attachment> |
getLatestVersionsOfAttachments(ContentEntityObject ceo,
LimitedRequest pageRequest,
com.google.common.base.Predicate<? super Attachment> predicate)
Deprecated.
|
List<Attachment> |
getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)
Retrieves the latest versions of all attachments for all CEOs provided
|
List<Attachment> |
getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject ceo)
Retrieves the latest versions of all attachments to ceo (including trashed)
|
AttachmentDao.AttachmentMigrator |
getMigrator(AttachmentDao destinationDao)
Get a migrator object to migrate attachments between attachment datastores.
|
Map<Long,Long> |
getRemappedAttachmentIds()
Gets a list of remapped attachment IDs.
|
boolean |
isAttachmentPresent(Attachment attachment)
Check that an attachment exists
|
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 |
removeAttachmentFromServer(Attachment attachment)
Removes attachment (and all of its versions)
|
void |
removeAttachmentVersionFromServer(Attachment attachment)
Removes an attachment version
|
void |
replaceAttachmentData(Attachment attachment,
InputStream attachmentData)
Sets the attachment data for attachment
|
void |
saveNewAttachment(Attachment attachment,
InputStream attachmentData)
Saves a new attachment
|
void |
saveNewAttachmentVersion(Attachment attachment,
Attachment previousVersion,
InputStream attachmentData)
Saves a new version of attachment
|
void |
updateAttachment(Attachment attachment)
Update an existing attachment without creating a new version
|
List<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo)
ceo
- the content to look up attachmentscountLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
List<Attachment> getLatestVersionsOfAttachmentsForMultipleCeos(Iterable<? extends ContentEntityObject> contentEntityObjects)
contentEntityObjects
- CEOs to retrieve attachements forList<Attachment> getLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject ceo)
ceo
- the content to look up attachmentscountLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
@Deprecated PageResponse<Attachment> getLatestVersionsOfAttachments(ContentEntityObject ceo, LimitedRequest pageRequest, com.google.common.base.Predicate<? super Attachment> predicate)
AttachmentDaoInternal.getFilteredLatestVersionsOfAttachments(ContentEntityObject, LimitedRequest, Predicate)
ceo
- the content to find attachments onpageRequest
- the pagination requestpredicate
- a predicate to filter the results byint countLatestVersionsOfAttachments(ContentEntityObject content)
content
- the content objectgetLatestVersionsOfAttachments(com.atlassian.confluence.core.ContentEntityObject)
int countLatestVersionsOfAttachmentsWithAnyStatus(ContentEntityObject content)
content
- the content object{com.atlassian.confluence.internal.pages.persistence.AttachmentDaoInternal#getLatestVersionsOfAttachmentsWithAnyStatusForContainers()}
int countLatestVersionsOfAttachmentsOnPageSince(ContentEntityObject content, Date since)
content
- the content objectsince
- the date of earliest change{com.atlassian.confluence.internal.pages.persistence.AttachmentDaoInternal#getLatestVersionsOfAttachmentsWithAnyStatusForContainers()}
Optional<AttachmentStatisticsDTO> getAttachmentStatistics()
List<Attachment> findAll()
Use of this method is discouraged when there are a large amount of Attachments.
findLatestVersionsIterator()
Iterator<Attachment> findLatestVersionsIterator()
InputStream getAttachmentData(Attachment attachment) throws AttachmentDataNotFoundException
attachment
- the attachment whose data will be returnedAttachmentDataNotFoundException
- if the data could not be foundInputStream getAttachmentData(Attachment attachment, Optional<RangeRequest> range) throws AttachmentDataNotFoundException
attachment
- the attachment whose data will be returnedrange
- the range of data to retrieve. See ByteRanges
AttachmentDataNotFoundException
- if the data could not be foundvoid saveNewAttachment(Attachment attachment, InputStream attachmentData)
attachment
- the Attachment to be savedattachmentData
- the attachment data to be savedvoid saveNewAttachmentVersion(Attachment attachment, Attachment previousVersion, InputStream attachmentData)
attachment
- the Attachment to be savedpreviousVersion
- the previous version of the AttachmentattachmentData
- the attachment data to be savedboolean isAttachmentPresent(Attachment attachment)
attachment
- the Attachment to be checkedvoid moveAttachment(Attachment attachment, Attachment oldAttachment, ContentEntityObject newContent)
This method assumes that the filename and/or content of the attachment (and its previous versions) have already been updated.
attachment
- the Attachment to be movedoldAttachment
- the Attachment before it has been updatednewContent
- the new content attachment belongs toIllegalArgumentException
- if attachment is not the latest versionvoid removeAttachmentFromServer(Attachment attachment)
attachment
- the Attachment to be removedvoid removeAttachmentVersionFromServer(Attachment attachment)
attachment
- the Attachment version to be removedvoid replaceAttachmentData(Attachment attachment, InputStream attachmentData)
This method will overwrite any existing data for the attachment version.
attachment
- Attachment the data belongs toattachmentData
- the data to saveAttachmentDao.AttachmentMigrator getMigrator(AttachmentDao destinationDao)
To be used when switching datastore implementations
destinationDao
- dao to move attachments toAttachmentDao.AttachmentCopier getCopier(AttachmentDao destinationDao)
The source data store will remain untouched
destinationDao
- dao to copy attachments tovoid prepareForMigrationTo()
Classes implementing this method will perform any tasks necessary to allow the data store to be used. These tasks may assume that users are locked out of the system.
RuntimeException
- if there was a problemvoid afterMigrationFrom()
RuntimeException
- if there was a problemList<Attachment> findAllVersions(Attachment attachment)
Attachment getById(long id)
id
- the persistent ID of the attachment to retrieveList<Attachment> getByIds(List<Long> ids)
ids
- list of IDs to retrieveAttachment getAttachment(ContentEntityObject content, String fileName, int version) throws IllegalArgumentException
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 getLatestAttachment(ContentEntityObject, String)
.
content
- the content to find the attachment onfileName
- the file name of the attachment, treated case-insensitivelyversion
- the version of the attachmentIllegalArgumentException
- if the content or fileName is nullAttachment getLatestAttachment(ContentEntityObject content, String fileName) throws IllegalArgumentException
content
- the content to find the attachment onfileName
- the file name of the attachmentIllegalArgumentException
- if the content or fileName is nullList<Attachment> getLastAddedVersionsOf(Attachment attachment)
attachment
- attachment (must be the latest version)IllegalArgumentException
- if the attachment is not the latest version or nullAttachmentDataStorageType getBackingStorageType()
AttachmentDataDao.getStorageType()
void updateAttachment(Attachment attachment)
attachment
- Map<Long,Long> getRemappedAttachmentIds()
AttachmentDataDao getDataDao()
Copyright © 2003–2021 Atlassian. All rights reserved.