com.atlassian.confluence.pages
Class Attachment

java.lang.Object
  extended by com.atlassian.core.bean.EntityObject
      extended by com.atlassian.confluence.core.ConfluenceEntityObject
          extended by com.atlassian.confluence.core.AbstractVersionedEntityObject
              extended by com.atlassian.confluence.core.AbstractLabelableEntityObject
                  extended by com.atlassian.confluence.core.ContentEntityObject
                      extended by com.atlassian.confluence.pages.Attachment
All Implemented Interfaces:
com.atlassian.bonnie.search.SearchableAttachment, com.atlassian.bonnie.Searchable, Content, Addressable, ContentTypeAware, HasLinkWikiMarkup, Versioned, EditableLabelable, Labelable, Contained<ContentEntityObject>, ContentConvertible, Spaced, Serializable, Cloneable, Comparable

public class Attachment
extends ContentEntityObject
implements com.atlassian.bonnie.search.SearchableAttachment, Addressable, Spaced, HasLinkWikiMarkup, ContentConvertible, Contained<ContentEntityObject>

See Also:
Serialized Form

Nested Class Summary
static class Attachment.Type
          An enum of basic Attachment types with a text description of each type.
 
Field Summary
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_FILESIZE
           
static String PROP_HIDDEN
           
static String PROP_MEDIA_TYPE
           
static String PROP_MINOR_EDIT
           
 
Fields inherited from class com.atlassian.confluence.core.ContentEntityObject
CREATED, CURRENT, DELETED, MODIFIED
 
Fields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION
 
Constructor Summary
Attachment()
           
Attachment(String fileName, String mediaType, long fileSize, String versionComment)
          Constructs a new Attachment.
Attachment(String fileName, String mediaType, long fileSize, String versionComment, boolean minorEdit)
           
 
Method Summary
 Object clone()
           
 Attachment copy()
           
 boolean equals(Object o)
           
 Integer getAttachmentVersion()
          Deprecated. Since 5.7. Use AbstractVersionedEntityObject.getVersion() instead
 String getComment()
          Deprecated. Since 5.7. Use ContentEntityObject.getVersionComment() instead
 ContentEntityObject getContainer()
           
 ContentEntityObject getContent()
          Deprecated. since 5.7 Use getContainer() instead
 ContentId getContentId()
          Returns the ContentId for this entity object, if it implements ContentConvertible.
 InputStream getContentsAsStream()
          Deprecated. since 5.5. Use AttachmentManager.getAttachmentData(Attachment)
 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 getExportPath()
           
 String getExportPathForThumbnail()
           
 String getFileExtension()
          Returns the file extension of the attachment.
 String getFileName()
           
 long getFileSize()
           
protected  Collection getImageDetailsDTO()
          accessor methods provided for hibernate proxy use only.
 String getLinkWikiMarkup()
           
 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 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.
 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 setAttachmentVersion(Integer attachmentVersion)
          Deprecated. Since 5.7. Use AbstractVersionedEntityObject.setVersion(int) instead
 void setComment(String comment)
          Deprecated. Since 5.7. Use ContentEntityObject.setVersionComment(java.lang.String) instead
 void setContainer(ContentEntityObject content)
           
 void setContent(ContentEntityObject content)
          Deprecated. since 5.7 Use setContainer(ContentEntityObject) instead
 void setContentType(String contentType)
          Deprecated. Since 5.7. Use setMediaType(java.lang.String) instead
 void setFileName(String fileName)
           
 void setFileSize(long fileSize)
           
protected  void setImageDetailsDTO(Set imageDetailDTOs)
           
 void setMediaType(String mediaType)
           
 void setMinorEdit(boolean minorEdit)
           
 boolean shouldConvertToContent()
           
 String toString()
           
 
Methods inherited from class com.atlassian.confluence.core.ContentEntityObject
addAttachment, addComment, addCustomContent, addOutgoingLink, addPermission, addReferralLink, addTrackbackLink, applyChildVersioningPolicy, compareTo, convertToHistoricalVersion, ensureAttachmentBelongsToContent, getAttachmentNamed, getAttachments, getAttachmentsUrlPath, getAttachmentUrlPath, getBodyAsString, getBodyAsStringWithoutMarkup, getBodyContent, getBodyContent, getBodyContents, getComments, getContainerContent, getContentEntityObject, getContentPermission, getContentPermissionSet, getContentStatus, getDefaultBodyType, getEntity, getExcerpt, getIdAsString, getLatestVersionsOfAttachments, getOutgoingLinks, getPermissions, getProperties, getReferralLinks, getRenderedVersionComment, getTitle, getTrackbackLinks, getTypeEnum, getUserAccessor, getVersionComment, hasContentPermissions, hasPermissions, isCurrent, isDeleted, isRecentlyUpdatedFor, isVersionCommentAvailable, removeAttachment, removeComment, removeContentPermissionSet, removeCustomContent, removeOutgoingLink, removeReferralLink, removeTrackbackLink, replaceContentProperties, restore, restoreDependents, setAttachments, setBodyAsString, setBodyContent, setBodyContents, setComments, setContainerContent, setContentStatus, setOutgoingLinks, setReferralLinks, setTitle, setTrackbackLinks, setUserAccessor, setVersionComment, toPageContext, trash, trashDependents
 
