Package com.atlassian.confluence.pages
Class Attachment
java.lang.Object
com.atlassian.core.bean.EntityObject
- All Implemented Interfaces:
Searchable,Content,Addressable,ContentTypeAware,HasLinkWikiMarkup,Versioned,RelatableEntity,EditableLabelable,Labelable,Contained<ContentEntityObject>,ContentConvertible,SearchableAttachment,Spaced,Serializable,Cloneable,Comparable<ContentEntityObject>
- Direct Known Subclasses:
ReadOnlyAttachment
public class Attachment
extends SpaceContentEntityObject
implements SearchableAttachment, Addressable, HasLinkWikiMarkup, ContentConvertible, Contained<ContentEntityObject>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enum of basic Attachment types with a text description of each type. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.atlassian.confluence.core.ContentEntityObject
COLLABORATIVE_EDITING_UUID, CONFLUENCE_RECOVERY, CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE, CONTENT_RESTORED_SYNC_REV_SOURCE, CREATED, CURRENT, DELETED, DELETED_BY, DELETED_BY_ANON_VALUE, 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_SOURCEFields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION -
Constructor Summary
ConstructorsConstructorDescriptionAttachment(@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) -
Method Summary
Modifier and TypeMethodDescriptionclone()copy()Will copy all detail information of an attachment including : - Content Properties - File Name - File Size - Content Type - And set version is 1booleanDeprecated.Since 5.7.@Nullable ContentEntityObjectReturns theContentIdfor this entity object, if it implementsContentConvertible.Deprecated.since 5.5.@NonNull StringDeprecated.Since 5.7.static StringgetDescriptionForMimeType(String mimeType, String fileExtension) Returns the display title.getDownloadPath(String attachmentPath, boolean addVersionInfo) Returns the download path of the attachment for a given attachmentPath prefix.Returns the download path without any version info.Returns the download path without any version info or API revision.Returns the file extension of the attachment.@NonNull StringGets the filename of this attachment.longprotected Collectionaccessor methods provided for hibernate proxy use only.@NonNull StringSubclasses should implement this method, giving a String back so that the content can be alphabetically sorted in a mixed-type list of content-entities.When we un-index something (say, a page), we also need to un-index everything contained within that page (comments, attachments), because presumably they're all about to go away.getSpace()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 StringgetVersionChildPolicy(ContentType contentType) Returns the rightVersionChildOwnerPolicydepending on the passed contentType.inthashCode()booleanisHidden()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 eventsbooleanOnly 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 attachmentsbooleanIndicates whether this attachment is supposed to be hidden under normal circumstances.booleanDetermines whether the Attachment is a user's profile picturevoidsetContainer(ContentEntityObject content) voidsetContentType(@NonNull String contentType) Deprecated.Since 5.7.voidsetFileName(@NonNull String fileName) voidsetFileSize(long fileSize) voidsetFileStoreId(String fileStoreId) voidsetHidden(boolean hidden) protected voidsetImageDetailsDTO(Set imageDetailDTOs) voidsetMediaType(@NonNull String mediaType) voidsetMinorEdit(boolean minorEdit) booleantoString()Methods inherited from class com.atlassian.confluence.core.SpaceContentEntityObject
convertToHistoricalVersion, getSpaceKey, isInSpace, setSpaceMethods inherited from class com.atlassian.confluence.core.ContentEntityObject
addAttachment, addComment, addCustomContent, addOutgoingLink, addPermission, applyChildVersioningPolicy, compareTo, ensureAttachmentBelongsToContent, getAttachmentManager, getAttachmentNamed, getAttachments, getAttachmentsUrlPath, getAttachmentUrlPath, getBodyAsString, getBodyAsStringWithoutMarkup, getBodyContent, getBodyContent, getBodyContents, getCollaborativeEditingUuid, getComments, getContainerContent, getContentPermission, getContentPermissionSet, getContentStatus, getContentStatusObject, getCustomContent, getDefaultBodyType, getEntity, getExcerpt, getIdAsString, getLatestVersionId, getLatestVersionsOfAttachments, getLowerTitle, getOriginalVersionId, getOutgoingLinks, getPermissions, getProperties, getRenderedVersionComment, getSelector, getShareId, getSynchronyRevision, getSynchronyRevisionSource, getTitle, getTrashDate, getTypeEnum, getVersionComment, hasContentPermissions, hasPermissions, isCurrent, isDeleted, isDraft, isUnpublished, isVersionCommentAvailable, removeAttachment, removeComment, removeContentPermissionSet, removeCustomContent, removeOutgoingLink, replaceContentProperties, restore, restoreDependents, setAttachments, setBodyAsString, setBodyContent, setBodyContents, setCollaborativeEditingUuid, setComments, setContainerContent, setContentPropertiesFrom, setContentStatus, setOriginalVersion, setOriginalVersionId, setOutgoingLinks, setShareId, setSynchronyRevision, setSynchronyRevisionSource, setTitle, setVersionComment, sharedAccessAllowed, sharedAccessAllowed, toPageContext, trash, trash, trash, wasCreatedByMethods inherited from class com.atlassian.confluence.core.AbstractLabelableEntityObject
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, removeLabelling, setLabellingsMethods inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
getConfluenceRevision, getLatestVersion, getVersion, isLatestVersion, isNew, setVersionMethods inherited from class com.atlassian.confluence.core.ConfluenceEntityObject
getCreator, getCreatorName, getLastModifier, getLastModifierName, getRealClass, isPersistent, setCreator, setCreatorName, setLastModifier, setLastModifierNameMethods inherited from class com.atlassian.confluence.core.AnnotatedEntityObject
getCreationDate, getLastModificationDateMethods inherited from class com.atlassian.core.bean.EntityObject
getCurrentDate, getId, setClock, setCreationDate, setId, setLastModificationDateMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.atlassian.confluence.core.Addressable
getIdMethods inherited from interface com.atlassian.confluence.pages.ContentConvertible
getSelectorMethods inherited from interface com.atlassian.confluence.labels.EditableLabelable
getId, isPersistentMethods inherited from interface com.atlassian.bonnie.Searchable
getId
-
Field Details
-
PROP_MEDIA_TYPE
- See Also:
-
PROP_FILESIZE
- See Also:
-
PROP_MINOR_EDIT
- See Also:
-
PROP_HIDDEN
- See Also:
-
PROP_FILE_STORE_ID
- See Also:
-
CONTENT_TYPE
- See Also:
-
PROFILE_PICTURE_COMMENT
- See Also:
-
API_REVISION
- See Also:
-
API_REVISION_V2
- See Also:
-
DOWNLOAD_PATH_BASE
Deprecated, for removal: This API element is subject to removal in a future version.since 9.3 useAddressableAttachment.DOWNLOAD_PATH_BASEThe download path for an attachment is composed with this base, seegetDownloadPathWithoutEncoding()for an example.- See Also:
-
-
Constructor Details
-
Method Details
-
getFileName
Description copied from interface:SearchableAttachmentGets the filename of this attachment. If there is no filename, return the empty string. This method should never return null.- Specified by:
getFileNamein interfaceSearchableAttachment- Returns:
- the filename of this attachment, or the empty string if there is no filename
-
setFileName
-
getMediaType
-
setMediaType
-
getContentType
Deprecated.Since 5.7. UsegetMediaType()insteadDescription copied from interface:SearchableAttachmentGets the MIME content-type of this attachment. If there is no content-type, return "application/x-unknown". Should never return null.- Specified by:
getContentTypein interfaceSearchableAttachment- Returns:
- the MIME content-type of the attachment, or "application/x-unknown" if the MIME type is unknown
-
setContentType
Deprecated.Since 5.7. UsesetMediaType(java.lang.String)instead -
getContainer
- Specified by:
getContainerin interfaceContained<ContentEntityObject>- Returns:
- the owner of this content object. Can be null.
-
setContainer
-
getComment
Deprecated.Since 5.7. UseContentEntityObject.getVersionComment()insteadDescription copied from interface:SearchableAttachmentReturn any comment associated with this attachment- Specified by:
getCommentin interfaceSearchableAttachment
-
isMinorEdit
public boolean isMinorEdit()Indicates whether this attachment is supposed to be hidden under normal circumstances. At the moment this is only used to avoid sending notifications and to hide them in the activity stream. Future usages should be hiding them by default in the attachment macro output- Returns:
- true, if the attachment is hidden
-
setMinorEdit
public void setMinorEdit(boolean minorEdit) -
getFileStoreId
- Returns:
- FileStore ID of the binary data of this attachment
- Since:
- 5.9
-
setFileStoreId
- Since:
- 5.9
-
isHidden
public 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- Returns:
- true, if the attachment is hidden
-
setHidden
public void setHidden(boolean hidden) -
getFileSize
public long getFileSize()- Returns:
- The size (in bytes) of the attachment's raw binary data
-
setFileSize
public void setFileSize(long fileSize) -
getNiceFileSize
- Specified by:
getNiceFileSizein interfaceSearchableAttachment
-
getNiceType
- Specified by:
getNiceTypein interfaceSearchableAttachment- Returns:
- A nice type for this file if possible (eg "PDF" or "Word") - or null if no nice type can be recognised
-
getType
Description copied from class:ContentEntityObjectAn easy name for the type of this content: makes it easy for things like the #contentLink macro to work out what to draw.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.
- Specified by:
getTypein interfaceContentTypeAware- Specified by:
getTypein classContentEntityObject- Returns:
- the content type
-
getDisplayTitle
Description copied from class:ContentEntityObjectReturns the display title. Some entities don't have titles for identification. For example, personal information objects use the user's fullname. Override this method to provide a custom title.- Specified by:
getDisplayTitlein interfaceAddressable- Overrides:
getDisplayTitlein classContentEntityObject- Returns:
- the display title
-
getUrlPath
- Specified by:
getUrlPathin interfaceAddressable- Specified by:
getUrlPathin classContentEntityObject
-
getSearchableDependants
Description copied from interface:SearchableWhen we un-index something (say, a page), we also need to un-index everything contained within that page (comments, attachments), because presumably they're all about to go away.- Specified by:
getSearchableDependantsin interfaceSearchable
-
isUserProfilePicture
public boolean isUserProfilePicture()Determines whether the Attachment is a user's profile picture- Returns:
- true if it is attached to a PersonalInformation object and has the correct comment
-
isIndexable
public 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- Specified by:
isIndexablein interfaceSearchable- Overrides:
isIndexablein classSpaceContentEntityObject
-
getDownloadPath
- Specified by:
getDownloadPathin interfaceSearchableAttachment
-
getDownloadPathWithoutVersion
Returns the download path without any version info. -
getDownloadPathWithoutVersionOrApiRevision
Returns the download path without any version info or API revision.- Since:
- 5.10
-
getDownloadPath
Returns the download path of the attachment for a given attachmentPath prefix. It basically appends the filename and some meta info to form the path. -
getDownloadPathWithoutEncoding
-
getExportPath
-
getExportPathForThumbnail
-
getContentsAsStream
Deprecated.since 5.5. UseAttachmentManager.getAttachmentData(Attachment)Description copied from interface:SearchableAttachmentReturn the contents of the attachment as an InputStream- Specified by:
getContentsAsStreamin interfaceSearchableAttachment- Returns:
- an InputStream set at the start of the attachment's contents.
- Throws:
IOException
-
toString
- Overrides:
toStringin classContentEntityObject
-
getNameForComparison
Description copied from class:ContentEntityObjectSubclasses should implement this method, giving a String back so that the content can be alphabetically sorted in a mixed-type list of content-entities.- Overrides:
getNameForComparisonin classSpaceContentEntityObject
-
equals
- Overrides:
equalsin classContentEntityObject
-
hashCode
public int hashCode()- Overrides:
hashCodein classSpaceContentEntityObject
-
getFileExtension
Returns the file extension of the attachment. If there is no extension, an empty string is returned.- Returns:
- the file extension of the attachment in lower case
-
getDescriptionForMimeType
- Parameters:
mimeType- the mime type to be described. Should not be nullfileExtension- the file extension to help with the deriving of the description.- Returns:
- A more displayable description for the supplied mime type. If a blank String is supplied then null will be returned.
-
getSpace
- Specified by:
getSpacein interfaceSpaced- Overrides:
getSpacein classSpaceContentEntityObject- Returns:
- the space of the owning content if it can be associated with a space (i.e. of type
Spaced), or null otherwise.
-
getLinkWikiMarkup
- Specified by:
getLinkWikiMarkupin interfaceHasLinkWikiMarkup- Returns:
- the wiki markup used to link to this content
-
getImageDetailsDTO
accessor methods provided for hibernate proxy use only. useImageDetailsManager.getImageDetails(Attachment attachment) -
setImageDetailsDTO
-
clone
- Overrides:
clonein classContentEntityObject
-
copy
-
getVersionChildPolicy
Description copied from interface:VersionedReturns the rightVersionChildOwnerPolicydepending on the passed contentType. By default,VersionChildOwnerPolicy.currentVersionis returnedRight now, this is only enforced for children with content type Attachment or Comment
- Specified by:
getVersionChildPolicyin interfaceVersioned- Overrides:
getVersionChildPolicyin classAbstractVersionedEntityObject
-
getContentTypeObject
- Specified by:
getContentTypeObjectin interfaceContentConvertible- Returns:
- the api ContentType that this ContentConvertible converts to
-
getContentId
Description copied from class:ContentEntityObjectReturns theContentIdfor this entity object, if it implementsContentConvertible.Subclasses implementing ContentConvertible must override this method.
- Specified by:
getContentIdin interfaceContentConvertible- Overrides:
getContentIdin classContentEntityObject- Returns:
- the ContentId representation of this object's id
-
shouldConvertToContent
public boolean shouldConvertToContent()- Specified by:
shouldConvertToContentin interfaceContentConvertible- Returns:
- true if the implementer wants to be part of the core API (default value), false otherwise
-
copyLatestVersion
Will copy all detail information of an attachment including : - Content Properties - File Name - File Size - Content Type - And set version is 1NOTE: it won't copy content history
- Returns:
- a copy instance
- Since:
- 5.10
-
AddressableAttachment.DOWNLOAD_PATH_BASE