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,EnhancedFunction,LogEnabled,Serviceable
- Direct Known Subclasses:
AbstractCreateODFContentFunction,CreateContentByCopyFunction,CreateContentFunction,CreateExtractionDescriptionFunction,CreateReferenceTableContentFunction,CreateSynchronizedContentFunction
public class CreateContentFunction
extends AbstractContentWorkflowComponent
implements EnhancedFunction
OSWorkflow function for creating a content.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
AbstractWorkflowComponent.ConditionFailureNested classes/interfaces inherited from interface org.ametys.plugins.workflow.EnhancedFunction
EnhancedFunction.FunctionType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContentTypeExtensionPointThe content types handlerprotected ContentTypesHelperThe content types helperprotected ObservationManagerObservation manager available to subclasses.protected AmetysObjectResolverAmetys object resolver available to subclasses.static final StringConstant for storing the content language to use into the transient variables map.static final StringConstant for storing the content mixins to use into the transient variables map.static final StringConstant for storing the content name to use into the transient variables map.static final StringConstant for storing the content title to use into the transient variables map.static final StringConstant for storing the content title variants (for multilingual content only) to use into the transient variables map.static final StringConstant for storing the content types to use into the transient variables map.static final StringConstant for storing the function allowing to get initial values into the transient variables map.static final StringConstant for storing the parent content id to use into the transient variables map.static final StringConstant for storing the parent path to use into the transient variables map.Fields inherited from class org.ametys.cms.workflow.AbstractContentWorkflowComponent
_contentHelper, CONTENT_KEY, HAS_CHANGED_KEYFields inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
_logger, _manager, CONTEXT_PARAMETERS_KEY, FAIL_CONDITIONS_KEY, RESULT_MAP_KEY, WORKFLOW_VALIDATION_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ModifiableWorkflowAwareContent_createContent(Map transientVars, Map args, 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 NameHelper.NameComputationModeDefine the default computation modeprotected NameHelper.NameComputationMode_getNameComputationMode(Map transientVars, Map args) Return the mode to compute the name if not unique.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, Map args) Return the type of the object to be created.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 variantsvoidReturn the type for the functiongetLabel()Get the label for this functionprotected UserIdentityGet 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
getContentMethods inherited from class org.ametys.plugins.workflow.AbstractWorkflowComponent
addWorkflowError, addWorkflowWarning, enableLogging, getConditionFailures, getContextParameters, getResultsMap, getUserMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.plugins.workflow.EnhancedFunction
getArguments, getFullLabel, getVisibilities
-
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. -
ROOT_CONTENT_PATH_KEY
Constant for storing the parent 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:
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, 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
Futureobjects 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, Map args, String desiredContentName, ModifiableTraversableAmetysObject contentsNode) Create the content object.- Parameters:
transientVars- the workflow parameters.args- The workflow function argumentsdesiredContentName- 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 varsargs- The workflow function arguments- Returns:
- The type of the object to be used during content creation.
-
_getNameComputationMode
Return the mode to compute the name if not unique. Ex: ametys:defaultContent.- Parameters:
transientVars- The workflow varsargs- The workflow function arguments- Returns:
- The unique name to be used during content creation.
-
_getDefaultNameComputationMode
Define the default computation mode- Returns:
- the default computation mode
-
_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
-
_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.
-
getFunctionExecType
Description copied from interface:EnhancedFunctionReturn the type for the function- Specified by:
getFunctionExecTypein interfaceEnhancedFunction- Returns:
- the type 's code
-
getLabel
Description copied from interface:EnhancedFunctionGet the label for this function- Specified by:
getLabelin interfaceEnhancedFunction- Returns:
- the label
-