com.atlassian.confluence.core
Class ContentEntityObject

java.lang.Object
  extended bycom.atlassian.core.bean.EntityObject
      extended bycom.atlassian.confluence.core.ConfluenceEntityObject
          extended bycom.atlassian.confluence.core.AbstractVersionedEntityObject
              extended bycom.atlassian.confluence.core.ContentEntityObject
All Implemented Interfaces:
Addressable, Cloneable, Comparable, Labelable, Searchable, Serializable, Versioned
Direct Known Subclasses:
PageContentEntityObject, PersonalInformation, SpaceContentEntityObject

public abstract class ContentEntityObject
extends AbstractVersionedEntityObject
implements Searchable, Comparable, Addressable, Labelable

See Also:
Serialized Form

Field Summary
static String CREATED
           
static String CURRENT
           
static String DELETED
           
static String MODIFIED
           
 
Constructor Summary
protected ContentEntityObject()
           
 
Method Summary
 void addAttachment(Attachment attachment)
           
 void addLabelling(Labelling content)
           
 void addOutgoingLink(OutgoingLink link)
           
 void addPermission(ContentPermission permission)
          Adds a ContentPermission.
 void addReferralLink(ReferralLink link)
           
 void addTrackbackLink(TrackbackLink link)
           
 Object clone()
           
 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)
           
 List getAttachments()
          Don't use it directly, use AttachmentManager.getAttachments(page) instead
 String getAttachmentsUrlPath()
           
 List getBodyContents()
           
 String getContent()
           
 ContentPermission getContentPermission(String permissionType)
          Deprecated. use getContentPermissionSet
 ContentPermissionSet getContentPermissionSet(String type)
          Note, this method does not return ContentPermissions inherited from the Content's ancestry.
 String getContentStatus()
           
 String getExcerpt()
           
 List getGlobalLabels(User user)
          List the labels on this content that are global labels
 String getIdAsString()
           
 int getLabelCount()
          Get the number of labels that are associated with this object.
 List getLabellings()
           
 List getLabels()
          Retrieve the labels that are associated with this object.
 List getLabelsForDisplay(User user)
          List the labels on this content that are visible to a particular user, and should be shown in a list of labels.
 LabelUtil getLabelUtil()
           
 List getLatestVersionsOfAttachments()
          Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead
protected abstract  org.apache.log4j.Category getLog()
           
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 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())
 List getPermissions()
          Deprecated. use getContentPermissionSet(String)
 List getPersonalLabels(User user)
          List the labels on this content that are personal labels for a particular user
 String getRealTitle()
           
 List getReferralLinks()
           
 String getRenderedVersionComment()
           
 Collection getSearchableDependants()
           
 String getTitle()
           
 List 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.
abstract  String getUrlPath()
           
 UserAccessor getUserAccessor()
           
 String getVersionComment()
           
 List getVisibleLabels(User user)
          List the labels on this content that are visible to a particular user
 int hashCode()
           
 boolean hasPermissions(String type)
           
 boolean isCurrent()
           
 boolean isDeleted()
           
 boolean isFavourite(User user)
          Is this object marked as somebody's favourite?
 boolean isIndexable()
          Content entity objects that are historical versions should not be indexed.
 boolean isRecentlyUpdatedFor(User user)
          Returns true if the page has been created or modified since the user last logged in.
 boolean isVersionCommentAvailable()
           
 void removeAttachment(Attachment attachment)
           
 void removeContentPermissionSet(ContentPermissionSet set)
          This method removes the given ContentPermissionSet from this CEO and disconnects the set from its owner.
 void removeLabelling(Labelling labelling)
           
 void removeOutgoingLink(OutgoingLink link)
           
 void removeReferralLink(ReferralLink link)
           
 void removeTrackbackLink(TrackbackLink link)
           
 void setAttachments(List attachments)
           
 void setBodyContents(List bodyContents)
           
 void setContent(String content)
           
 void setContentStatus(String contentStatus)
           
 void setOutgoingLinks(List outgoingLinks)
           
 void setReferralLinks(List referralLinks)
           
 void setTitle(String title)
           
 void setTrackbackLinks(List trackbackLinks)
           
 void setUserAccessor(UserAccessor userAccessor)
           
 void setVersionComment(String versionComment)
           
 PageContext toPageContext()
          When the content is rendered, what context is it being rendered in?
 String toString()
           
 void trash()
          places content in trash can
 
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
getCreatorName, getLastModifierName, 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
 

Field Detail

CURRENT

public static final String CURRENT
See Also:
Constant Field Values

DELETED

public static final String DELETED
See Also:
Constant Field Values

CREATED

public static final String CREATED
See Also:
Constant Field Values

MODIFIED

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

ContentEntityObject

protected ContentEntityObject()
Method Detail

