public abstract class

ContentEntityObject

extends AbstractLabelableEntityObject
implements Searchable Content Addressable Comparable<T>
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.core.ContentEntityObject
Known Direct Subclasses
Known Indirect Subclasses

Summary

Constants
String CREATED
String CURRENT
String DELETED
String MODIFIED
[Expand]
Inherited Constants
From class com.atlassian.confluence.core.AbstractVersionedEntityObject
Protected Constructors
ContentEntityObject()
Public Methods
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)
Object clone()
final int compareTo(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.
boolean equals(Object o)
Attachment getAttachmentNamed(String fileName)
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).
List<Attachment> getAttachments()
Don't use it directly, use AttachmentManager.getAttachments(page) instead
String getAttachmentsUrlPath()
String getBodyAsString()
Convenience method that returns the String representation of the content.
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.
List<BodyContent> getBodyContents()
List<Comment> getComments()
@Deprecated synchronized ContentPermission getContentPermission(String permissionType)
This method is deprecated. use getContentPermissionSet
ContentPermissionSet getContentPermissionSet(String type)
Note, this method does not return ContentPermissions inherited from the Content's ancestry.
String getContentStatus()
BodyType getDefaultBodyType()
String getDisplayTitle()
Returns the display title.
ContentEntityObject getEntity()
Gets the ContentEntityObject that backs this piece of content.
String getExcerpt()
String getIdAsString()
List<Attachment> getLatestVersionsOfAttachments()
Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead
abstract 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.
List<OutgoingLink> getOutgoingLinks()
An outgoing link is a link on this page to another confluence page.
@Deprecated List<ContentPermission> getPermissions()
This method is deprecated. use getContentPermissionSet(String)
List<ReferralLink> getReferralLinks()
String getRenderedVersionComment()
Collection<Searchable> getSearchableDependants()
String getTitle()
List<TrackbackLink> getTrackbackLinks()
abstract 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 String getUrlPath()
@Deprecated UserAccessor getUserAccessor()
This method is deprecated. since 4.0
String getVersionComment()
boolean hasContentPermissions()
boolean hasPermissions(String type)
int hashCode()
boolean isCurrent()
boolean isDeleted()
boolean isIndexable()
Content entity objects that are historical versions should not be indexed.
@Deprecated boolean isRecentlyUpdatedFor(User user)
This method is deprecated. since 4.0. Use 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(List<Attachment> attachments)
void setBodyAsString(String content)
Convenience method that sets the content of this ContentEntityObject.
void setBodyContent(BodyContent bodyContent)
Sets the BodyContent object for this ContentEntityObject.
void setBodyContents(List<BodyContent> bodyContents)
void setComments(List<Comment> comments)
@Deprecated void setContent(String content)
This method is deprecated. replace calls with calls to setBodyAsString(String).
void setContentStatus(String contentStatus)
void setOutgoingLinks(List<OutgoingLink> outgoingLinks)
void setReferralLinks(List<ReferralLink> referralLinks)
void setTitle(String title)
void setTrackbackLinks(List<TrackbackLink> trackbackLinks)
@Deprecated void setUserAccessor(UserAccessor userAccessor)
This method is deprecated. since 4.0
void setVersionComment(String versionComment)
final PageContext toPageContext()
When the content is rendered, what context is it being rendered in?
String toString()
void trash()
places content in trash can
Protected Methods
void ensureAttachmentBelongsToContent(Attachment attachment)
[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.confluence.content.Content
From interface com.atlassian.confluence.core.Addressable
From interface com.atlassian.confluence.core.ContentTypeAware
From interface com.atlassian.confluence.core.Versioned
From interface com.atlassian.confluence.labels.EditableLabelable
From interface com.atlassian.confluence.labels.Labelable
From interface java.lang.Comparable

Constants

public static final String CREATED

Constant Value: "created"

public static final String CURRENT

Constant Value: "current"

public static final String DELETED

Constant Value: "deleted"

public static final String MODIFIED

Constant Value: "modified"

Protected Constructors

protected ContentEntityObject ()

Public Methods

public void addAttachment (Attachment attachment)

public void addComment (Comment comment)

public void addOutgoingLink (OutgoingLink link)

public void addPermission (ContentPermission permission)

Adds a ContentPermission. Do not add them manually via addContentPermission(ContentPermission). If possible use 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)

