com.atlassian.confluence.core
Class ContentEntityObject

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
All Implemented Interfaces:
com.atlassian.bonnie.Searchable, Content, Addressable, ContentTypeAware, Versioned, EditableLabelable, Labelable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
Comment, Draft, GlobalDescription, PageContentEntityObject, PersonalInformation, SpaceContentEntityObject

public abstract class ContentEntityObject
extends AbstractLabelableEntityObject
implements com.atlassian.bonnie.Searchable, java.lang.Comparable, Addressable, Content

See Also:
Serialized Form

Field Summary
static java.lang.String CREATED
           
static java.lang.String CURRENT
           
static java.lang.String DELETED
           
static java.lang.String MODIFIED
           
 
Fields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION
 
Constructor Summary
protected ContentEntityObject()
           
 
Method Summary
 void addAttachment(Attachment attachment)
           
 void addComment(Comment comment)
           
 void addOutgoingLink(OutgoingLink link)
           
 void addPermission(ContentPermission permission)
          Adds a ContentPermission.
 void addReferralLink(ReferralLink link)
           
 void addTrackbackLink(TrackbackLink link)
           
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Content entities are naturally ordered alphabetically by "comparison name", which depends on the entity (it's the title for pages, the parent page title for comments, etc.).
 void convertToHistoricalVersion()
          Remove all data from the object that does not need to be saved by historical versions.
protected  void ensureAttachmentBelongsToContent(Attachment attachment)
           
 boolean equals(java.lang.Object o)
           
 Attachment getAttachmentNamed(java.lang.String fileName)
           
 java.util.List<Attachment> getAttachments()
          Don't use it directly, use AttachmentManager.getAttachments(page) instead
 java.lang.String getAttachmentsUrlPath()
           
 java.lang.String getAttachmentUrlPath(Attachment attachment)
          Gets the path relative to Confluence's base URL to view the given attachment in the context of this content (for example, highlighted in the content's list of attachments).
 java.lang.String getBodyAsString()
          Convenience method that returns the String representation of the content.
 java.lang.String getBodyAsStringWithoutMarkup()
           
 BodyContent getBodyContent()
          Gets the BodyContent object for this ContentEntityObject.
 BodyContent getBodyContent(BodyType expectedBodyType)
          Gets the BodyContent object for this ContentEntityObject or throws an UnsupportedOperationException if its body type is not the same as the supplied expectedBodyType.
 java.util.List<BodyContent> getBodyContents()
           
 java.util.List<Comment> getComments()
           
 ContentPermission getContentPermission(java.lang.String permissionType)
          Deprecated. since 2.6 - use getContentPermissionSet
 ContentPermissionSet getContentPermissionSet(java.lang.String type)
          Note, this method does not return ContentPermissions inherited from the Content's ancestry.
 java.lang.String getContentStatus()
           
 BodyType getDefaultBodyType()
           
 java.lang.String getDisplayTitle()
          Returns the display title.
 ContentEntityObject getEntity()
          Gets the ContentEntityObject that backs this piece of content.
 java.lang.String getExcerpt()
           
 java.lang.String getIdAsString()
           
 java.util.List<Attachment> getLatestVersionsOfAttachments()
          Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead
abstract  java.lang.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.
 java.util.List<OutgoingLink> getOutgoingLinks()
          An outgoing link is a link on this page to another confluence page.
It could also link to a website URL
These links are contained in the page content
They are refreshed each time the page is updated (LinkManager.updateOutgoingLinks())
 java.util.List<ContentPermission> getPermissions()
          Deprecated. since 2.6 - use getContentPermissionSet(String)
 java.util.List<ReferralLink> getReferralLinks()
           
 java.lang.String getRenderedVersionComment()
           
 java.util.Collection<com.atlassian.bonnie.Searchable> getSearchableDependants()
           
 java.lang.String getTitle()
           
 java.util.List<TrackbackLink> getTrackbackLinks()
           
abstract  java.lang.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.
 ContentTypeEnum getTypeEnum()
           