Methods inherited from class com.atlassian.confluence.core.AbstractLabelableEntityObject
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getLabelUtil, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, isFavourite, removeLabelling, setLabellings
 
Methods inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
getLatestVersion, getOriginalVersion, getVersion, isLatestVersion, isNew, setOriginalVersion, setVersion
 
Methods inherited from class com.atlassian.confluence.core.ConfluenceEntityObject
getCreator, getCreatorName, getLastModifier, getLastModifierName, getRealClass, isPersistent, setCreator, setCreatorName, setLastModifier, setLastModifierName
 
Methods inherited from class com.atlassian.core.bean.EntityObject
getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.atlassian.bonnie.Searchable
getId
 
Methods inherited from interface com.atlassian.confluence.core.Addressable
getId
 
Methods inherited from interface com.atlassian.confluence.labels.EditableLabelable
getId, isPersistent
 

Field Detail

PROP_MEDIA_TYPE

public static final String PROP_MEDIA_TYPE
See Also:
Constant Field Values

PROP_FILESIZE

public static final String PROP_FILESIZE
See Also:
Constant Field Values

PROP_MINOR_EDIT

public static final String PROP_MINOR_EDIT
See Also:
Constant Field Values

PROP_HIDDEN

public static final String PROP_HIDDEN
See Also:
Constant Field Values

CONTENT_TYPE

public static final String CONTENT_TYPE
See Also:
Constant Field Values

PROFILE_PICTURE_COMMENT

public static final String PROFILE_PICTURE_COMMENT
See Also:
Constant Field Values

API_REVISION

public static final String API_REVISION
See Also:
Constant Field Values

API_REVISION_V2

public static final String API_REVISION_V2
See Also:
Constant Field Values

DOWNLOAD_PATH_BASE

public static final String DOWNLOAD_PATH_BASE
The download path for an attachment is composed with this base, see getDownloadPathWithoutEncoding() for an example.

Constructor Detail

Attachment

public Attachment()

Attachment

public Attachment(@Nonnull
                  String fileName,
                  @Nonnull
                  String mediaType,
                  long fileSize,
                  @Nonnull
                  String versionComment,
                  boolean minorEdit)

Attachment

public Attachment(@Nonnull
                  String fileName,
                  @Nonnull
                  String mediaType,
                  long fileSize,
                  @Nonnull
                  String versionComment)
Constructs a new Attachment.

Method Detail

getAttachmentVersion

@Deprecated
public Integer getAttachmentVersion()
Deprecated. Since 5.7. Use AbstractVersionedEntityObject.getVersion() instead


setAttachmentVersion

@Deprecated
public void setAttachmentVersion(@Nullable
                                            Integer attachmentVersion)
Deprecated. Since 5.7. Use AbstractVersionedEntityObject.setVersion(int) instead


getFileName

@Nonnull
public String getFileName()
Specified by:
getFileName in interface com.atlassian.bonnie.search.SearchableAttachment

setFileName

public void setFileName(@Nonnull
                        String fileName)

getMediaType

@Nonnull
public String getMediaType()

setMediaType

public void setMediaType(@Nonnull
                         String mediaType)

getContentType

@Nonnull
@Deprecated
public String getContentType()
Deprecated. Since 5.7. Use getMediaType() instead

Specified by:
getContentType in interface com.atlassian.bonnie.search.SearchableAttachment

setContentType

@Deprecated
public void setContentType(@Nonnull
                                      String contentType)
Deprecated. Since 5.7. Use setMediaType(java.lang.String) instead


getContainer

public ContentEntityObject getContainer()
Specified by:
getContainer in interface Contained<ContentEntityObject>
Returns:
the owner of this content object. Can be null.

setContainer

public void setContainer(ContentEntityObject content)

getContent

@Deprecated
@Nonnull
public ContentEntityObject getContent()
Deprecated. since 5.7 Use getContainer() instead

The object to which the attachment is attached. Eg the page or blog post to which its attached.


setContent

@Deprecated
public void setContent(@Nonnull
                                  ContentEntityObject content)
Deprecated. since 5.7 Use setContainer(ContentEntityObject) instead


getComment

@Deprecated
public String getComment()
Deprecated. Since 5.7. Use ContentEntityObject.getVersionComment() instead

Specified by:
getComment in interface com.atlassian.bonnie.search.SearchableAttachment

setComment

@Deprecated
public void setComment(String comment)
Deprecated. Since 5.7. Use ContentEntityObject.setVersionComment(java.lang.String) instead


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)

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

