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, ContentConvertible, Spaced, java.io.Serializable, java.lang.Cloneable

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

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 java.lang.String API_REVISION
           
static java.lang.String API_REVISION_V2
           
static java.lang.String CONTENT_TYPE
           
static java.lang.String DOWNLOAD_PATH_BASE
          The download path for an attachment is composed with this base, see getDownloadPathWithoutEncoding() for an example.
static java.lang.String PROFILE_PICTURE_COMMENT
           
 
Fields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION
 
Constructor Summary
Attachment()
           
Attachment(java.lang.String fileName, java.lang.String contentType, long fileSize, java.lang.String comment)
          Constructs a new Attachment.
Attachment(java.lang.String fileName, java.lang.String contentType, long fileSize, java.lang.String comment, boolean minorEdit)
           
 
Method Summary
 java.lang.Object clone()
           
 Attachment copy()
           
 boolean equals(java.lang.Object o)
           
 java.lang.Integer getAttachmentVersion()
           
 java.lang.String getComment()
           
 ContentEntityObject getContent()
          The object to which the attachment is attached.
 ContentId getContentId()
           
 java.io.InputStream getContentsAsStream()
          Deprecated. since 5.5. Use AttachmentManager.getAttachmentData(Attachment)
 java.lang.String getContentType()
           
static java.lang.String getDescriptionForMimeType(java.lang.String mimeType, java.lang.String fileExtension)
           
 java.lang.String getDisplayTitle()
           
 java.lang.String getDownloadPath()
           
 java.lang.String getDownloadPath(java.lang.String attachmentPath, boolean addVersionInfo)
          Returns the download path of the attachment for a given attachmentPath prefix.
 java.lang.String getDownloadPathWithoutEncoding()
           
 java.lang.String getDownloadPathWithoutVersion()
          Returns the download path without any version info.
 java.lang.String getExportPath()
           
 java.lang.String getExportPathForThumbnail()
           
 java.lang.String getFileExtension()
          Returns the file extension of the attachment.
 java.lang.String getFileName()
           
 long getFileSize()
           
protected  java.util.Collection getImageDetailsDTO()
          accessor methods provided for hibernate proxy use only.
 java.lang.String getLinkWikiMarkup()
           
 java.lang.String getNiceFileSize()
           
 java.lang.String getNiceType()
           
 java.util.Collection getSearchableDependants()
           
 Space getSpace()
           
 java.lang.String getTitle()
           
 java.lang.String getType()
           
 java.lang.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 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(java.lang.Integer attachmentVersion)
           
 void setComment(java.lang.String comment)
           
 void setContent(ContentEntityObject content)
           
 void setContentType(java.lang.String contentType)
           
 void setFileName(java.lang.String fileName)
           
 void setFileSize(long fileSize)
           
protected  void setImageDetailsDTO(java.util.Set imageDetailDTOs)
           
 void setMinorEdit(boolean minorEdit)
           
 java.lang.String toString()
           
 
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
convertToHistoricalVersion, 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

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
See Also:
Constant Field Values

PROFILE_PICTURE_COMMENT

public static final java.lang.String PROFILE_PICTURE_COMMENT
See Also:
Constant Field Values

API_REVISION

public static final java.lang.String API_REVISION
See Also:
Constant Field Values

API_REVISION_V2

public static final java.lang.String API_REVISION_V2
See Also:
Constant Field Values

DOWNLOAD_PATH_BASE

public static final java.lang.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(java.lang.String fileName,
                  java.lang.String contentType,
                  long fileSize,
                  java.lang.String comment,
                  boolean minorEdit)

Attachment

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

Method Detail

getAttachmentVersion

public java.lang.Integer getAttachmentVersion()

setAttachmentVersion

public void setAttachmentVersion(java.lang.Integer attachmentVersion)

getFileName

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

setFileName

public void setFileName(java.lang.String fileName)

getContentType

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

setContentType

public void setContentType(java.lang.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 java.lang.String getComment()
Specified by:
getComment in interface com.atlassian.bonnie.search.SearchableAttachment

setComment

public void setComment(java.lang.String comment)

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)

getFileSize

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

setFileSize

public void setFileSize(long fileSize)

getNiceFileSize

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

getNiceType

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

getDisplayTitle

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

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface EditableLabelable

getUrlPath

public java.lang.String getUrlPath()
Specified by:
getUrlPath in interface Addressable

getSearchableDependants

public java.util.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 java.lang.String getDownloadPath()
Specified by:
getDownloadPath in interface com.atlassian.bonnie.search.SearchableAttachment

getDownloadPathWithoutVersion

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

Returns:

getDownloadPath

public java.lang.String getDownloadPath(java.lang.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 java.lang.String getDownloadPathWithoutEncoding()

getExportPath

public java.lang.String getExportPath()

getExportPathForThumbnail

public java.lang.String getExportPathForThumbnail()

getContentsAsStream

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

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

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

equals

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

getFileExtension

public java.lang.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 java.lang.String getDescriptionForMimeType(java.lang.String mimeType,
                                                         java.lang.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 java.lang.String getLinkWikiMarkup()
Specified by:
getLinkWikiMarkup in interface HasLinkWikiMarkup
Returns:
the wiki markup used to link to this content

getImageDetailsDTO

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


setImageDetailsDTO

protected void setImageDetailsDTO(java.util.Set imageDetailDTOs)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class AbstractLabelableEntityObject
Throws:
java.lang.CloneNotSupportedException

copy

public Attachment copy()

getContentId

public ContentId getContentId()
Specified by:
getContentId in interface ContentConvertible
Returns:
the ContentId identifying this Content-convertible entity.


Copyright © 2003-2014 Atlassian. All Rights Reserved.