abstract  java.lang.String getUrlPath()
           
 UserAccessor getUserAccessor()
          Deprecated. since 4.0
 java.lang.String getVersionComment()
           
 boolean hasContentPermissions()
           
 int hashCode()
           
 boolean hasPermissions(java.lang.String type)
           
 boolean isCurrent()
           
 boolean isDeleted()
           
 boolean isIndexable()
          Content entity objects that are historical versions should not be indexed.
 boolean isRecentlyUpdatedFor(com.atlassian.user.User user)
          Deprecated. since 4.0. Use PageManager.isPageRecentlyUpdatedForUser(com.atlassian.confluence.pages.Page, com.atlassian.user.User) instead as this was only used for pages anyway.
 boolean isVersionCommentAvailable()
           
 void removeAttachment(Attachment attachment)
           
 void removeComment(Comment comment)
           
 void removeContentPermissionSet(ContentPermissionSet set)
          This method removes the given ContentPermissionSet from this CEO and disconnects the set from its owner.
 void removeOutgoingLink(OutgoingLink link)
           
 void removeReferralLink(ReferralLink link)
           
 void removeTrackbackLink(TrackbackLink link)
           
 void setAttachments(java.util.List<Attachment> attachments)
           
 void setBodyAsString(java.lang.String content)
          Convenience method that sets the content of this ContentEntityObject.
 void setBodyContent(BodyContent bodyContent)
          Sets the BodyContent object for this ContentEntityObject.
 void setBodyContents(java.util.List<BodyContent> bodyContents)
           
 void setComments(java.util.List<Comment> comments)
           
 void setContent(java.lang.String content)
          Deprecated. since 3.5 - replace calls with calls to setBodyAsString(String).
 void setContentStatus(java.lang.String contentStatus)
           
 void setOutgoingLinks(java.util.List<OutgoingLink> outgoingLinks)
           
 void setReferralLinks(java.util.List<ReferralLink> referralLinks)
           
 void setTitle(java.lang.String title)
           
 void setTrackbackLinks(java.util.List<TrackbackLink> trackbackLinks)
           
 void setUserAccessor(UserAccessor userAccessor)
          Deprecated. since 4.0
 void setVersionComment(java.lang.String versionComment)
           
 PageContext toPageContext()
          When the content is rendered, what context is it being rendered in?
 java.lang.String toString()
           
 void trash()
          places content in trash can
 
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

CURRENT

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

DELETED

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

CREATED

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

MODIFIED

public static final java.lang.String MODIFIED
See Also:
Constant Field Values
Constructor Detail

ContentEntityObject

protected ContentEntityObject()
Method Detail

getType

public abstract java.lang.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.

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
Returns:
the content type

getTypeEnum

public ContentTypeEnum getTypeEnum()

getIdAsString

public java.lang.String getIdAsString()

getDisplayTitle

public java.lang.String getDisplayTitle()
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
Returns:
the display title

getUrlPath

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

getAttachmentUrlPath

public java.lang.String getAttachmentUrlPath(Attachment attachment)
Gets the path relative to Confluence's base URL to view the given attachment in the context of this content (for example, highlighted in the content's list of attachments). Generally you will want to call Attachment.getUrlPath() instead of this method: if we ever implement view pages for individual attachments, that's the method that will be changed to point to them. The default implementation just returns the view page for this content.

Parameters:
attachment - one of this content's attachments
Returns:
the path relative to the base url to view the attachment in the context of this content.
Throws:
java.lang.IllegalArgumentException - if the attachment is not attached to this content

getTitle

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

setTitle

public void setTitle(java.lang.String title)

getDefaultBodyType

public BodyType getDefaultBodyType()

getBodyContent

public BodyContent getBodyContent()
Gets the BodyContent object for this ContentEntityObject. Although it appears that there may be a number of BodyContent objects attached to a ContentEntityObject, only one is ever used. If there are none currently attached, a new BodyContent object is created and returned. Any values set on the returned BodyContent will not be saved unless a call is made to setBodyContent(com.atlassian.confluence.core.BodyContent). Null is never returned.

This method should not normally be called directly unless, you need to be able to handle different body types. Use getBodyAsString() as you should normally be expecting only one type.

Returns:
the BodyContent.
See Also:
getBodyContent(BodyType)

getBodyContent

public BodyContent getBodyContent(BodyType expectedBodyType)
Gets the BodyContent object for this ContentEntityObject or throws an UnsupportedOperationException if its body type is not the same as the supplied expectedBodyType.

This method should not normally be called directly unless, you need to be able to handle different body types. Use getBodyAsString() and getBodyAsString() as you should normally be expecting only one type.

Parameters:
expectedBodyType - that can be handled by the caller.
Returns:
the BodyContent.
Throws:
java.lang.UnsupportedOperationException - if the BodyType of the content is not the expectedBodyType.
See Also:
getBodyContent()

setBodyContent