getFileSize

public long getFileSize()
Returns:
The size (in bytes) of the attachment's raw binary data

setFileSize

public void setFileSize(long fileSize)

getNiceFileSize

public String getNiceFileSize()
Specified by:
getNiceFileSize in interface com.atlassian.bonnie.search.SearchableAttachment

getNiceType

public String getNiceType()
Specified by:
getNiceType in interface com.atlassian.bonnie.search.SearchableAttachment
Returns:
A nice type for this file if possible (eg "PDF" or "Word") - or null if no nice type can be recognised

getType

public String getType()
Description copied from class: ContentEntityObject
An 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:
getType in interface ContentTypeAware
Specified by:
getType in class ContentEntityObject
Returns:
the content type

getDisplayTitle

public String getDisplayTitle()
Description copied from class: ContentEntityObject
Returns 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:
getDisplayTitle in interface Addressable
Overrides:
getDisplayTitle in class ContentEntityObject
Returns:
the display title

getUrlPath

@Nullable
public String getUrlPath()
Specified by:
getUrlPath in interface Addressable
Specified by:
getUrlPath in class ContentEntityObject

getSearchableDependants

public Collection getSearchableDependants()
Specified by:
getSearchableDependants in interface com.atlassian.bonnie.Searchable
Overrides:
getSearchableDependants in class ContentEntityObject

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:
isIndexable in interface com.atlassian.bonnie.Searchable
Overrides:
isIndexable in class ContentEntityObject

getDownloadPath

public String getDownloadPath()
Specified by:
getDownloadPath in interface com.atlassian.bonnie.search.SearchableAttachment

getDownloadPathWithoutVersion

public String getDownloadPathWithoutVersion()
Returns the download path without any version info.

Returns:

getDownloadPath

public String getDownloadPath(String attachmentPath,
                              boolean addVersionInfo)
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.

Parameters:
attachmentPath -
addVersionInfo -
Returns:

getDownloadPathWithoutEncoding

public String getDownloadPathWithoutEncoding()

getExportPath

public String getExportPath()

getExportPathForThumbnail

public String getExportPathForThumbnail()

getContentsAsStream

@Deprecated
public InputStream getContentsAsStream()
                                throws IOException
Deprecated. since 5.5. Use AttachmentManager.getAttachmentData(Attachment)

Specified by:
getContentsAsStream in interface com.atlassian.bonnie.search.SearchableAttachment
Throws:
IOException

toString

public String toString()
Overrides:
toString in class ContentEntityObject

getNameForComparison

public String getNameForComparison()
Description copied from class: ContentEntityObject
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.

Specified by:
getNameForComparison in class ContentEntityObject

equals

public boolean equals(Object o)
Overrides:
equals in class ContentEntityObject

hashCode

public int hashCode()
Overrides:
hashCode in class ContentEntityObject

getFileExtension

public String 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

public static String getDescriptionForMimeType(String mimeType,
                                               String fileExtension)
Parameters:
mimeType - the mime type to be described. Should not be null
fileExtension - 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

public Space getSpace()
Specified by:
getSpace in interface Spaced
Returns:
the space of the owning content if it can be associated with a space (i.e. of type Spaced), or null otherwise.

getLinkWikiMarkup

public String getLinkWikiMarkup()
Specified by:
getLinkWikiMarkup in interface HasLinkWikiMarkup
Returns:
the wiki markup used to link to this content

getImageDetailsDTO

protected Collection getImageDetailsDTO()
accessor methods provided for hibernate proxy use only. use ImageDetailsManager.getImageDetails(Attachment attachment)


setImageDetailsDTO

protected void setImageDetailsDTO(Set imageDetailDTOs)

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class ContentEntityObject
Throws:
CloneNotSupportedException

copy

public Attachment copy()

getVersionChildPolicy

public VersionChildOwnerPolicy getVersionChildPolicy(ContentType contentType)
Description copied from interface: Versioned
Returns the right 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

Specified by:
getVersionChildPolicy in interface Versioned
Overrides:
getVersionChildPolicy in class AbstractVersionedEntityObject

getContentTypeObject

public ContentType getContentTypeObject()
Specified by:
getContentTypeObject in interface ContentConvertible
Returns:
the api ContentType that this ContentConvertible converts to

getContentId

public ContentId getContentId()
Description copied from class: ContentEntityObject
Returns the ContentId for this entity object, if it implements ContentConvertible.

Subclasses implementing ContentConvertible must override this method.

Specified by:
getContentId in interface ContentConvertible
Overrides:
getContentId in class ContentEntityObject
Returns:
the ContentId representation of this object's id

shouldConvertToContent

public boolean shouldConvertToContent()
Specified by:
shouldConvertToContent in interface ContentConvertible
Returns:
true if the implementer wants to be part of the core API (default value), false otherwise


Copyright © 2003–2015 Atlassian. All rights reserved.