public class Attachment extends SpaceContentEntityObject implements com.atlassian.bonnie.search.SearchableAttachment, Addressable, HasLinkWikiMarkup, ContentConvertible, Contained<ContentEntityObject>
Modifier and Type | Class and Description |
---|---|
static class |
Attachment.Type
An enum of basic Attachment types with a text description of each type.
|
Modifier and Type | Field and Description |
---|---|
static String |
API_REVISION |
static String |
API_REVISION_V2 |
static String |
CONTENT_TYPE |
static String |
DOWNLOAD_PATH_BASE
The download path for an attachment is composed with this base, see
getDownloadPathWithoutEncoding() for an example. |
static String |
PROFILE_PICTURE_COMMENT |
static String |
PROP_FILE_STORE_ID |
static String |
PROP_FILESIZE |
static String |
PROP_HIDDEN |
static String |
PROP_MEDIA_TYPE |
static String |
PROP_MINOR_EDIT |
COLLABORATIVE_EDITING_UUID, CONFLUENCE_RECOVERY, CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE, CONTENT_RESTORED_SYNC_REV_SOURCE, CREATED, CURRENT, DELETED, DRAFT, DUMMY_SYNC_REV, LIMITED_MODE_SYNC_REV_SOURCE, MODIFIED, SHARE_ID, SYNC_REV, SYNC_REV_SOURCE, SYNCHRONY_ACK_SYNC_REV_SOURCE, SYNCHRONY_RECOVERY, SYNCHRONY_RECOVERY_WITH_EXTERNAL_CHANGE, SYNCHRONY_SYNC_REV_SOURCE
INITIAL_VERSION
Constructor and Description |
---|
Attachment() |
Attachment(@NonNull String fileName,
@NonNull String mediaType,
long fileSize,
String versionComment)
Constructs a new Attachment.
|
Attachment(@NonNull String fileName,
@NonNull String mediaType,
long fileSize,
String versionComment,
boolean minorEdit) |
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
Attachment |
copy() |
Attachment |
copyLatestVersion()
Will copy all detail information of an attachment including :
- Content Properties
- File Name
- File Size
- Content Type
- And set version is 1
|
boolean |
equals(Object o) |
String |
getComment()
Deprecated.
Since 5.7. Use
ContentEntityObject.getVersionComment() instead |
@Nullable ContentEntityObject |
getContainer() |
ContentId |
getContentId()
Returns the
ContentId for this entity object, if it implements ContentConvertible . |
InputStream |
getContentsAsStream()
Deprecated.
since 5.5. Use
AttachmentManager.getAttachmentData(Attachment) |
@NonNull String |
getContentType()
Deprecated.
Since 5.7. Use
getMediaType() instead |
ContentType |
getContentTypeObject() |
static String |
getDescriptionForMimeType(String mimeType,
String fileExtension) |
String |
getDisplayTitle()
Returns the display title.
|
String |
getDownloadPath() |
String |
getDownloadPath(String attachmentPath,
boolean addVersionInfo)
Returns the download path of the attachment for a given attachmentPath prefix.
|
String |
getDownloadPathWithoutEncoding() |
String |
getDownloadPathWithoutVersion()
Returns the download path without any version info.
|
String |
getDownloadPathWithoutVersionOrApiRevision()
Returns the download path without any version info or API revision.
|
String |
getExportPath() |
String |
getExportPathForThumbnail() |
String |
getFileExtension()
Returns the file extension of the attachment.
|
@NonNull String |
getFileName() |
long |
getFileSize() |
String |
getFileStoreId() |
protected Collection |
getImageDetailsDTO()
accessor methods provided for hibernate proxy use only.
|
String |
getLinkWikiMarkup() |
@NonNull String |
getMediaType() |
String |
getNameForComparison()
Subclasses should implement this method, giving a String back so
that the content can be alphabetically sorted in a mixed-type list
of content-entities.
|
String |
getNiceFileSize() |
String |
getNiceType() |
Collection<com.atlassian.bonnie.Searchable> |
getSearchableDependants() |
Space |
getSpace() |
String |
getType()
An easy name for the type of this content: makes it easy for
things like the #contentLink macro to work out what to draw.
|
@Nullable String |
getUrlPath() |
VersionChildOwnerPolicy |
getVersionChildPolicy(ContentType contentType)
Returns the right
VersionChildOwnerPolicy depending on the passed contentType. |
int |
hashCode() |
boolean |
isHidden()
Indicates whether this attachment is supposed to be strictly hidden from displaying and searching
Hidden attachment is not indexable
Hidden attachment manipulation will not trigger external notification events
|
boolean |
isIndexable()
Only the current version of a non-hidden attachment is indexable (until we can deal with old objects in search results)
We also don't want to index attachments associated with drafts or global descriptions or hidden attachments
|
boolean |
isMinorEdit()
Indicates whether this attachment is supposed to be hidden under normal circumstances.
|
boolean |
isUserProfilePicture()
Determines whether the Attachment is a user's profile picture
|
void |
setContainer(ContentEntityObject content) |
void |
setContentType(@NonNull String contentType)
Deprecated.
Since 5.7. Use
setMediaType(java.lang.String) instead |
void |
setFileName(@NonNull String fileName) |
void |
setFileSize(long fileSize) |
void |
setFileStoreId(String fileStoreId) |
void |
setHidden(boolean hidden) |
protected void |
setImageDetailsDTO(Set imageDetailDTOs) |
void |
setMediaType(@NonNull String mediaType) |
void |
setMinorEdit(boolean minorEdit) |
boolean |
shouldConvertToContent() |
String |
toString() |
convertToHistoricalVersion, getSpaceKey, isInSpace, setSpace
addAttachment, addComment, addCustomContent, addOutgoingLink, addPermission, addReferralLink, addTrackbackLink, applyChildVersioningPolicy, applyChildVersioningPolicy, compareTo, ensureAttachmentBelongsToContent, getAttachmentManager, getAttachmentNamed, getAttachments, getAttachmentsUrlPath, getAttachmentUrlPath, getBodyAsString, getBodyAsStringWithoutMarkup, getBodyContent, getBodyContent, getBodyContents, getCollaborativeEditingUuid, getComments, getContainerContent, getContentPermission, getContentPermissionSet, getContentStatus, getContentStatusObject, getDefaultBodyType, getEntity, getExcerpt, getIdAsString, getLatestVersionId, getLatestVersionsOfAttachments, getLowerTitle, getOriginalVersionId, getOutgoingLinks, getPermissions, getProperties, getReferralLinks, getRenderedVersionComment, getSelector, getShareId, getSynchronyRevision, getSynchronyRevisionSource, getTitle, getTrackbackLinks, getTypeEnum, getVersionComment, hasContentPermissions, hasPermissions, isCurrent, isDeleted, isDraft, isUnpublished, isVersionCommentAvailable, removeAttachment, removeComment, removeContentPermissionSet, removeCustomContent, removeOutgoingLink, removeReferralLink, removeTrackbackLink, replaceContentProperties, restore, restoreDependents, setAttachments, setBodyAsString, setBodyContent, setBodyContents, setCollaborativeEditingUuid, setComments, setContainerContent, setContentPropertiesFrom, setContentStatus, setOriginalVersion, setOriginalVersionId, setOutgoingLinks, setReferralLinks, setShareId, setSynchronyRevision, setSynchronyRevisionSource, setTitle, setTrackbackLinks, setVersionComment, sharedAccessAllowed, sharedAccessAllowed, toPageContext, trash, trashDependents, wasCreatedBy
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, removeLabelling, setLabellings
getConfluenceRevision, getLatestVersion, getVersion, isLatestVersion, isNew, setVersion
getCreator, getCreatorName, getLastModifier, getLastModifierName, getRealClass, isPersistent, setCreator, setCreatorName, setLastModifier, setLastModifierName
getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
finalize, getClass, notify, notifyAll, wait, wait, wait
getId
getSelector
getId, isPersistent
public static final String PROP_MEDIA_TYPE
public static final String PROP_FILESIZE
public static final String PROP_MINOR_EDIT
public static final String PROP_HIDDEN
public static final String PROP_FILE_STORE_ID
public static final String CONTENT_TYPE
public static final String PROFILE_PICTURE_COMMENT
public static final String API_REVISION
public static final String API_REVISION_V2
public static final String DOWNLOAD_PATH_BASE
getDownloadPathWithoutEncoding()
for an example.public Attachment()
public Attachment(@NonNull String fileName, @NonNull String mediaType, long fileSize, String versionComment, boolean minorEdit)
public @NonNull String getFileName()
getFileName
in interface com.atlassian.bonnie.search.SearchableAttachment
public void setFileName(@NonNull String fileName)
public @NonNull String getMediaType()
public void setMediaType(@NonNull String mediaType)
@Deprecated public @NonNull String getContentType()
getMediaType()
insteadgetContentType
in interface com.atlassian.bonnie.search.SearchableAttachment
@Deprecated public void setContentType(@NonNull String contentType)
setMediaType(java.lang.String)
insteadpublic @Nullable ContentEntityObject getContainer()
getContainer
in interface Contained<ContentEntityObject>
public void setContainer(ContentEntityObject content)
@Deprecated public String getComment()
ContentEntityObject.getVersionComment()
insteadgetComment
in interface com.atlassian.bonnie.search.SearchableAttachment
public boolean isMinorEdit()
public void setMinorEdit(boolean minorEdit)
public String getFileStoreId()
public void setFileStoreId(String fileStoreId)
public boolean isHidden()
public void setHidden(boolean hidden)
public long getFileSize()
public void setFileSize(long fileSize)
public String getNiceFileSize()
getNiceFileSize
in interface com.atlassian.bonnie.search.SearchableAttachment
public String getNiceType()
getNiceType
in interface com.atlassian.bonnie.search.SearchableAttachment
public String getType()
ContentEntityObject
This is a bit of a hack, but it saves heaps of code elsewhere, especially since we tend to get back these objects wrapped in all sorts of Hibernate CGLIB stuff.
getType
in interface ContentTypeAware
getType
in class ContentEntityObject
public String getDisplayTitle()
ContentEntityObject
getDisplayTitle
in interface Addressable
getDisplayTitle
in class ContentEntityObject
public @Nullable String getUrlPath()
getUrlPath
in interface Addressable
getUrlPath
in class ContentEntityObject
public Collection<com.atlassian.bonnie.Searchable> getSearchableDependants()
getSearchableDependants
in interface com.atlassian.bonnie.Searchable
getSearchableDependants
in class ContentEntityObject
public boolean isUserProfilePicture()
public boolean isIndexable()
isIndexable
in interface com.atlassian.bonnie.Searchable
isIndexable
in class SpaceContentEntityObject
public String getDownloadPath()
getDownloadPath
in interface com.atlassian.bonnie.search.SearchableAttachment
public String getDownloadPathWithoutVersion()
public String getDownloadPathWithoutVersionOrApiRevision()
public String getDownloadPath(String attachmentPath, boolean addVersionInfo)
public String getDownloadPathWithoutEncoding()
public String getExportPath()
public String getExportPathForThumbnail()
@Deprecated public InputStream getContentsAsStream() throws IOException
AttachmentManager.getAttachmentData(Attachment)
getContentsAsStream
in interface com.atlassian.bonnie.search.SearchableAttachment
IOException
public String toString()
toString
in class ContentEntityObject
public String getNameForComparison()
ContentEntityObject
getNameForComparison
in class SpaceContentEntityObject
public boolean equals(Object o)
equals
in class ContentEntityObject
public int hashCode()
hashCode
in class SpaceContentEntityObject
public String getFileExtension()
public static String getDescriptionForMimeType(String mimeType, String fileExtension)
mimeType
- the mime type to be described. Should not be nullfileExtension
- the file extension to help with the deriving of the description.public Space getSpace()
getSpace
in interface Spaced
getSpace
in class SpaceContentEntityObject
Spaced
), or null otherwise.public String getLinkWikiMarkup()
getLinkWikiMarkup
in interface HasLinkWikiMarkup
protected Collection getImageDetailsDTO()
ImageDetailsManager
.getImageDetails(Attachment attachment)protected void setImageDetailsDTO(Set imageDetailDTOs)
public Object clone()
clone
in class ContentEntityObject
public Attachment copy()
public VersionChildOwnerPolicy getVersionChildPolicy(ContentType contentType)
Versioned
VersionChildOwnerPolicy
depending on the passed contentType.
By default, VersionChildOwnerPolicy.currentVersion
is returned
Right now, this is only enforced for children with content type Attachment or Comment
getVersionChildPolicy
in interface Versioned
getVersionChildPolicy
in class AbstractVersionedEntityObject
public ContentType getContentTypeObject()
getContentTypeObject
in interface ContentConvertible
public ContentId getContentId()
ContentEntityObject
ContentId
for this entity object, if it implements ContentConvertible
.
Subclasses implementing ContentConvertible must override this method.
getContentId
in interface ContentConvertible
getContentId
in class ContentEntityObject
public boolean shouldConvertToContent()
shouldConvertToContent
in interface ContentConvertible
public Attachment copyLatestVersion()
NOTE: it won't copy content history
Copyright © 2003–2021 Atlassian. All rights reserved.