Package org.ametys.cms.workflow
Class ContentWorkflowHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.workflow.ContentWorkflowHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class ContentWorkflowHelper
extends AbstractLogEnabled
implements Serviceable, Contextualizable, Component
A component to do workflow actions on Content
-
Field Summary
Modifier and TypeFieldDescriptionprotected ObservationManager
The observation managerprotected CurrentUserProvider
Component to get the current userprotected WorkflowProvider
Workflow instance.static final String
The component role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contextualize
(Context context) createContent
(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode) Creates a content using the workflow (with the CreateContentFunction).createContent
(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode, Map<String, Object> inputs) Creates a content using the workflow (with the CreateContentFunction).createContent
(String workflowName, int initialActionId, String contentName, Map<String, String> titleVariants, String[] contentTypes, String[] mixins) Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).createContent
(String workflowName, int initialActionId, String contentName, Map<String, String> titleVariants, String[] contentTypes, String[] mixins, Map<String, Object> inputs) Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).doAction
(WorkflowAwareContent content, int actionId) Do a workflow action on a content.doAction
(WorkflowAwareContent content, int actionId, Map<String, Object> inputs) Do a workflow action on a content.doAction
(WorkflowAwareContent content, int actionId, Map<String, Object> inputs, boolean logError) Do a workflow action on a content.editContent
(WorkflowAwareContent content, Map<String, Object> values, int workflowActionId) Edit aContent
programmatically.editContent
(WorkflowAwareContent content, Map<String, Object> values, int workflowActionId, View view) Edit aContent
programmatically.int[]
getAvailableActions
(WorkflowAwareContent content) Get the available workflow actions for the contentint[]
getAvailableActions
(WorkflowAwareContent content, Map<String, Object> inputs) Get the available workflow actions for the contentboolean
isAvailableAction
(WorkflowAwareContent content, int actionId) Determines if the workflow action is availableboolean
isAvailableAction
(WorkflowAwareContent content, int actionId, Map<String, Object> inputs) Determines if the workflow action is availablevoid
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role -
_userProvider
Component to get the current user -
_workflowProvider
Workflow instance. -
_observationManager
The observation manager
-
-
Constructor Details
-
ContentWorkflowHelper
public ContentWorkflowHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
createContent
public Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException Creates a content using the workflow (with the CreateContentFunction).- Parameters:
workflowName
- The name of the workflow to createinitialActionId
- The workflow action id that creates contentcontentName
- The new namecontentTitle
- The new titlecontentTypes
- The new content types. Cannot be null. Cannot be empty.mixins
- The new mixins. Can be null. Can be empty.languageCode
- The language code of the new content (such as 'fr', 'en'...)- Returns:
- The workflow result map. See the create content function used to get the new content. Can be under the key CreateContentFunction.CONTENT_KEY, and the id under the key "contentId"
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
createContent
public Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, Map<String, String> titleVariants, String[] contentTypes, String[] mixins) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCreates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).- Parameters:
workflowName
- The name of the workflow to createinitialActionId
- The workflow action id that creates contentcontentName
- The new nametitleVariants
- The title's variantscontentTypes
- The new content types. Cannot be null. Cannot be empty.mixins
- The new mixins. Can be null. Can be empty.- Returns:
- The workflow result map. See the create content function used to get the new content. Can be under the key CreateContentFunction.CONTENT_KEY, and the id under the key "contentId"
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
createContent
public Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode, Map<String, Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCreates a content using the workflow (with the CreateContentFunction).- Parameters:
workflowName
- The name of the workflow to createinitialActionId
- The workflow action id that creates contentcontentName
- The new namecontentTitle
- The new titlecontentTypes
- The new content types. Cannot be null. Cannot be empty.mixins
- The new mixins. Can be null. Can be empty.languageCode
- The language code of the new content (such as 'fr', 'en'...)inputs
- The parameters to transmit to the workflow functions. Cannot be null.- Returns:
- The workflow result map. See the create content function used to get the new content. Can be under the key CreateContentFunction.CONTENT_KEY, and the id under the key "contentId"
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
createContent
public Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, Map<String, String> titleVariants, String[] contentTypes, String[] mixins, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionObject> inputs) Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).- Parameters:
workflowName
- The name of the workflow to createinitialActionId
- The workflow action id that creates contentcontentName
- The new nametitleVariants
- The title's variantscontentTypes
- The new content types. Cannot be null. Cannot be empty.mixins
- The new mixins. Can be null. Can be empty.inputs
- The parameters to transmit to the workflow functions. Cannot be null.- Returns:
- The workflow result map. See the create content function used to get the new content. Can be under the key CreateContentFunction.CONTENT_KEY, and the id under the key "contentId"
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
isAvailableAction
Determines if the workflow action is available- Parameters:
content
- the content to consider.actionId
- the workflow action id to check- Returns:
true
if the wortkflow action is available
-
isAvailableAction
public boolean isAvailableAction(WorkflowAwareContent content, int actionId, Map<String, Object> inputs) Determines if the workflow action is available- Parameters:
content
- the content to consider.actionId
- the workflow action id to checkinputs
- The parameters to transmit to the workflow functions. Cannot be null.- Returns:
true
if the wortkflow action is available
-
getAvailableActions
Get the available workflow actions for the content- Parameters:
content
- The content to consider. Cannot be null.- Returns:
- The array of actions ids that are available now
-
getAvailableActions
Get the available workflow actions for the content- Parameters:
content
- The content to consider. Cannot be null.inputs
- The parameters to transmit to the workflow functions. Cannot be null.- Returns:
- The array of actions ids that are available now
-
doAction
public Map<String,Object> doAction(WorkflowAwareContent content, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException Do a workflow action on a content.- Parameters:
content
- The content to act on. Cannot be null.actionId
- The id of the workflow action to do- Returns:
- The results of the functions
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
doAction
public Map<String,Object> doAction(WorkflowAwareContent content, int actionId, Map<String, Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionDo a workflow action on a content.- Parameters:
content
- The content to act on. Cannot be null.actionId
- The id of the workflow action to doinputs
- The parameters to transmit to the workflow functions. Cannot be null. The special key AbstractWorkflowComponent.CONTEXT_PARAMETERS_KEY will be filled with the parent context if null (this means that if your are in a request dispatched, you will automatically get the js parameters).- Returns:
- The results of the functions
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
doAction
public Map<String,Object> doAction(WorkflowAwareContent content, int actionId, Map<String, Object> inputs, boolean logError) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionDo a workflow action on a content.- Parameters:
content
- The content to act on. Cannot be null.actionId
- The id of the workflow action to doinputs
- The parameters to transmit to the workflow functions. Cannot be null. The special key AbstractWorkflowComponent.CONTEXT_PARAMETERS_KEY will be filled with the parent context if null (this means that if your are in a request dispatched, you will automatically get the js parameters).logError
-true
to log the action error- Returns:
- The results of the functions
- Throws:
com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the content
-
editContent
public Map<String,Object> editContent(WorkflowAwareContent content, Map<String, Object> values, int workflowActionId) throws com.opensymphony.workflow.WorkflowExceptionEdit aContent
programmatically.- Parameters:
content
- theModifiableContent
.values
- the typed values to set.workflowActionId
- the id of the workflow action- Returns:
- the workflow results.
- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs while processing the workflow action
-
editContent
public Map<String,Object> editContent(WorkflowAwareContent content, Map<String, Object> values, int workflowActionId, View view) throws com.opensymphony.workflow.WorkflowExceptionEdit aContent
programmatically.- Parameters:
content
- theModifiableContent
.values
- the typed values to set.workflowActionId
- the id of the workflow actionview
- the view to edit- Returns:
- the workflow results.
- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurs while processing the workflow action
-