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.pages.Attachment
All Implemented Interfaces:
com.atlassian.bonnie.search.SearchableAttachment, com.atlassian.bonnie.Searchable, Addressable, ContentTypeAware, HasLinkWikiMarkup, Versioned, EditableLabelable, Labelable, Spaced, Serializable, Cloneable

public class Attachment
extends AbstractLabelableEntityObject
implements com.atlassian.bonnie.search.SearchableAttachment, Addressable, Spaced, HasLinkWikiMarkup

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 PROFILE_PICTURE_COMMENT
           
 
Fields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION
 
Constructor Summary
Attachment()
           
Attachment(String fileName, String contentType, long fileSize, String comment)
          Constructs a new Attachment.
 
Method Summary
 Object clone()
           
 Attachment copy()
           
 boolean equals(Object o)
           
 Integer getAttachmentVersion()
           
 String getComment()
           
 ContentEntityObject getContent()
          The object to which the attachment is attached.
 InputStream getContentsAsStream()
           
 String getContentType()
           
static String getDescriptionForMimeType(String mimeType, String fileExtension)
           
 String getDisplayTitle()
           
 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 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)
           
protected  void setImageDetailsDTO(Set imageDetailDTOs)
           
 String toString()
           
 
Methods inherited from class com.atlassian.confluence.core.AbstractLabelableEntityObject
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getLabelUtil, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, removeLabelling, setLabellings
 
Methods inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
convertToHistoricalVersion, getLatestVersion, getOriginalVersion, getVersion, isLatestVersion, isNew, setOriginalVersion, setVersion
 
Methods inherited from class com.atlassian.confluence.core.ConfluenceEntityObject
getCreatorName, getLastModifierName, getRealClass, isPersistent, setCreatorName, 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

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
Constructor Detail

Attachment

public Attachment()

Attachment

public Attachment(String fileName,
                  String contentType,
                  long fileSize,
                  String comment)
Constructs a new Attachment.

Method Detail

getAttachmentVersion

public Integer getAttachmentVersion()

setAttachmentVersion

public void setAttachmentVersion(Integer attachmentVersion)

getFileName

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

setFileName

public void setFileName(String fileName)

getContentType

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

setContentType

public void setContentType(String contentType)

getContent

public ContentEntityObject getContent()
The object to which the attachment is attached. Eg the page or blog post to which its attached.


setContent

public void setContent(ContentEntityObject content)

getComment

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

setComment

public void setComment(String comment)

getFileSize

public long getFileSize()

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()
Specified by:
getType in interface ContentTypeAware
Returns:
the content type

getDisplayTitle

public String getDisplayTitle()
Specified by:
getDisplayTitle in interface Addressable
Returns:
the title of the addressable object, suitable for display in a list

getTitle

public String getTitle()
Specified by:
getTitle in interface EditableLabelable

getUrlPath

public String getUrlPath()
Specified by:
getUrlPath in interface Addressable

getSearchableDependants

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

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 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.

Specified by:
isIndexable in interface com.atlassian.bonnie.Searchable

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

public InputStream getContentsAsStream()
                                throws IOException
Specified by:
getContentsAsStream in interface com.atlassian.bonnie.search.SearchableAttachment
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class com.atlassian.core.bean.EntityObject

equals

public boolean equals(Object o)
Overrides:
equals in class com.atlassian.core.bean.EntityObject

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 AbstractLabelableEntityObject
Throws:
CloneNotSupportedException

copy

public Attachment copy()


Copyright © 2003-2013 Atlassian. All Rights Reserved.