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
Fields Modifier and Type Field Description protected ContentTypeExtensionPoint_contentTypeEPThe content types handlerprotected ContentTypesHelper_contentTypeHelperThe content types helperprotected ObservationManager_observationManagerObservation manager available to subclasses.protected AmetysObjectResolver_resolverAmetys object resolver available to subclasses.static StringCONTENT_LANGUAGE_KEYConstant for storing the content language to use into the transient variables map.static StringCONTENT_MIXINS_KEYConstant for storing the content mixins to use into the transient variables map.static StringCONTENT_NAME_KEYConstant for storing the content name to use into the transient variables map.static StringCONTENT_TITLE_KEYConstant for storing the content title to use into the transient variables map.static StringCONTENT_TITLE_VARIANTS_KEYConstant for storing the content title variants (for multilingual content only) to use into the transient variables map.static StringCONTENT_TYPES_KEYConstant for storing the content types to use into the transient variables map.static StringPARENT_CONTENT_ID_KEYConstant for storing the parent content to use into the transient variables map.static StringPARENT_CONTENT_METADATA_PATH_KEYConstant for storing the parent content metadata path to use into the transient variables map.-
Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_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
Constructors Constructor Description CreateContentFunction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ModifiableWorkflowAwareContent_createContent(Map transientVars, String desiredContentName, ModifiableTraversableAmetysObject contentsNode)Create the content object.protected Map<String,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, 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 contentprotected List<Future>_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 variantsvoidexecute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps)protected UserIdentitygetSystemUser()Get the user to use when the content is created in a background environment.voidservice(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 Detail
-
CONTENT_NAME_KEY
public static final String CONTENT_NAME_KEY
Constant for storing the content name to use into the transient variables map.
-
CONTENT_TITLE_KEY
public static final String CONTENT_TITLE_KEY
Constant for storing the content title to use into the transient variables map.
-
CONTENT_TITLE_VARIANTS_KEY
public static final String 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
public static final String CONTENT_TYPES_KEY
Constant for storing the content types to use into the transient variables map.
-
CONTENT_MIXINS_KEY
public static final String CONTENT_MIXINS_KEY
Constant for storing the content mixins to use into the transient variables map.
-
CONTENT_LANGUAGE_KEY
public static final String CONTENT_LANGUAGE_KEY
Constant for storing the content language to use into the transient variables map.
-
PARENT_CONTENT_ID_KEY
public static final String PARENT_CONTENT_ID_KEY
Constant for storing the parent content to use into the transient variables map.
-
PARENT_CONTENT_METADATA_PATH_KEY
public static final String PARENT_CONTENT_METADATA_PATH_KEY
Constant for storing the parent content metadata path to use into the transient variables map.
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver available to subclasses.
-
_observationManager
protected ObservationManager _observationManager
Observation manager available to subclasses.
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The content types handler
-
_contentTypeHelper
protected ContentTypesHelper _contentTypeHelper
The content types helper
-
-
Constructor Detail
-
CreateContentFunction
public CreateContentFunction()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractContentWorkflowComponent- Throws:
ServiceException
-
execute
public void execute(Map transientVars, Map args, com.opensymphony.module.propertyset.PropertySet ps) throws com.opensymphony.workflow.WorkflowException
- Specified by:
executein interfacecom.opensymphony.workflow.FunctionProvider- Throws:
com.opensymphony.workflow.WorkflowException
-
_initWorkflow
protected void _initWorkflow(Map transientVars, ModifiableWorkflowAwareContent content, 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 AmetysRepositoryException
Set 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
protected boolean _isMultilingual(String[] contentTypes)
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
Futureobjects of the asynchronous observers - Throws:
com.opensymphony.workflow.WorkflowException- If an error occurred
-
_eventParamsForContentAdded
protected Map<String,Object> _eventParamsForContentAdded(Content content)
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
protected String _getObjectType(Map transientVars)
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
protected UserIdentity 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.
-
-