Package org.ametys.cms.workflow
Class CreateContentFunction
java.lang.Object
org.ametys.plugins.workflow.AbstractWorkflowComponent
org.ametys.cms.workflow.AbstractContentWorkflowComponent
org.ametys.cms.workflow.CreateContentFunction
- All Implemented Interfaces:
com.opensymphony.workflow.FunctionProvider
,LogEnabled
,Serviceable
- Direct Known Subclasses:
AbstractCreateODFContentFunction
,CreateContentByCopyFunction
,CreateContentFunction
,CreateExtractionDescriptionFunction
,CreateReferenceTableContentFunction
,CreateSynchronizedContentFunction
public class CreateContentFunction
extends AbstractContentWorkflowComponent
implements com.opensymphony.workflow.FunctionProvider
OSWorkflow function for creating a content.
-
Field Summary
Modifier and TypeFieldDescriptionprotected ContentTypeExtensionPoint
The content types handlerprotected ContentTypesHelper
The content types helperprotected ObservationManager
Observation manager available to subclasses.protected AmetysObjectResolver
Ametys object resolver available to subclasses.static final String
Constant for storing the content language to use into the transient variables map.static final String
Constant for storing the content mixins to use into the transient variables map.static final String
Constant for storing the content name to use into the transient variables map.static final String
Constant for storing the content title to use into the transient variables map.static final String
Constant for storing the content title variants (for multilingual content only) to use into the transient variables map.static final String
Constant for storing the content types to use into the transient variables map.static final String
Constant for storing the function allowing to get initial values into the transient variables map.static final String
Constant for storing the parent content to use into the transient variables map.static final String
Constant for storing the parent content metadata path to use into the transient variables map.static final String
Constant for storing the parent content id to use into the transient variables map.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEY
Fields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_ERRORS_KEY, WORKFLOW_WARNS_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ModifiableWorkflowAwareContent
_createContent
(Map transientVars, String desiredContentName, ModifiableTraversableAmetysObject contentsNode) Create the content object._eventParamsForContentAdded
(Content content) Gets the event parameters sent in method_notifyContentAdded(Content, Map)
protected ModifiableTraversableAmetysObject
_getContentRoot
(Map transientVars) Retrieve the content root.protected String
_getNonNullVar
(Map transientVars, String name, String exceptionName) Get a workflow parameter, throwing an exception if it is null.protected String
_getObjectType
(Map transientVars) Return the type of the object to be created.protected ModifiableTraversableAmetysObject
_getSubContentRoot
(String parentContentId, String parentContentMetadataPath) Get the content root when creating a sub-content.protected void
_initWorkflow
(Map transientVars, ModifiableWorkflowAwareContent content, javax.jcr.Session session, long workflowId) Initialize the workflow of the added content.protected boolean
_isMultilingual
(String[] contentTypes) Determines if the content to create is a multilingual content_notifyContentAdded
(Content content, Map transientVars) Notify observers that the content has been createdprotected void
_populateAdditionalData
(Map transientVars, ModifiableContent content) Populate the content.protected void
_populateContent
(Map transientVars, ModifiableContent content) Populate the content.protected void
_setTitle
(ModifiableContent content, String[] cTypes, Map<String, String> titleVariants, Locale locale) Set the content's title variantsvoid
protected UserIdentity
Get the user to use when the content is created in a background environment.void
service
(ServiceManager manager) Methods inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
getContent
Methods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUser
-
Field Details
-
CONTENT_NAME_KEY
Constant for storing the content name to use into the transient variables map. -
CONTENT_TITLE_KEY
Constant for storing the content title to use into the transient variables map. -
CONTENT_TITLE_VARIANTS_KEY
Constant for storing the content title variants (for multilingual content only) to use into the transient variables map. -
CONTENT_TYPES_KEY
Constant for storing the content types to use into the transient variables map. -
CONTENT_MIXINS_KEY
Constant for storing the content mixins to use into the transient variables map. -
CONTENT_LANGUAGE_KEY
Constant for storing the content language to use into the transient variables map. -
PARENT_CONTENT_ID_KEY
Constant for storing the parent content to use into the transient variables map. -
PARENT_CONTENT_METADATA_PATH_KEY
Constant for storing the parent content metadata path to use into the transient variables map. -
INITIAL_VALUE_SUPPLIER
Constant for storing the function allowing to get initial values into the transient variables map. -
PARENT_CONTEXT_VALUE
Constant for storing the parent content id to use into the transient variables map. -
_resolver
Ametys object resolver available to subclasses. -
_observationManager
Observation manager available to subclasses. -
_contentTypeEP
The content types handler -
_contentTypeHelper
The content types helper
-
-
Constructor Details
-
CreateContentFunction
public CreateContentFunction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractContentWorkflowComponent
- Throws:
ServiceException
-
execute
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException - Specified by:
execute
in interfacecom.opensymphony.workflow.FunctionProvider
- Throws:
com.opensymphony.workflow.WorkflowException
-
_initWorkflow
protected void _initWorkflow(Map transientVars, ModifiableWorkflowAwareContent content, javax.jcr.Session session, long workflowId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException Initialize the workflow of the added content.- Parameters:
transientVars
- The workflow varscontent
- The added contentsession
- The sessionworkflowId
- The workflow ID- Throws:
AmetysRepositoryException
- if a repository error occuredcom.opensymphony.workflow.WorkflowException
- if a workflow error occured
-
_setTitle
protected void _setTitle(ModifiableContent content, String[] cTypes, Map<String, String> titleVariants, Locale locale) throws AmetysRepositoryExceptionSet the content's title variants- Parameters:
content
- The contentcTypes
- The content's content typestitleVariants
- The title's variantslocale
- The title's locale. Cannot be null if content is a non-multilingual content.- Throws:
AmetysRepositoryException
- if failed to set title
-
_isMultilingual
Determines if the content to create is a multilingual content- Parameters:
contentTypes
- The content types of content to create- Returns:
- true if multilingual
-
_notifyContentAdded
protected List<Future> _notifyContentAdded(Content content, Map transientVars) throws com.opensymphony.workflow.WorkflowException Notify observers that the content has been created- Parameters:
content
- The content addedtransientVars
- The workflow vars- Returns:
- The
Future
objects of the asynchronous observers - Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred
-
_eventParamsForContentAdded
Gets the event parameters sent in method_notifyContentAdded(Content, Map)
- Parameters:
content
- The content added- Returns:
- the event parameters
-
_createContent
protected ModifiableWorkflowAwareContent _createContent(Map transientVars, String desiredContentName, ModifiableTraversableAmetysObject contentsNode) Create the content object.- Parameters:
transientVars
- the workflow parameters.desiredContentName
- the desired content name.contentsNode
- the content root node in the repository.- Returns:
- the created Content.
-
_getObjectType
Return the type of the object to be created. Ex: ametys:defaultContent.- Parameters:
transientVars
- The workflow vars- Returns:
- The type of the object to be used during content creation.
-
_getContentRoot
protected ModifiableTraversableAmetysObject _getContentRoot(Map transientVars) throws com.opensymphony.workflow.WorkflowException Retrieve the content root.- Parameters:
transientVars
- the workflow parameters.- Returns:
- the content root node.
- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs
-
_getSubContentRoot
protected ModifiableTraversableAmetysObject _getSubContentRoot(String parentContentId, String parentContentMetadataPath) throws com.opensymphony.workflow.WorkflowException Get the content root when creating a sub-content.- Parameters:
parentContentId
- the parent content ID.parentContentMetadataPath
- the path of the metadata in which to create the sub-content.- Returns:
- the content collection metadata.
- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs.
-
_getNonNullVar
protected String _getNonNullVar(Map transientVars, String name, String exceptionName) throws com.opensymphony.workflow.WorkflowException Get a workflow parameter, throwing an exception if it is null.- Parameters:
transientVars
- the workflow parameters.name
- the variable name.exceptionName
- label of the exception to throw if the variable is null.- Returns:
- the variable value.
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred
-
_populateContent
protected void _populateContent(Map transientVars, ModifiableContent content) throws com.opensymphony.workflow.WorkflowException Populate the content.- Parameters:
transientVars
- the transient variables.content
- the content.- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs.
-
getSystemUser
Get the user to use when the content is created in a background environment.- Returns:
- The anonymous user
-
_populateAdditionalData
protected void _populateAdditionalData(Map transientVars, ModifiableContent content) throws com.opensymphony.workflow.WorkflowException Populate the content.- Parameters:
transientVars
- the transient variables.content
- the content.- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs.
-