public class

Attachment

extends AbstractLabelableEntityObject
implements SearchableAttachment Addressable HasLinkWikiMarkup Spaced
java.lang.Object
   ↳ com.atlassian.core.bean.EntityObject
     ↳ com.atlassian.confluence.core.ConfluenceEntityObject
       ↳ com.atlassian.confluence.core.AbstractVersionedEntityObject
         ↳ com.atlassian.confluence.core.AbstractLabelableEntityObject
           ↳ com.atlassian.confluence.pages.Attachment

Summary

Nested Classes
enum Attachment.Type An enum of basic Attachment types with a text description of each type. 
Constants
String CONTENT_TYPE
String PROFILE_PICTURE_COMMENT
[Expand]
Inherited Constants
From class com.atlassian.confluence.core.AbstractVersionedEntityObject
Public Constructors
Attachment()
Attachment(String fileName, String contentType, long fileSize, String comment)
Constructs a new Attachment.
Public Methods
Object clone()
Attachment copy()
boolean equals(Object o)
Integer getAttachmentVersion()
String getComment()
ContentEntityObject getContent()
The object to which the attachment is attached.
String getContentType()
InputStream getContentsAsStream()
static String getDescriptionForMimeType(String mimeType, String fileExtension)
String getDisplayTitle()
String getDownloadPath()
String getDownloadPathWithoutEncoding()
String getDownloadPathWithoutVersion()
String getExportPath()
String getExportPathForThumbnail()
String getFileExtension()
Returns the file extension of the attachment.
String getFileName()
long getFileSize()
String getLinkWikiMarkup()
String getNiceFileSize()
String getNiceType()
Collection getSearchableDependants()
Space getSpace()
String getTitle()
String getType()
String getUrlPath()
int hashCode()
boolean isIndexable()
Only the current version of an 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.
boolean isUserProfilePicture()
Determines whether the Attachment is a user's profile picture
void setAttachmentVersion(Integer attachmentVersion)
void setComment(String comment)
void setContent(ContentEntityObject content)
void setContentType(String contentType)
void setFileName(String fileName)
void setFileSize(long fileSize)
String toString()
Protected Methods
Collection getImageDetailsDTO()
accessor methods provided for hibernate proxy use only.
void setImageDetailsDTO(Set imageDetailDTOs)
[Expand]
Inherited Methods
From class com.atlassian.confluence.core.AbstractLabelableEntityObject
From class com.atlassian.confluence.core.AbstractVersionedEntityObject
From class com.atlassian.confluence.core.ConfluenceEntityObject
From class com.atlassian.core.bean.EntityObject
From class java.lang.Object
From interface com.atlassian.bonnie.Searchable
From interface com.atlassian.bonnie.search.SearchableAttachment
From interface com.atlassian.confluence.core.Addressable
From interface com.atlassian.confluence.core.ContentTypeAware
From interface com.atlassian.confluence.core.HasLinkWikiMarkup
From interface com.atlassian.confluence.core.Versioned
From interface com.atlassian.confluence.labels.EditableLabelable
From interface com.atlassian.confluence.labels.Labelable
From interface com.atlassian.confluence.spaces.Spaced

Constants

public static final String CONTENT_TYPE

Constant Value: "attachment"

public static final String PROFILE_PICTURE_COMMENT

Constant Value: "Uploaded Profile Picture"

Public Constructors

public Attachment ()

public Attachment (String fileName, String contentType, long fileSize, String comment)

Constructs a new Attachment.

Public Methods

public Object clone ()

public Attachment copy ()

public boolean equals (Object o)

public Integer getAttachmentVersion ()

public String getComment ()

public ContentEntityObject getContent ()

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

public String getContentType ()

public InputStream getContentsAsStream ()

Throws
IOException

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.

public String getDisplayTitle ()

public String getDownloadPath ()

public String getDownloadPathWithoutEncoding ()

public String getDownloadPathWithoutVersion ()

public String getExportPath ()

public String getExportPathForThumbnail ()

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

public String getFileName ()

public long getFileSize ()

public String getLinkWikiMarkup ()

public String getNiceFileSize ()

public String getNiceType ()

Returns
  • A nice type for this file if possible (eg "PDF" or "Word") - or null if no nice type can be recognised

public Collection getSearchableDependants ()

public Space getSpace ()

Returns
  • the space of the owning content if it can be associated with a space (i.e. of type Spaced), or null otherwise.

public String getTitle ()

public String getType ()

public String getUrlPath ()

public int hashCode ()

public boolean isIndexable ()

Only the current version of an 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.

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

public void setAttachmentVersion (Integer attachmentVersion)

public void setComment (String comment)

public void setContent (ContentEntityObject content)

public void setContentType (String contentType)

public void setFileName (String fileName)

public void setFileSize (long fileSize)

public String toString ()

Protected Methods

protected Collection getImageDetailsDTO ()

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

protected void setImageDetailsDTO (Set imageDetailDTOs)