public void addReferralLink (ReferralLink link)

public void addTrackbackLink (TrackbackLink link)

public Object clone ()

public final int compareTo (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.

public void convertToHistoricalVersion ()

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.

public boolean equals (Object o)

public Attachment getAttachmentNamed (String fileName)

public 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 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
IllegalArgumentException if the attachment is not attached to this content

public List<Attachment> getAttachments ()

Don't use it directly, use AttachmentManager.getAttachments(page) instead

public String getAttachmentsUrlPath ()

public String getBodyAsString ()

Convenience method that returns the String representation of the content.

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

public String getBodyAsStringWithoutMarkup ()

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

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
UnsupportedOperationException if the BodyType of the content is not the expectedBodyType.
See Also

public List<BodyContent> getBodyContents ()

public List<Comment> getComments ()

@Deprecated public synchronized ContentPermission getContentPermission (String permissionType)

This method is deprecated.
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

public ContentPermissionSet getContentPermissionSet (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.

public String getContentStatus ()

public BodyType getDefaultBodyType ()

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

Returns
  • the display title

public ContentEntityObject getEntity ()

Gets the ContentEntityObject that backs this piece of content.

Returns
  • the persistent object behind this content

public String getExcerpt ()

public String getIdAsString ()

public List<Attachment> getLatestVersionsOfAttachments ()

Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead

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

public 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

@Deprecated public List<ContentPermission> getPermissions ()

This method is deprecated.
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.

public List<ReferralLink> getReferralLinks ()

public String getRenderedVersionComment ()

public Collection<Searchable> getSearchableDependants ()

public String getTitle ()

public List<TrackbackLink> getTrackbackLinks ()

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

public ContentTypeEnum getTypeEnum ()

public abstract String getUrlPath ()

@Deprecated public UserAccessor getUserAccessor ()

This method is deprecated.
since 4.0

public String getVersionComment ()

public boolean hasContentPermissions ()

public boolean hasPermissions (String type)

Returns
  • true if this content entity object contains any ContentPermissions of the type specified

public int hashCode ()

public boolean isCurrent ()

public boolean isDeleted ()

public boolean isIndexable ()

Content entity objects that are historical versions should not be indexed.

@Deprecated public boolean isRecentlyUpdatedFor (User user)

This method is deprecated.
since 4.0. Use 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.

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

public boolean isVersionCommentAvailable ()

public void removeAttachment (Attachment attachment)

public void removeComment (Comment comment)

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)

public void removeOutgoingLink (OutgoingLink link)

public void removeReferralLink (ReferralLink link)

public void removeTrackbackLink (TrackbackLink link)

public void setAttachments (List<Attachment> attachments)

public void setBodyAsString (String content)

Convenience method that sets the content of this ContentEntityObject.

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

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

public void setBodyContents (List<BodyContent> bodyContents)

public void setComments (List<Comment> comments)

@Deprecated public void setContent (String content)

This method is deprecated.
replace calls with calls to setBodyAsString(String).

This method converts wiki content to xhtml on the fly.

public void setContentStatus (String contentStatus)

public void setOutgoingLinks (List<OutgoingLink> outgoingLinks)

public void setReferralLinks (List<ReferralLink> referralLinks)

public void setTitle (String title)

public void setTrackbackLinks (List<TrackbackLink> trackbackLinks)

@Deprecated public void setUserAccessor (UserAccessor userAccessor)

This method is deprecated.
since 4.0

public void setVersionComment (String versionComment)

public final PageContext toPageContext ()

When the content is rendered, what context is it being rendered in?

public String toString ()

public void trash ()

places content in trash can

Protected Methods

protected void ensureAttachmentBelongsToContent (Attachment attachment)