Class ContentCreator
- java.lang.Object
-
- com.atlassian.confluence.content.apisupport.ContentCreator
-
@ExperimentalSpi public class ContentCreator extends Object
ContentCreator contains logic to validate CREATE / UPDATE content operations which involves sanity checks like access permission and blank titles. In addition, ContentCreator consists of util methods to clone and set content metadata and properties It is expected to be used along side concrete implementations ofBaseContentTypeApiSupport
- Since:
- 5.9.0
-
-
Constructor Summary
Constructors Constructor Description ContentCreator(SpaceManager spaceManager, ContentBodyConversionService contentBodyConversionService, PermissionManager permissionManager, PageManagerInternal pageManager, CustomContentManager customContentEntityManager, com.atlassian.event.api.EventPublisher eventPublisher, DraftAttributesCopier draftAttributesCopier, LabelManagerInternal labelManager, RelationManager relationManager, ContentEntityManagerInternal contentEntityManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T extends ContentEntityObject>
TcloneForUpdate(T ceo)
<T extends ContentEntityObject>
TsaveForCreate(T entity)
Deprecated.since 6.13.0, usesaveNewContent(ContentEntityObject, Version, Draft)
<T extends ContentEntityObject>
TsaveForCreate(T entity, @Nullable Version version, com.atlassian.fugue.Option<Draft> draft)
Deprecated.since 7.0.1.<T extends ContentEntityObject>
TsaveForCreate(T entity, com.atlassian.fugue.Option<Draft> draft)
Deprecated.since 6.13.0, usesaveNewContent(ContentEntityObject, Version, Draft)
<T extends ContentEntityObject>
TsaveNewContent(T entity, @Nullable Version version, @Nullable Draft draft)
Save a newly created content entity object<T extends ContentEntityObject>
TsaveNewVersion(T ceo, T originalCEO, Version version)
Save a new version of the CEO due to an updateboolean
setCommonMetadata(Content updatedContent, ContentEntityObject entity)
Sets the common metadata on the entityvoid
setCommonPropertiesForCreate(Content newContent, ContentEntityObject entity, com.atlassian.user.User authenticatedUser)
Sets common properties on a newly created entity in preparation for being saved.boolean
setCommonPropertiesForUpdate(Content updatedContent, ContentEntityObject entity)
Sets common properties on the entity in preparation for an update.boolean
setContentBodyOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the body content in updatedContent on the entityboolean
setContentStatusOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the content status from updatedContent on the entityboolean
setLabelsMetadataOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the labels metadata on the entityvoid
setSpaceForCreate(Content newContent, SpaceContentEntityObject spacedEntity, com.atlassian.user.User authenticatedUser)
Sets the space in newContent on this spacedEntityboolean
setTitleOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the title in updatedContent on the entity<T extends ContentEntityObject>
Tupdate(T ceo, T originalCEO, Version version)
Saves CEOValidationResult
validateCreate(ConfluenceUser confluenceUser, Content newContent, Class<? extends ContentEntityObject> entityClass)
Perform common validation checks for creation of content in a spaceValidationResult
validateUpdate(ConfluenceUser user, Content updatedContent, ContentEntityObject entity)
Perform common validation checks for updating content
-
-
-
Constructor Detail
-
ContentCreator
public ContentCreator(SpaceManager spaceManager, ContentBodyConversionService contentBodyConversionService, PermissionManager permissionManager, PageManagerInternal pageManager, CustomContentManager customContentEntityManager, com.atlassian.event.api.EventPublisher eventPublisher, DraftAttributesCopier draftAttributesCopier, LabelManagerInternal labelManager, RelationManager relationManager, ContentEntityManagerInternal contentEntityManager)
-
-
Method Detail
-
setCommonPropertiesForCreate
public void setCommonPropertiesForCreate(Content newContent, ContentEntityObject entity, com.atlassian.user.User authenticatedUser)
Sets common properties on a newly created entity in preparation for being saved.The properties set include the title and content body, and if the entity is a SpacedContentEntityObject also the space
- Parameters:
newContent
- the content containing the new properties to set on the entityentity
- the entity to set the new properties onauthenticatedUser
- the user that performing the operation
-
validateUpdate
public ValidationResult validateUpdate(ConfluenceUser user, Content updatedContent, ContentEntityObject entity)
Perform common validation checks for updating content- Parameters:
user
- the user to perform permission checks onupdatedContent
- the content to be updatedentity
- the entity to be updated- Returns:
- a validation result indicating any validation errors that would occur on update
-
validateCreate
public ValidationResult validateCreate(ConfluenceUser confluenceUser, Content newContent, Class<? extends ContentEntityObject> entityClass)
Perform common validation checks for creation of content in a space- Parameters:
confluenceUser
- the user to perform permission checks onnewContent
- the content to be createdentityClass
- the class of content to create- Returns:
- a validation result indicating any errors that would occur attempting to create content
-
setCommonPropertiesForUpdate
public boolean setCommonPropertiesForUpdate(Content updatedContent, ContentEntityObject entity)
Sets common properties on the entity in preparation for an update. For properties initialized include the title and the content body.- Parameters:
updatedContent
- the content containing the properties to update on the entityentity
- the entity to be updated- Returns:
- true if the entity was updated and requires being saved to the database
-
setLabelsMetadataOnEntity
public boolean setLabelsMetadataOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the labels metadata on the entity- Parameters:
updatedContent
- the content with the new body contententity
- the entity to be updated- Returns:
- true if the entity was updated with labels metadata different to what it already had
-
setCommonMetadata
public boolean setCommonMetadata(Content updatedContent, ContentEntityObject entity)
Sets the common metadata on the entity- Parameters:
updatedContent
- the content containing the properties to update on the entityentity
- the entity to be updated- Returns:
- true if the entity was updated
-
setTitleOnEntity
public boolean setTitleOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the title in updatedContent on the entity- Parameters:
updatedContent
- the content with the new titleentity
- the entity to be updated- Returns:
- true if the entity was updated with a different title to what it already had
-
setContentBodyOnEntity
public boolean setContentBodyOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the body content in updatedContent on the entity- Parameters:
updatedContent
- the content with the new body contententity
- the entity to be updated- Returns:
- true if the entity was updated with body content different to what it already had
-
setContentStatusOnEntity
public boolean setContentStatusOnEntity(Content updatedContent, ContentEntityObject entity)
Sets the content status from updatedContent on the entity- Parameters:
updatedContent
- the content with the new titleentity
- the entity to be updated- Returns:
- true if the content status was updated
-
setSpaceForCreate
public void setSpaceForCreate(Content newContent, SpaceContentEntityObject spacedEntity, com.atlassian.user.User authenticatedUser)
Sets the space in newContent on this spacedEntity- Parameters:
newContent
- the content with the new space to setspacedEntity
- the entity to be updated with the space
-
saveNewVersion
public <T extends ContentEntityObject> T saveNewVersion(T ceo, T originalCEO, Version version)
Save a new version of the CEO due to an update- Parameters:
ceo
- the new version of the CEOoriginalCEO
- the original version of the ceoversion
- the version object with information about the new version to be saved- Returns:
- the latest version of the CEO fetched from the database
-
update
public <T extends ContentEntityObject> T update(T ceo, T originalCEO, Version version)
Saves CEO- Parameters:
ceo
- CEOoriginalCEO
- ceo we are updating fromversion
- current version to update to- Returns:
- the latest version of the CEO fetched from the database
-
saveForCreate
@Deprecated public <T extends ContentEntityObject> T saveForCreate(T entity)
Deprecated.since 6.13.0, usesaveNewContent(ContentEntityObject, Version, Draft)
Save a newly created CEO- Parameters:
entity
- the newly created CEO- Returns:
- the latest version of the CEO fetched from the database
-
saveForCreate
@Deprecated public <T extends ContentEntityObject> T saveForCreate(T entity, com.atlassian.fugue.Option<Draft> draft)
Deprecated.since 6.13.0, usesaveNewContent(ContentEntityObject, Version, Draft)
Save a newly created CEO- Parameters:
entity
- the newly created CEOdraft
- the draft object contains metadata which will be transferred into the entity- Returns:
- the latest version of the CEO fetched from the database
-
saveForCreate
@Deprecated public <T extends ContentEntityObject> T saveForCreate(T entity, @Nullable Version version, com.atlassian.fugue.Option<Draft> draft)
Deprecated.since 7.0.1. UsesaveNewContent(ContentEntityObject, Version, Draft)
Save a newly created content entity object- Parameters:
entity
- the entity object to be savedversion
- the versiondraft
- the draft object contains metadata which will be transferred into the entity- Returns:
- the latest version of the content entity object fetched from the database
- Since:
- 6.13.0
-
saveNewContent
public <T extends ContentEntityObject> T saveNewContent(T entity, @Nullable Version version, @Nullable Draft draft)
Save a newly created content entity object- Parameters:
entity
- the entity object to be savedversion
- the versiondraft
- the draft object contains metadata which will be transferred into the entity. Can be null.- Returns:
- the latest version of the content entity object fetched from the database
- Since:
- 7.0.1
-
cloneForUpdate
public <T extends ContentEntityObject> T cloneForUpdate(T ceo)
-
-