public void setBodyContent(BodyContent bodyContent)
Sets the BodyContent object for this ContentEntityObject.

This method should not normally be called directly unless, you need to be able to handle different body types. Use setBodyAsString(java.lang.String) as you should normally be expecting only one type.

Parameters:
bodyContent - to be set. If the supplied bodyContent or its body are null, the list of body contents are cleared.

getBodyAsString

public java.lang.String getBodyAsString()
Convenience method that returns the String representation of the content.

Returns:
the content.
Throws:
java.lang.UnsupportedOperationException - if the BodyType of the content is not the normal type (by default BodyType#XHTML) used by this ContentEntityObject.

setBodyAsString

public void setBodyAsString(java.lang.String content)
Convenience method that sets the content of this ContentEntityObject.

Parameters:
content - the String representation of the content.
Throws:
java.lang.UnsupportedOperationException - if the BodyType of the content is not the normal type (by default BodyType#XHTML) used by this ContentEntityObject.

setContent

@Deprecated
public void setContent(java.lang.String content)
Deprecated. since 3.5 - replace calls with calls to setBodyAsString(String).

This method converts wiki content to xhtml on the fly.


getBodyContents

public java.util.List<BodyContent> getBodyContents()

setBodyContents

public void setBodyContents(java.util.List<BodyContent> bodyContents)

getOutgoingLinks

public java.util.List<OutgoingLink> getOutgoingLinks()
An outgoing link is a link on this page to another confluence page.
It could also link to a website URL
These links are contained in the page content
They are refreshed each time the page is updated (LinkManager.updateOutgoingLinks())

Returns:
List of OutgoingLinks

setOutgoingLinks

public void setOutgoingLinks(java.util.List<OutgoingLink> outgoingLinks)

addOutgoingLink

public void addOutgoingLink(OutgoingLink link)

removeOutgoingLink

public void removeOutgoingLink(OutgoingLink link)

getReferralLinks

public java.util.List<ReferralLink> getReferralLinks()

setReferralLinks

public void setReferralLinks(java.util.List<ReferralLink> referralLinks)

addReferralLink

public void addReferralLink(ReferralLink link)

removeReferralLink

public void removeReferralLink(ReferralLink link)

getTrackbackLinks

public java.util.List<TrackbackLink> getTrackbackLinks()

setTrackbackLinks

public void setTrackbackLinks(java.util.List<TrackbackLink> trackbackLinks)

addTrackbackLink

public void addTrackbackLink(TrackbackLink link)

removeTrackbackLink

public void removeTrackbackLink(TrackbackLink link)

convertToHistoricalVersion

public void convertToHistoricalVersion()
Description copied from interface: Versioned
Remove all data from the object that does not need to be saved by historical versions. For versioned objects that are persisted, this includes removing associations with other persisted objects that may otherwise cause us to break the expected arity of the database relations.

When using Hibernate to persist versioned objects, take special care to null any field that might contain a Hibernate-persisted collection, as Hibernate does not allow two different persistent objects to refer to the same persisted collection at the same time.

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

equals

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

hashCode

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

toString

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

getNameForComparison

public abstract java.lang.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.


compareTo

public final int compareTo(java.lang.Object o)
Content entities are naturally ordered alphabetically by "comparison name", which depends on the entity (it's the title for pages, the parent page title for comments, etc.).

If the comparison names are identical, we fall back on creation dates. This ensures, for example, that comments are always listed after the pages they are contained in, and in posting order.

Note also: comparison does NOT agree with equals(). This makes using content entities within sets a little dangerous, but the chances of two things with the exact same name being created on exactly the same millisecond is probably pretty low.

Specified by:
compareTo in interface java.lang.Comparable

getSearchableDependants

public java.util.Collection<com.atlassian.bonnie.Searchable> getSearchableDependants()
Specified by:
getSearchableDependants in interface com.atlassian.bonnie.Searchable

toPageContext

public final PageContext toPageContext()
When the content is rendered, what context is it being rendered in?


isRecentlyUpdatedFor

@Deprecated
public boolean isRecentlyUpdatedFor(com.atlassian.user.User user)
Deprecated. since 4.0. Use PageManager.isPageRecentlyUpdatedForUser(com.atlassian.confluence.pages.Page, com.atlassian.user.User) instead as this was only used for pages anyway.

Returns true if the page has been created or modified since the user last logged in. If the user has no last login time, returns false. For an anonymous user returns false.

Parameters:
user -
Returns:
true if the page has been created or modified since the user's last login, false otherwise

isIndexable

public boolean isIndexable()
Content entity objects that are historical versions should not be indexed.

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

getPermissions

@Deprecated
public java.util.List<ContentPermission> getPermissions()
Deprecated. since 2.6 - use getContentPermissionSet(String)

Get all the permissions that apply to this content. Please do not modify the contents of this list!

Returns:
a list of all the permissions that apply to this content.

getContentPermission

@Deprecated
public ContentPermission getContentPermission(java.lang.String permissionType)
Deprecated. since 2.6 - use getContentPermissionSet

Gives back the first content permission of a specific type. Returns only the permission if it is set on this object and not inherited. Returns null if no permission can't be found.

Synchronized, as otherwise it was creating timing issues during the multi-threaded re-indexing.

Returns:
ContentPermission

getContentStatus

public java.lang.String getContentStatus()

setContentStatus

public void setContentStatus(java.lang.String contentStatus)

isCurrent

public boolean isCurrent()

isDeleted

public boolean isDeleted()

trash

public void trash()
places content in trash can


getAttachments

public java.util.List<Attachment> getAttachments()
Don't use it directly, use AttachmentManager.getAttachments(page) instead


getLatestVersionsOfAttachments

public java.util.List<Attachment> getLatestVersionsOfAttachments()
Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead


setAttachments

public void setAttachments(java.util.List<Attachment> attachments)

addAttachment

public void addAttachment(Attachment attachment)

removeAttachment

public void removeAttachment(Attachment attachment)

getBodyAsStringWithoutMarkup

public java.lang.String getBodyAsStringWithoutMarkup()

getExcerpt

public java.lang.String getExcerpt()

getAttachmentsUrlPath

public java.lang.String getAttachmentsUrlPath()

getAttachmentNamed

public Attachment getAttachmentNamed(java.lang.String fileName)

getVersionComment

public java.lang.String getVersionComment()

setVersionComment

public void setVersionComment(java.lang.String versionComment)

isVersionCommentAvailable

public boolean isVersionCommentAvailable()

getUserAccessor

@Deprecated
public UserAccessor getUserAccessor()
Deprecated. since 4.0


setUserAccessor

@Deprecated
public void setUserAccessor(UserAccessor userAccessor)
Deprecated. since 4.0


clone

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

getRenderedVersionComment

public java.lang.String getRenderedVersionComment()

getContentPermissionSet

public ContentPermissionSet getContentPermissionSet(java.lang.String type)
Note, this method does not return ContentPermissions inherited from the Content's ancestry.

Returns:
a set containing ContentPermissions of this type, or null if there are no content permissions explicitly set on this ContentEntityObject for the type.

hasPermissions

public boolean hasPermissions(java.lang.String type)
Returns:
true if this content entity object contains any ContentPermissions of the type specified

hasContentPermissions

public boolean hasContentPermissions()

addPermission

public void addPermission(ContentPermission permission)
Adds a ContentPermission. Do not add them manually via ContentPermissionSet.addContentPermission(ContentPermission). If possible use ContentPermissionManager.addContentPermission(com.atlassian.confluence.security.ContentPermission, ContentEntityObject) instead. Also note that as of Confluence 2.4 although methods have been added to facilitate having multiple ContentPermissions per page, Confluence does not yet properly support them (eg users permitted by them will not see the data in their searches)


removeContentPermissionSet

public void removeContentPermissionSet(ContentPermissionSet set)
This method removes the given ContentPermissionSet from this CEO and disconnects the set from its owner. This method should only be called by the DefaultContentPermissionManager. Note that as of Confluence 2.4 although methods have been added to facilitate having multiple ContentPermissions per page, Confluence does not yet properly support them (eg users permitted by them will not see the data in their searches)

See Also:
DefaultContentPermissionManager.removeContentPermission(com.atlassian.confluence.security.ContentPermission)

getComments

public java.util.List<Comment> getComments()

setComments

public void setComments(java.util.List<Comment> comments)

addComment

public void addComment(Comment comment)

removeComment

public void removeComment(Comment comment)

getEntity

public ContentEntityObject getEntity()
Description copied from interface: Content
Gets the ContentEntityObject that backs this piece of content.

Specified by:
getEntity in interface Content
Returns:
the persistent object behind this content

ensureAttachmentBelongsToContent

protected void ensureAttachmentBelongsToContent(Attachment attachment)


Copyright © 2003-2014 Atlassian. All Rights Reserved.