getType

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.

Specified by:
getType in interface Addressable

getIdAsString

public String getIdAsString()

getRealTitle

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

getUrlPath

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

getTitle

public String getTitle()

setTitle

public void setTitle(String title)

getContent

public String getContent()

setContent

public void setContent(String content)

getBodyContents

public List getBodyContents()

setBodyContents

public void setBodyContents(List bodyContents)

getOutgoingLinks

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

setOutgoingLinks

public void setOutgoingLinks(List outgoingLinks)

addOutgoingLink

public void addOutgoingLink(OutgoingLink link)

removeOutgoingLink

public void removeOutgoingLink(OutgoingLink link)

getReferralLinks

public List getReferralLinks()

setReferralLinks

public void setReferralLinks(List referralLinks)

addReferralLink

public void addReferralLink(ReferralLink link)

removeReferralLink

public void removeReferralLink(ReferralLink link)

getTrackbackLinks

public List getTrackbackLinks()

setTrackbackLinks

public void setTrackbackLinks(List 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(Object o)

hashCode

public int hashCode()

toString

public String toString()

getNameForComparison

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.


compareTo

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.

Specified by:
compareTo in interface Comparable

getSearchableDependants

public Collection getSearchableDependants()
Specified by:
getSearchableDependants in interface Searchable

toPageContext

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


isRecentlyUpdatedFor

public boolean isRecentlyUpdatedFor(User user)
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.

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 Searchable

getPermissions

public List getPermissions()
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.

getContentPermission

public ContentPermission getContentPermission(String permissionType)
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.

Parameters:
permissionType -
Returns:
ContentPermission

getContentStatus

public String getContentStatus()

setContentStatus

public void setContentStatus(String contentStatus)

isCurrent

public boolean isCurrent()

isDeleted

public boolean isDeleted()

trash

public void trash()
places content in trash can


getAttachments

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


getLatestVersionsOfAttachments

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


setAttachments

public void setAttachments(List attachments)

addAttachment

public void addAttachment(Attachment attachment)

removeAttachment

public void removeAttachment(Attachment attachment)

getExcerpt

public String getExcerpt()

getLog

protected abstract org.apache.log4j.Category getLog()
Returns:
The category to log for this class

getAttachmentsUrlPath

public String getAttachmentsUrlPath()

getAttachmentNamed

public Attachment getAttachmentNamed(String fileName)

getLabellings

public List getLabellings()

addLabelling

public void addLabelling(Labelling content)

removeLabelling

public void removeLabelling(Labelling labelling)

getLabels

public List getLabels()
Description copied from interface: Labelable
Retrieve the labels that are associated with this object.

Specified by:
getLabels in interface Labelable
Returns:
a list of label instances.

getLabelCount

public int getLabelCount()
Description copied from interface: Labelable
Get the number of labels that are associated with this object.

Specified by:
getLabelCount in interface Labelable
Returns:
the number of labels associated with this object.

isFavourite

public boolean isFavourite(User user)
Description copied from interface: Labelable
Is this object marked as somebody's favourite?

Specified by:
isFavourite in interface Labelable
Parameters:
user - the user who is being checked against. If user is null this method must always return false (anonymous users can not mark anything as a favourite, obviously)
Returns:
true if the labelable object is a 'favourite' of a given user, false otherwise

getVisibleLabels

public List getVisibleLabels(User user)
List the labels on this content that are visible to a particular user

Parameters:
user - the user
Returns:
the labels on this content visible to that user

getPersonalLabels

public List getPersonalLabels(User user)
List the labels on this content that are personal labels for a particular user

Parameters:
user - the user
Returns:
the personal labels on this content visible to the user

getGlobalLabels

public List getGlobalLabels(User user)
List the labels on this content that are global labels

Parameters:
user - the user
Returns:
the personal labels on this content visible to the user

getLabelsForDisplay

public List getLabelsForDisplay(User user)
List the labels on this content that are visible to a particular user, and should be shown in a list of labels. This is like {code}getVisibleLabels{code} except that it also filters out special labels like favourites

Parameters:
user - the user
Returns:
the labels on this content visible to that user

getLabelUtil

public LabelUtil getLabelUtil()

getVersionComment

public String getVersionComment()

setVersionComment

public void setVersionComment(String versionComment)

isVersionCommentAvailable

public boolean isVersionCommentAvailable()

getUserAccessor

public UserAccessor getUserAccessor()

setUserAccessor

public void setUserAccessor(UserAccessor userAccessor)

clone

public Object clone()
             throws CloneNotSupportedException
Throws:
CloneNotSupportedException

getRenderedVersionComment

public String getRenderedVersionComment()

getContentPermissionSet

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.

hasPermissions

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

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)


Confluence is developed by Atlassian.