com.atlassian.confluence.content.apisupport
Class ContentCreator

java.lang.Object
  extended by com.atlassian.confluence.content.apisupport.ContentCreator

public class ContentCreator
extends Object


Constructor Summary
ContentCreator(SpaceManager spaceManager, ContentBodyConversionService contentBodyConversionService, PermissionManager permissionManager, PageManagerInternal pageManager, CustomContentManager customContentEntityManager)
           
 
Method Summary
<T extends ContentEntityObject>
T
cloneForUpdate(T ceo)
           
<T extends ContentEntityObject>
T
saveForCreate(T entity)
          Save a newly created CEO
<T extends ContentEntityObject>
T
saveNewVersion(T ceo, T originalCEO, Version version)
          Save a new version of the CEO due to an update
 void 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 entity
 void setSpaceForCreate(Content newContent, SpaceContentEntityObject spacedEntity, com.atlassian.user.User authenticatedUser)
          Sets the space in newContent on this spacedEntity
 boolean setTitleOnEntity(Content updatedContent, ContentEntityObject entity)
          Sets the title in updatedContent on the entity
 ValidationResult validateCreate(ConfluenceUser confluenceUser, Content newContent, Class<? extends ContentEntityObject> entityClass)
          Perform common validation checks for creation of content in a space
 ValidationResult validateUpdate(ConfluenceUser user, Content updatedContent, ContentEntityObject entity)
          Perform common validation checks for updating content
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentCreator

public ContentCreator(SpaceManager spaceManager,
                      ContentBodyConversionService contentBodyConversionService,
                      PermissionManager permissionManager,
                      PageManagerInternal pageManager,
                      CustomContentManager customContentEntityManager)
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 entity
entity - the entity to set the new properties on
authenticatedUser - 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 on
updatedContent - the content to be updated
entity - 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 on
newContent - the content to be created
entityClass - 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 entity
entity - the entity to be updated
Returns:
true if the entity was updated and requires being saved to the database

setTitleOnEntity

public boolean setTitleOnEntity(Content updatedContent,
                                ContentEntityObject entity)
Sets the title in updatedContent on the entity

Parameters:
updatedContent - the content with the new title
entity - 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 content
entity - the entity to be updated
Returns:
true if the entity was updated with body content different to what it already had

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 set
spacedEntity - 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 CEO
originalCEO - the original version of the ceo
version - the version object with information about the new version to be saved
Returns:
the latest version of the CEO fetched from the database

saveForCreate

public <T extends ContentEntityObject> T saveForCreate(T entity)
Save a newly created CEO

Parameters:
entity - the newly created CEO
Returns:
the latest version of the CEO fetched from the database

cloneForUpdate

public <T extends ContentEntityObject> T cloneForUpdate(T ceo)


Copyright © 2003–2015 Atlassian. All rights reserved.