Class ContentEntityObject
- 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
-
- All Implemented Interfaces:
Searchable
,Content
,Addressable
,ContentTypeAware
,Versioned
,RelatableEntity
,EditableLabelable
,Labelable
,Serializable
,Cloneable
,Comparable<ContentEntityObject>
- Direct Known Subclasses:
Comment
,Draft
,GlobalDescription
,PersonalInformation
,SpaceContentEntityObject
public abstract class ContentEntityObject extends AbstractLabelableEntityObject implements Searchable, Comparable<ContentEntityObject>, Addressable, Content, RelatableEntity
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field 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 incontentStatus
to indicate that this object is a draft.static String
DUMMY_SYNC_REV
static String
LIMITED_MODE_SYNC_REV_SOURCE
Deprecated.since 7.5.0.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
-
Fields inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
INITIAL_VERSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ContentEntityObject()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method 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
applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDaoInternal<?> dao)
IfVersioned.getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or makes no change.void
applyChildVersioningPolicy(Versioned versionToPromote, ObjectDao dao)
Deprecated.since 6.10.0.Object
clone()
int
compareTo(ContentEntityObject otherEntity)
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)
protected AttachmentManager
getAttachmentManager()
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 theBodyContent
object for this ContentEntityObject.BodyContent
getBodyContent(BodyType expectedBodyType)
Gets theBodyContent
object for this ContentEntityObject or throws an UnsupportedOperationException if its body type is not the same as the suppliedexpectedBodyType
.List<BodyContent>
getBodyContents()
String
getCollaborativeEditingUuid()
List<Comment>
getComments()
protected @Nullable ContentEntityObject
getContainerContent()
Implementing classes wanting to beContained
in another CEO should implement the Contained interface and delegate to this methodContentId
getContentId()
Returns theContentId
for this entity object, if it implementsContentConvertible
.ContentPermission
getContentPermission(String permissionType)
Deprecated.since 2.6 - use getContentPermissionSetContentPermissionSet
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.List<CustomContentEntityObject>
getCustomContent()
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()
Deprecated.Since 6.13.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 - usegetContentPermissionSet(String)
ContentProperties
getProperties()
String
getRenderedVersionComment()
Collection<Searchable>
getSearchableDependants()
When we un-index something (say, a page), we also need to un-index everything contained within that page (comments, attachments), because presumably they're all about to go away.ContentSelector
getSelector()
String
getShareId()
String
getSynchronyRevision()
String
getSynchronyRevisionSource()
String
getTitle()
Optional<Instant>
getTrashDate()
Get trash date if this CEO has been added to the trash since Confluence 7.14.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()
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
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)
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 trashprotected 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 theBodyContent
object for this ContentEntityObject.void
setBodyContents(List<BodyContent> bodyContents)
void
setCollaborativeEditingUuid(String uuid)
void
setComments(List<Comment> comments)
protected void
setContainerContent(@Nullable ContentEntityObject container)
void
setContentPropertiesFrom(ContentEntityObject ceo)
Initialises theContentProperties
of this ContentEntityObject by performing a deep clone of theContentEntityObject
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(@Nullable Long originalVersionId)
For Hibernatevoid
setOutgoingLinks(List<OutgoingLink> outgoingLinks)
void
setShareId(String shareId)
void
setSynchronyRevision(String synchronyRevision)
void
setSynchronyRevisionSource(String synchronyRevisionSource)
void
setTitle(String title)
void
setVersionComment(String versionComment)
boolean
sharedAccessAllowed(com.atlassian.user.User user)
Checks if this draft can be accessed by users other than the creator (shared access)boolean
sharedAccessAllowed(String shareId)
Deprecated.since 5.10PageContext
toPageContext()
When the content is rendered, what context is it being rendered in?String
toString()
void
trash()
places content in trash canprotected void
trash(long trashTimestamp)
protected void
trashDependents()
boolean
wasCreatedBy(com.atlassian.user.User user)
-
Methods inherited from class com.atlassian.confluence.core.AbstractLabelableEntityObject
addLabelling, getGlobalLabels, getLabelCount, getLabellings, getLabels, getLabelsForDisplay, getPersonalLabels, getTeamLabels, getVisibleLabels, isFavourite, removeLabelling, setLabellings
-
Methods inherited from class com.atlassian.confluence.core.AbstractVersionedEntityObject
getConfluenceRevision, getLatestVersion, getVersion, getVersionChildPolicy, isLatestVersion, isNew, 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.confluence.core.Addressable
getId
-
Methods inherited from interface com.atlassian.confluence.labels.EditableLabelable
getId, isPersistent
-
Methods inherited from interface com.atlassian.bonnie.Searchable
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
-
DRAFT
public static final String DRAFT
Constant used incontentStatus
to indicate that this object is a draft.Drafts for existing objects use
AbstractVersionedEntityObject.getLatestVersion()
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.
-
SHARE_ID
public static final String SHARE_ID
Constant used to store a ContentProperty that allows shared access.Used for sharing drafts.
- See Also:
DRAFT
, Constant Field Values
-
SYNC_REV
public static final String SYNC_REV
Constant used to store the Synchrony revision as a ContentProperty.- See Also:
- Constant Field Values
-
DUMMY_SYNC_REV
public static final String DUMMY_SYNC_REV
- See Also:
- Constant Field Values
-
SYNC_REV_SOURCE
public static final String SYNC_REV_SOURCE
Constant used to store the status of the Synchrony revision as a ContentProperty.- See Also:
- Constant Field Values
-
COLLABORATIVE_EDITING_UUID
public static final String COLLABORATIVE_EDITING_UUID
Contains the global UUID at the time Confluence was last restarted.- See Also:
- Constant Field Values
-
LIMITED_MODE_SYNC_REV_SOURCE
@Deprecated public static final String LIMITED_MODE_SYNC_REV_SOURCE
Deprecated.since 7.5.0. Limited mode is no longer supported since 7.5.0- See Also:
- Constant Field Values
-
SYNCHRONY_SYNC_REV_SOURCE
public static final String SYNCHRONY_SYNC_REV_SOURCE
- See Also:
- Constant Field Values
-
SYNCHRONY_ACK_SYNC_REV_SOURCE
public static final String SYNCHRONY_ACK_SYNC_REV_SOURCE
- See Also:
- Constant Field Values
-
CONTENT_RESTORED_SYNC_REV_SOURCE
public static final String CONTENT_RESTORED_SYNC_REV_SOURCE
- See Also:
- Constant Field Values
-
CONFLUENCE_RECOVERY
public static final String CONFLUENCE_RECOVERY
- See Also:
- Constant Field Values
-
CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE
public static final String CONFLUENCE_RECOVERY_WITH_EXTERNAL_CHANGE
- See Also:
- Constant Field Values
-
SYNCHRONY_RECOVERY
public static final String SYNCHRONY_RECOVERY
- See Also:
- Constant Field Values
-
SYNCHRONY_RECOVERY_WITH_EXTERNAL_CHANGE
public static final String SYNCHRONY_RECOVERY_WITH_EXTERNAL_CHANGE
- See Also:
- Constant Field Values
-
-
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 interfaceContentTypeAware
- Returns:
- the content type
-
getTypeEnum
public ContentTypeEnum getTypeEnum()
-
getIdAsString
public String getIdAsString()
-
getDisplayTitle
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.- Specified by:
getDisplayTitle
in interfaceAddressable
- Returns:
- the display title
-
getUrlPath
public abstract String getUrlPath()
- Specified by:
getUrlPath
in interfaceAddressable
-
getAttachmentUrlPath
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 callAttachment.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
-
getTitle
public String getTitle()
- Specified by:
getTitle
in interfaceEditableLabelable
-
setTitle
public void setTitle(String title)
-
getLowerTitle
public String getLowerTitle()
-
getDefaultBodyType
public BodyType getDefaultBodyType()
-
getBodyContent
public BodyContent getBodyContent()
Gets theBodyContent
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 tosetBodyContent(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 theBodyContent
object for this ContentEntityObject or throws an UnsupportedOperationException if its body type is not the same as the suppliedexpectedBodyType
.This method should not normally be called directly unless, you need to be able to handle different body types. Use
getBodyAsString()
andgetBodyAsString()
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 theexpectedBodyType
.- See Also:
getBodyContent()
-
setBodyContent
public void setBodyContent(BodyContent bodyContent)
Sets theBodyContent
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 arenull
, the list of body contents are cleared.
-
getBodyAsString
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 defaultBodyType#XHTML
) used by this ContentEntityObject.
-
setBodyAsString
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 defaultBodyType#XHTML
) used by this ContentEntityObject.
-
getBodyContents
public List<BodyContent> getBodyContents()
-
setBodyContents
public void setBodyContents(List<BodyContent> bodyContents)
-
getOutgoingLinks
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
-
setOutgoingLinks
public void setOutgoingLinks(List<OutgoingLink> outgoingLinks)
-
addOutgoingLink
public void addOutgoingLink(OutgoingLink link)
-
removeOutgoingLink
public void removeOutgoingLink(OutgoingLink link)
-
setOriginalVersion
public void setOriginalVersion(Versioned originalVersion)
Description copied from interface:Versioned
Set the current version of this object. After this method is called, this object will become an historical version of the object passed in.- Specified by:
setOriginalVersion
in interfaceVersioned
- Overrides:
setOriginalVersion
in classAbstractVersionedEntityObject
- Parameters:
originalVersion
- the current version of this object.
-
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 interfaceVersioned
- Overrides:
convertToHistoricalVersion
in classAbstractVersionedEntityObject
-
applyChildVersioningPolicy
@Deprecated public void applyChildVersioningPolicy(Versioned versionToPromote, ObjectDao dao)
Deprecated.since 6.10.0. UseapplyChildVersioningPolicy(Versioned, ObjectDaoInternal)
instead.Description copied from interface:Versioned
IfVersioned.getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or makes no change.- Specified by:
applyChildVersioningPolicy
in interfaceVersioned
- Overrides:
applyChildVersioningPolicy
in classAbstractVersionedEntityObject
- Parameters:
versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained content
-
applyChildVersioningPolicy
public void applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDaoInternal<?> dao)
Description copied from interface:Versioned
IfVersioned.getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or makes no change.- Specified by:
applyChildVersioningPolicy
in interfaceVersioned
- Overrides:
applyChildVersioningPolicy
in classAbstractVersionedEntityObject
- Parameters:
versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained content
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classcom.atlassian.core.bean.EntityObject
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classcom.atlassian.core.bean.EntityObject
-
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(ContentEntityObject otherEntity)
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 interfaceComparable<ContentEntityObject>
-
getSearchableDependants
public Collection<Searchable> getSearchableDependants()
Description copied from interface:Searchable
When we un-index something (say, a page), we also need to un-index everything contained within that page (comments, attachments), because presumably they're all about to go away.- Specified by:
getSearchableDependants
in interfaceSearchable
-
toPageContext
public final PageContext toPageContext()
When the content is rendered, what context is it being rendered in?
-
isIndexable
public boolean isIndexable()
Content entity objects that are historical versions should not be indexed.- Specified by:
isIndexable
in interfaceSearchable
-
getPermissions
@Deprecated public List<ContentPermission> getPermissions()
Deprecated.since 2.6 - usegetContentPermissionSet(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(String permissionType)
Deprecated.since 2.6 - use getContentPermissionSetGives 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
-
sharedAccessAllowed
@Deprecated public boolean sharedAccessAllowed(String shareId)
Deprecated.since 5.10Checks if this draft can be accessed by users other than the creator (shared access)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.
- Parameters:
shareId
- Optional. Used to check for access if needed- Returns:
- true if this draft can be accessed given a share id, false otherwise
- See Also:
TODO: delete this method after 6.0
-
getContentStatusObject
public ContentStatus getContentStatusObject()
Get the api layer enum for content status, distinguishing CURRENT/HISTORICAL/DRAFT/TRASHED.Important: this has different semantics from the hibernate field
getContentStatus()
, because it takes into account historical status, and uses different strings for some values.- Returns:
- the API ContentStatus for this content, distinguishing CURRENT/HISTORICAL/DRAFT/TRASHED
- See Also:
for the hibernate field value, different semantics
-
getContentStatus
public String getContentStatus()
Get the hibernate field for content status, distinguishing only draft/deleted/current status.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.- Returns:
- the hibernate field value, distinguishing only
CURRENT
,DRAFT
,DELETED
. - See Also:
for the API enum, different semantics
-
setContentStatus
public void setContentStatus(String contentStatus)
Set the hibernate field for content status, distinguishing only draft/deleted/current status.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.- Parameters:
contentStatus
- the hibernate field value,CURRENT
,DRAFT
,DELETED
.- See Also:
for the API enum, different semantics
-
isCurrent
public boolean isCurrent()
Does this content have "current" status? (non-trashed and non-draft)This method does NOT distinguish current and historical versions. Both will return true. See
AbstractVersionedEntityObject.isLatestVersion()
to distinguish them.- Returns:
- true if the content is live, i.e. not trashed and not a draft
- See Also:
AbstractVersionedEntityObject.isLatestVersion()
-
isDeleted
public boolean isDeleted()
-
isDraft
public boolean isDraft()
-
sharedAccessAllowed
public boolean sharedAccessAllowed(com.atlassian.user.User user)
Checks if this draft can be accessed by users other than the creator (shared access)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.
- Parameters:
user
- User to check- Returns:
- true if this draft can be accessed given a share id, false otherwise
- See Also:
SHARE_ID
,SharedAccessInterceptor
,AbstractCreateAndEditPageAction.hasDraftPermission()
-
getSynchronyRevisionSource
public String getSynchronyRevisionSource()
- See Also:
SYNC_REV_SOURCE
-
getTrashDate
public Optional<Instant> getTrashDate()
Get trash date if this CEO has been added to the trash since Confluence 7.14. For generic cases, useTrashManagerInternal#findTrashDate
- Returns:
- when this content entity was added to the trash or
Optional.empty()
if it was trashed before 7.14 - Since:
- 7.14
-
setSynchronyRevisionSource
public void setSynchronyRevisionSource(String synchronyRevisionSource)
- See Also:
SYNC_REV_SOURCE
-
getCollaborativeEditingUuid
public String getCollaborativeEditingUuid()
- See Also:
COLLABORATIVE_EDITING_UUID
-
setCollaborativeEditingUuid
public void setCollaborativeEditingUuid(String uuid)
- See Also:
COLLABORATIVE_EDITING_UUID
-
isUnpublished
public boolean isUnpublished()
-
wasCreatedBy
public boolean wasCreatedBy(com.atlassian.user.User user)
-
trash
public void trash()
places content in trash can
-
trash
protected void trash(long trashTimestamp)
-
trashDependents
protected void trashDependents()
-
restore
public void restore()
restores content from the trash
-
restoreDependents
protected void restoreDependents()
-
getAttachments
public List<Attachment> getAttachments()
Don't use it directly, use AttachmentManager.getAttachments(page) instead.
This also includes trashed items.
-
getLatestVersionsOfAttachments
@Deprecated public List<Attachment> getLatestVersionsOfAttachments()
Deprecated.Since 6.13. use AttachmentManager.getLatestVersionsOfAttachments(page) instead.
-
setAttachments
public void setAttachments(List<Attachment> attachments)
-
addAttachment
public void addAttachment(Attachment attachment)
-
removeAttachment
public void removeAttachment(Attachment attachment)
-
getBodyAsStringWithoutMarkup
public String getBodyAsStringWithoutMarkup()
-
getExcerpt
public String getExcerpt()
-
getAttachmentsUrlPath
public String getAttachmentsUrlPath()
-
getAttachmentNamed
public Attachment getAttachmentNamed(String fileName)
-
getVersionComment
public String getVersionComment()
-
setVersionComment
public void setVersionComment(String versionComment)
-
isVersionCommentAvailable
public boolean isVersionCommentAvailable()
-
clone
public Object clone()
- Overrides:
clone
in classAbstractLabelableEntityObject
-
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
ContentPermission
s 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
ContentPermission
s of the type specified
-
hasContentPermissions
public boolean hasContentPermissions()
-
addPermission
public void addPermission(ContentPermission permission)
Adds a ContentPermission. Do not add them manually viaContentPermissionSet.addContentPermission(ContentPermission)
. If possible useContentPermissionManager.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)
-
addComment
public void addComment(Comment comment)
-
removeComment
public void removeComment(Comment comment)
-
getCustomContent
public List<CustomContentEntityObject> getCustomContent()
- Returns:
- all custom content that is a child of this CEO.
- Since:
- 7.16.3
-
addCustomContent
public void addCustomContent(CustomContentEntityObject customContentEntityObject)
-
removeCustomContent
public void removeCustomContent(CustomContentEntityObject customContentEntityObject)
-
getEntity
public ContentEntityObject getEntity()
Description copied from interface:Content
Gets the ContentEntityObject that backs this piece of content.
-
ensureAttachmentBelongsToContent
@EnsuresNonNullIf(expression="attachment.getContainer()", result=true) protected void ensureAttachmentBelongsToContent(Attachment attachment)
-
getContentId
public ContentId getContentId()
Returns theContentId
for this entity object, if it implementsContentConvertible
.Subclasses implementing ContentConvertible must override this method.
- Returns:
- the ContentId representation of this object's id
- Throws:
UnsupportedOperationException
- if the instance doesn't implement ContentConvertible
-
getSelector
public ContentSelector getSelector()
- Returns:
- the ContentSelector for this entity, which will always include the id of the latest version, and the version number for this version of the entity.
-
getProperties
public ContentProperties getProperties()
- Returns:
- the content properties associated with this entity
-
getContainerContent
protected @Nullable ContentEntityObject getContainerContent()
Implementing classes wanting to beContained
in another CEO should implement the Contained interface and delegate to this method- Returns:
- the CEO that contains this one
-
setContainerContent
protected void setContainerContent(@Nullable ContentEntityObject container)
-
replaceContentProperties
protected void replaceContentProperties(ContentProperties propertiesToClone)
Clones the supplied properties and sets these as the properties of the current ContentEntityObject.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".
-
setContentPropertiesFrom
public void setContentPropertiesFrom(ContentEntityObject ceo)
Initialises theContentProperties
of this ContentEntityObject by performing a deep clone of theContentEntityObject
object's properties.
-
getOriginalVersionId
public Long getOriginalVersionId()
-
setOriginalVersionId
protected void setOriginalVersionId(@Nullable Long originalVersionId)
For Hibernate
-
getLatestVersionId
public long getLatestVersionId()
-
getAttachmentManager
protected AttachmentManager getAttachmentManager()
-
-