public abstract class ContentEntityObject extends AbstractLabelableEntityObject implements com.atlassian.bonnie.Searchable, Comparable, Addressable, Content, RelatableEntity
Modifier and Type | Field and Description |
---|---|
static String |
COLLABORATIVE_EDITING_UUID
Contains the global UUID at the time Confluence was last restarted.
|
static String |
CONFLUENCE_RECOVERY |
static String |
CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE |
static String |
CONTENT_RESTORED_SYNC_REV_SOURCE |
static String |
CREATED |
static String |
CURRENT |
static String |
DELETED |
static String |
DRAFT
Constant used in
contentStatus to indicate that this object is a draft. |
static String |
DUMMY_SYNC_REV |
static String |
LIMITED_MODE_SYNC_REV_SOURCE |
static String |
MODIFIED |
static String |
SHARE_ID
Constant used to store a ContentProperty that allows shared access.
|
static String |
SYNC_REV
Constant used to store the Synchrony revision as a ContentProperty.
|
static String |
SYNC_REV_SOURCE
Constant used to store the status of the Synchrony revision as a ContentProperty.
|
static String |
SYNCHRONY_ACK_SYNC_REV_SOURCE |
static String |
SYNCHRONY_RECOVERY |
static String |
SYNCHRONY_RECOVERY_WITH_EXTERNAL_CHANGE |
static String |
SYNCHRONY_SYNC_REV_SOURCE |
INITIAL_VERSION
Modifier | Constructor and Description |
---|---|
protected |
ContentEntityObject() |
Modifier and Type | Method and Description |
---|---|
void |
addAttachment(Attachment attachment) |
void |
addComment(Comment comment) |
void |
addCustomContent(CustomContentEntityObject customContentEntityObject) |
void |
addOutgoingLink(OutgoingLink link) |
void |
addPermission(ContentPermission permission)
Adds a ContentPermission.
|
void |
addReferralLink(ReferralLink link) |
void |
addTrackbackLink(TrackbackLink link) |
void |
applyChildVersioningPolicy(Versioned versionToPromote,
ObjectDao dao)
If
Versioned.getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType) specifies so, moves content from versionToPromote to this Versioned instance or
makes no change. |
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.
|
protected void |
ensureAttachmentBelongsToContent(Attachment attachment) |
boolean |
equals(Object o) |
Attachment |
getAttachmentNamed(String fileName) |
List<Attachment> |
getAttachments()
Don't use it directly, use AttachmentManager.getAttachments(page) instead.
|
String |
getAttachmentsUrlPath() |
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).
|
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() |
String |
getCollaborativeEditingUuid() |
List<Comment> |
getComments() |
protected ContentEntityObject |
getContainerContent()
Implementing classes wanting to be
Contained in another CEO should
implement the Contained interface and delegate to this method |
ContentEntityObject |
getContentEntityObject()
Deprecated.
since 5.7. Use
getEntity() |
ContentId |
getContentId()
Returns the
ContentId for this entity object, if it implements ContentConvertible . |
ContentPermission |
getContentPermission(String permissionType)
Deprecated.
since 2.6 - use getContentPermissionSet
|
ContentPermissionSet |
getContentPermissionSet(String type)
Note, this method does not return ContentPermissions inherited from the Content's ancestry.
|
String |
getContentStatus()
Get the hibernate field for content status, distinguishing only draft/deleted/current status.
|
ContentStatus |
getContentStatusObject()
Get the api layer enum for content status, distinguishing CURRENT/HISTORICAL/DRAFT/TRASHED.
|
BodyType |
getDefaultBodyType() |
String |
getDisplayTitle()
Returns the display title.
|
ContentEntityObject |
getEntity()
Gets the ContentEntityObject that backs this piece of content.
|
String |
getExcerpt() |
String |
getIdAsString() |
long |
getLatestVersionId() |
List<Attachment> |
getLatestVersionsOfAttachments()
Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead.
|
String |
getLowerTitle() |
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.
|
Long |
getOriginalVersionId() |
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()) |
List<ContentPermission> |
getPermissions()
Deprecated.
since 2.6 - use
getContentPermissionSet(String) |
ContentProperties |
getProperties() |
List<ReferralLink> |
getReferralLinks() |
String |
getRenderedVersionComment() |
Collection<com.atlassian.bonnie.Searchable> |
getSearchableDependants() |
ContentSelector |
getSelector() |
String |
getShareId() |
String |
getSynchronyRevision() |
String |
getSynchronyRevisionSource() |
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() |
UserAccessor |
getUserAccessor()
Deprecated.
since 4.0
|
String |
getVersionComment() |
boolean |
hasContentPermissions() |
int |
hashCode() |
boolean |
hasPermissions(String type) |
boolean |
isCurrent()
Does this content have "current" status? (non-trashed and non-draft)
|
boolean |
isDeleted() |
boolean |
isDraft() |
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 |
isUnpublished() |
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 |
removeCustomContent(CustomContentEntityObject customContentEntityObject) |
void |
removeOutgoingLink(OutgoingLink link) |
void |
removeReferralLink(ReferralLink link) |
void |
removeTrackbackLink(TrackbackLink link) |
protected void |
replaceContentProperties(ContentProperties propertiesToClone)
Clones the supplied properties and sets these as the properties of the current ContentEntityObject.
|
void |
restore()
restores content from the trash
|
protected void |
restoreDependents() |
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 |
setCollaborativeEditingUuid(String uuid) |
void |
setComments(List<Comment> comments) |
protected void |
setContainerContent(ContentEntityObject container) |
void |
setContentPropertiesFrom(ContentEntityObject ceo)
Initialises the
ContentProperties of this ContentEntityObject by performing
a deep clone of the ContentEntityObject object's properties. |
void |
setContentStatus(String contentStatus)
Set the hibernate field for content status, distinguishing only draft/deleted/current status.
|
void |
setOriginalVersion(Versioned originalVersion)
Set the current version of this object.
|
protected void |
setOriginalVersionId(Long originalVersionId)
For Hibernate
|
void |
setOutgoingLinks(List<OutgoingLink> outgoingLinks) |
void |
setReferralLinks(List<ReferralLink> referralLinks) |
void |
setShareId(String shareId) |
void |
setSynchronyRevision(String synchronyRevision) |
void |
setSynchronyRevisionSource(String synchronyRevisionSource) |
void |
setTitle(String title) |
void |
setTrackbackLinks(List<TrackbackLink> trackbackLinks) |
void |
setUserAccessor(UserAccessor userAccessor)
Deprecated.
since 4.0
|
void |
setVersionComment(String versionComment) |
boolean |
sharedAccessAllowed(String shareId)
Deprecated.
since 5.10
|
boolean |
sharedAccessAllowed(com.atlassian.user.User user)
Checks if this draft can be accessed by users other than the creator (shared access)
|
PageContext |
toPageContext()
When the content is rendered, what context is it being rendered in?
|
String |
toString() |
void |
trash()
places content in trash can
|
protected void |
trashDependents() |
boolean |
wasCreatedBy(com.atlassian.user.User user) |
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getLabelUtil, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, isFavourite, removeLabelling, setLabellings
getConfluenceRevision, getLatestVersion, getOriginalVersion, getVersion, getVersionChildPolicy, isLatestVersion, isNew, setVersion
getCreator, getCreatorName, getLastModifier, getLastModifierName, getRealClass, isPersistent, setCreator, setCreatorName, setLastModifier, setLastModifierName
getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
finalize, getClass, notify, notifyAll, wait, wait, wait
getId
getId, isPersistent
public static final String CURRENT
public static final String DELETED
public static final String CREATED
public static final String MODIFIED
public static final String DRAFT
contentStatus
to indicate that this object is a draft.
Drafts for existing objects use AbstractVersionedEntityObject.originalVersion
to point to the object they are drafts of and,
unless stated otherwise, there should be only one draft per object, which is shared between all users.
Drafts for existing objects are considered automatically shared according to the permissions set, but drafts for new objects are considered private, so if a user is trying to access one of them it should be verified that is doing so with the proper share id in addition to permissions.
public static final String SHARE_ID
Used for sharing drafts.
DRAFT
,
Constant Field Valuespublic static final String SYNC_REV
public static final String DUMMY_SYNC_REV
public static final String SYNC_REV_SOURCE
public static final String COLLABORATIVE_EDITING_UUID
public static final String LIMITED_MODE_SYNC_REV_SOURCE
public static final String SYNCHRONY_SYNC_REV_SOURCE
public static final String SYNCHRONY_ACK_SYNC_REV_SOURCE
public static final String CONTENT_RESTORED_SYNC_REV_SOURCE
public static final String CONFLUENCE_RECOVERY
public static final String CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE
public static final String SYNCHRONY_RECOVERY
public static final String SYNCHRONY_RECOVERY_WITH_EXTERNAL_CHANGE
@Deprecated public ContentEntityObject getContentEntityObject()
getEntity()
public abstract String getType()
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.
getType
in interface ContentTypeAware
public ContentTypeEnum getTypeEnum()
public String getIdAsString()
public String getDisplayTitle()
getDisplayTitle
in interface Addressable
public abstract String getUrlPath()
getUrlPath
in interface Addressable
public String getAttachmentUrlPath(Attachment attachment)
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.
attachment
- one of this content's attachmentsIllegalArgumentException
- if the attachment is not attached to this contentpublic String getTitle()
getTitle
in interface EditableLabelable
public void setTitle(String title)
public String getLowerTitle()
public BodyType getDefaultBodyType()
public BodyContent getBodyContent()
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.
getBodyContent(BodyType)
public BodyContent getBodyContent(BodyType expectedBodyType)
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.
expectedBodyType
- that can be handled by the caller.UnsupportedOperationException
- if the BodyType of the content is not the expectedBodyType
.getBodyContent()
public void setBodyContent(BodyContent bodyContent)
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.
bodyContent
- to be set. If the supplied bodyContent or its body are null
, the list of body
contents are cleared.public String getBodyAsString()
UnsupportedOperationException
- if the BodyType of the content is not the normal type (by default
BodyType#XHTML
) used by this ContentEntityObject.public void setBodyAsString(String content)
content
- the String representation of the content.UnsupportedOperationException
- if the BodyType of the content is not the normal type (by default
BodyType#XHTML
) used by this ContentEntityObject.public List<BodyContent> getBodyContents()
public void setBodyContents(List<BodyContent> bodyContents)
public List<OutgoingLink> getOutgoingLinks()
public void setOutgoingLinks(List<OutgoingLink> outgoingLinks)
public void addOutgoingLink(OutgoingLink link)
public void removeOutgoingLink(OutgoingLink link)
public List<ReferralLink> getReferralLinks()
public void setReferralLinks(List<ReferralLink> referralLinks)
public void addReferralLink(ReferralLink link)
public void removeReferralLink(ReferralLink link)
public List<TrackbackLink> getTrackbackLinks()
public void setTrackbackLinks(List<TrackbackLink> trackbackLinks)
public void addTrackbackLink(TrackbackLink link)
public void removeTrackbackLink(TrackbackLink link)
public void setOriginalVersion(Versioned originalVersion)
Versioned
setOriginalVersion
in interface Versioned
setOriginalVersion
in class AbstractVersionedEntityObject
originalVersion
- the current version of this object.public void convertToHistoricalVersion()
Versioned
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.
convertToHistoricalVersion
in interface Versioned
convertToHistoricalVersion
in class AbstractVersionedEntityObject
public void applyChildVersioningPolicy(Versioned versionToPromote, ObjectDao dao)
Versioned
Versioned.getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or
makes no change.applyChildVersioningPolicy
in interface Versioned
applyChildVersioningPolicy
in class AbstractVersionedEntityObject
versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained contentpublic boolean equals(Object o)
equals
in class com.atlassian.core.bean.EntityObject
public int hashCode()
hashCode
in class com.atlassian.core.bean.EntityObject
public abstract String getNameForComparison()
public final int compareTo(Object o)
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.
compareTo
in interface Comparable
public Collection<com.atlassian.bonnie.Searchable> getSearchableDependants()
getSearchableDependants
in interface com.atlassian.bonnie.Searchable
public final PageContext toPageContext()
@Deprecated public boolean isRecentlyUpdatedFor(com.atlassian.user.User user)
PageManager.isPageRecentlyUpdatedForUser(com.atlassian.confluence.pages.Page, com.atlassian.user.User)
instead as this was only used for pages anyway.user
- public boolean isIndexable()
isIndexable
in interface com.atlassian.bonnie.Searchable
@Deprecated public List<ContentPermission> getPermissions()
getContentPermissionSet(String)
Get all the permissions that apply to this content. Please do not modify the contents of this list!
@Deprecated public ContentPermission getContentPermission(String permissionType)
Synchronized, as otherwise it was creating timing issues during the multi-threaded re-indexing.
@Deprecated public boolean sharedAccessAllowed(String shareId)
IMPORTANT NOTE: if shared access is disallowed it prevails over permissions (only creator has access), BUT if it is allowed normal permissions still need to be checked
Drafts for existing objects are considered automatically shared according to the permissions set, but drafts for new objects are considered private, so if a user if trying to access one of them it should be verified that is doing so with the proper share id in addition to permissions.
shareId
- Optional. Used to check for access if neededTODO: delete this method after 6.0
public ContentStatus getContentStatusObject()
Important: this has different semantics from the hibernate field getContentStatus()
,
because it takes into account historical status, and uses different strings for some values.
for the hibernate field value, different semantics
public String getContentStatus()
Important: this is not the same as the string value of the api getContentStatusObject()
,
because that one takes into account historical status, and uses different strings for some values.
This method does NOT distinguish current and historical versions. Both will return "current".
See AbstractVersionedEntityObject.isLatestVersion()
to distinguish them.
CURRENT
, DRAFT
, DELETED
.for the API enum, different semantics
public void setContentStatus(String contentStatus)
Important: this is not the same as the string value of the api getContentStatusObject()
,
because that one takes into account historical status, and uses different strings for some values.
This method does NOT distinguish current and historical versions. Both use "current".
See AbstractVersionedEntityObject.isLatestVersion()
to distinguish them.
contentStatus
- the hibernate field value, CURRENT
, DRAFT
, DELETED
.for the API enum, different semantics
public boolean isCurrent()
This method does NOT distinguish current and historical versions. Both will return true.
See AbstractVersionedEntityObject.isLatestVersion()
to distinguish them.
AbstractVersionedEntityObject.isLatestVersion()
public boolean isDeleted()
public boolean isDraft()
public boolean sharedAccessAllowed(com.atlassian.user.User user)
IMPORTANT NOTE: if shared access is disallowed it prevails over permissions (only creator has access), BUT if it is allowed normal permissions still need to be checked
Drafts for existing objects are considered automatically shared according to the permissions set, but drafts that have never been published are considered private even without permissions set, so if a user if trying to access one of them it should be verified that is doing so with the proper share id in addition to permissions.
user
- User to checkSHARE_ID
,
SharedAccessInterceptor
,
AbstractCreateAndEditPageAction.hasDraftPermission()
public String getSynchronyRevisionSource()
SYNC_REV_SOURCE
public void setSynchronyRevisionSource(String synchronyRevisionSource)
SYNC_REV_SOURCE
public String getCollaborativeEditingUuid()
COLLABORATIVE_EDITING_UUID
public void setCollaborativeEditingUuid(String uuid)
COLLABORATIVE_EDITING_UUID
public boolean isUnpublished()
public boolean wasCreatedBy(com.atlassian.user.User user)
public void trash()
protected void trashDependents()
public void restore()
protected void restoreDependents()
public List<Attachment> getAttachments()
Don't use it directly, use AttachmentManager.getAttachments(page) instead.
This also includes trashed items.
public List<Attachment> getLatestVersionsOfAttachments()
Don't use it directly, use AttachmentManager.getLatestVersionsOfAttachments(page) instead.
This does not include trashed items.
public void setAttachments(List<Attachment> attachments)
public void addAttachment(Attachment attachment)
public void removeAttachment(Attachment attachment)
public String getBodyAsStringWithoutMarkup()
public String getExcerpt()
public String getAttachmentsUrlPath()
public Attachment getAttachmentNamed(String fileName)
public String getVersionComment()
public void setVersionComment(String versionComment)
public boolean isVersionCommentAvailable()
@Deprecated public UserAccessor getUserAccessor()
@Deprecated public void setUserAccessor(UserAccessor userAccessor)
public Object clone()
clone
in class AbstractLabelableEntityObject
public String getRenderedVersionComment()
public ContentPermissionSet getContentPermissionSet(String type)
ContentPermission
s of this type, or null if there are no content permissions
explicitly set on this ContentEntityObject for the type.public boolean hasPermissions(String type)
ContentPermission
s of the type specifiedpublic boolean hasContentPermissions()
public void addPermission(ContentPermission permission)
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)public void removeContentPermissionSet(ContentPermissionSet set)
public void addComment(Comment comment)
public void removeComment(Comment comment)
public void addCustomContent(CustomContentEntityObject customContentEntityObject)
public void removeCustomContent(CustomContentEntityObject customContentEntityObject)
public ContentEntityObject getEntity()
Content
protected void ensureAttachmentBelongsToContent(Attachment attachment)
public ContentId getContentId()
ContentId
for this entity object, if it implements ContentConvertible
.
Subclasses implementing ContentConvertible must override this method.
UnsupportedOperationException
- if the instance doesn't implement ContentConvertiblepublic ContentSelector getSelector()
public ContentProperties getProperties()
@Nullable protected ContentEntityObject getContainerContent()
Contained
in another CEO should
implement the Contained interface and delegate to this methodprotected void setContainerContent(@Nullable ContentEntityObject container)
protected void replaceContentProperties(ContentProperties propertiesToClone)
This method should be used instead of directly modifying the contentProperties field, to avoid swapping collections that have Hibernate associations. Doing so would result in the following error: You may not dereference a collection with cascade="all-delete-orphan".
public void setContentPropertiesFrom(ContentEntityObject ceo)
ContentProperties
of this ContentEntityObject by performing
a deep clone of the ContentEntityObject
object's properties.public Long getOriginalVersionId()
protected void setOriginalVersionId(@Nullable Long originalVersionId)
public long getLatestVersionId()
Copyright © 2003–2017 Atlassian. All rights reserved.