public class ContentWorkflowHelper extends AbstractLogEnabled implements Serviceable, Contextualizable, Component
Modifier and Type | Field and Description |
---|---|
private Context |
_context |
protected ObservationManager |
_observationManager
The observation manager
|
protected CurrentUserProvider |
_userProvider
Component to get the current user
|
protected WorkflowProvider |
_workflowProvider
Workflow instance.
|
static String |
ROLE
The component role
|
Constructor and Description |
---|
ContentWorkflowHelper() |
Modifier and Type | Method and Description |
---|---|
protected void |
_applyChanges(WorkflowAwareContent content,
int actionId,
String comment)
Apply changes on content: create a new version and notify listeners.
|
private Map<String,Object> |
_doInitialize(String workflowName,
String contentName,
int initialActionId,
Map<String,Object> inputs) |
private void |
_getCommonInputsForCreation(Map<String,Object> inputs,
String contentName,
String[] contentTypes,
String[] mixins,
String parentContentId,
String parentContentMetadatapath) |
protected ModifiableCompositeMetadata |
_getCompositeFromValuePath(WorkflowAwareContent contentToEdit,
String valuePath)
Get the last composite and the metadata name from a value path.
|
private UserIdentity |
_getUser() |
protected void |
_removeEntry(int position,
ModifiableCompositeMetadata repositoryComposite)
Removes the repeater entry at the given position.
|
void |
contextualize(Context context) |
Map<String,Object> |
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).
|
Map<String,Object> |
createContent(String workflowName,
int initialActionId,
String contentName,
Map<String,String> titleVariants,
String[] contentTypes,
String[] mixins,
String parentContentId,
String parentContentMetadatapath)
Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).
|
Map<String,Object> |
createContent(String workflowName,
int initialActionId,
String contentName,
Map<String,String> titleVariants,
String[] contentTypes,
String[] mixins,
String parentContentId,
String parentContentMetadatapath,
Map<String,Object> inputs)
Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).
|
Map<String,Object> |
createContent(String workflowName,
int initialActionId,
String contentName,
String contentTitle,
String[] contentTypes,
String[] mixins,
String languageCode)
Creates a content using the workflow (with the CreateContentFunction).
|
Map<String,Object> |
createContent(String workflowName,
int initialActionId,
String contentName,
String contentTitle,
String[] contentTypes,
String[] mixins,
String languageCode,
String parentContentId,
String parentContentMetadatapath)
Creates a content using the workflow (with the CreateContentFunction).
|
Map<String,Object> |
createContent(String workflowName,
int initialActionId,
String contentName,
String contentTitle,
String[] contentTypes,
String[] mixins,
String languageCode,
String parentContentId,
String parentContentMetadatapath,
Map<String,Object> inputs)
Creates a content using the workflow (with the CreateContentFunction).
|
Map<String,Object> |
doAction(WorkflowAwareContent content,
int actionId)
Do a workflow action on a content.
|
Map<String,Object> |
doAction(WorkflowAwareContent content,
int actionId,
Map<String,Object> inputs)
Do a workflow action on a content.
|
int[] |
getAvailableActions(WorkflowAwareContent content)
Get the available workflow actions for the content
|
int[] |
getAvailableActions(WorkflowAwareContent content,
Map<String,Object> inputs)
Get the available workflow actions for the content
|
boolean |
isAvailableAction(WorkflowAwareContent content,
int actionId)
Determines if the workflow action is available
|
boolean |
removeMetadata(WorkflowAwareContent contentToEdit,
String valuePath,
int actionId,
String comment)
Remove metadata from content and apply changes
|
boolean |
removeRepeaterEntry(WorkflowAwareContent contentToEdit,
String entryPath,
int actionId,
String comment)
Remove repeater entry from content and apply changes
|
boolean |
removeStringValueFromMultipleMetadata(WorkflowAwareContent contentToEdit,
String valuePath,
String valueToRemove,
int actionId,
String comment)
Remove string value of multiple metadata from content and apply changes
|
void |
service(ServiceManager manager) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected CurrentUserProvider _userProvider
protected WorkflowProvider _workflowProvider
protected ObservationManager _observationManager
public ContentWorkflowHelper()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
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
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'...)com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, Map<String,String> titleVariants, String[] contentTypes, String[] mixins) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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.com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode, String parentContentId, String parentContentMetadatapath) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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'...)parentContentId
- If the new content is a subcontent, the parent content identifier.parentContentMetadatapath
- If the new content is a subcontent, the path of the metadata where the new content will take place in its parentcom.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, Map<String,String> titleVariants, String[] contentTypes, String[] mixins, String parentContentId, String parentContentMetadatapath) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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.parentContentId
- If the new content is a subcontent, the parent content identifier.parentContentMetadatapath
- If the new content is a subcontent, the path of the metadata where the new content will take place in its parentcom.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, String contentTitle, String[] contentTypes, String[] mixins, String languageCode, String parentContentId, String parentContentMetadatapath, Map<String,Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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'...)parentContentId
- If the new content is a subcontent, the parent content identifier.parentContentMetadatapath
- If the new content is a subcontent, the path of the metadata where the new content will take place in its parentinputs
- The parameters to transmit to the workflow functions. Cannot be null.com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> createContent(String workflowName, int initialActionId, String contentName, Map<String,String> titleVariants, String[] contentTypes, String[] mixins, String parentContentId, String parentContentMetadatapath, Map<String,Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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.parentContentId
- If the new content is a subcontent, the parent content identifier.parentContentMetadatapath
- If the new content is a subcontent, the path of the metadata where the new content will take place in its parentinputs
- The parameters to transmit to the workflow functions. Cannot be null.com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentprivate Map<String,Object> _doInitialize(String workflowName, String contentName, int initialActionId, Map<String,Object> inputs) throws com.opensymphony.workflow.WorkflowException
com.opensymphony.workflow.WorkflowException
private void _getCommonInputsForCreation(Map<String,Object> inputs, String contentName, String[] contentTypes, String[] mixins, String parentContentId, String parentContentMetadatapath)
public boolean isAvailableAction(WorkflowAwareContent content, int actionId)
content
- the content to consider.actionId
- the workflow action id to checktrue
if the wortkflow action is availablepublic int[] getAvailableActions(WorkflowAwareContent content)
content
- The content to consider. Cannot be null.public int[] getAvailableActions(WorkflowAwareContent content, Map<String,Object> inputs)
content
- The content to consider. Cannot be null.inputs
- The parameters to transmit to the workflow functions. Cannot be null.public Map<String,Object> doAction(WorkflowAwareContent content, int actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
content
- The content to act on. Cannot be null.actionId
- The id of the workflow action to docom.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentpublic Map<String,Object> doAction(WorkflowAwareContent content, int actionId, Map<String,Object> inputs) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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).com.opensymphony.workflow.WorkflowException
- If an error occurred while doing the action on the workflowAmetysRepositoryException
- If cannot get the workflow identifier of the contentprivate UserIdentity _getUser()
public boolean removeMetadata(WorkflowAwareContent contentToEdit, String valuePath, int actionId, String comment) throws com.opensymphony.workflow.WorkflowException
contentToEdit
- the content to editvaluePath
- the value path of the metadata to removeactionId
- the workflow action id to execute if changes have been madecomment
- the comment of the action. Can be null.com.opensymphony.workflow.WorkflowException
- if failed to remove metadatapublic boolean removeStringValueFromMultipleMetadata(WorkflowAwareContent contentToEdit, String valuePath, String valueToRemove, int actionId, String comment) throws com.opensymphony.workflow.WorkflowException
contentToEdit
- the content to editvaluePath
- the value path of the metadatavalueToRemove
- the value to removeactionId
- the workflow action id to execute if changes have been madecomment
- the comment of the action. Can be null.com.opensymphony.workflow.WorkflowException
- if an error occurredpublic boolean removeRepeaterEntry(WorkflowAwareContent contentToEdit, String entryPath, int actionId, String comment) throws com.opensymphony.workflow.WorkflowException
contentToEdit
- the content to editentryPath
- the path of the entry to removeactionId
- the workflow action id to execute if changes have been madecomment
- the comment of the actioncom.opensymphony.workflow.WorkflowException
- if an error occurredprotected void _removeEntry(int position, ModifiableCompositeMetadata repositoryComposite)
position
- The position of the entry to removerepositoryComposite
- the repository composite of the repeaterIllegalArgumentException
- if the position is not between the negative and positive repeater sizeprotected ModifiableCompositeMetadata _getCompositeFromValuePath(WorkflowAwareContent contentToEdit, String valuePath)
contentToEdit
- the content to editvaluePath
- the value pathprotected void _applyChanges(WorkflowAwareContent content, int actionId, String comment) throws com.opensymphony.workflow.WorkflowException
content
- the content to apply changesactionId
- the id of workflow action to executecomment
- the action comment. Can be null.com.opensymphony.workflow.WorkflowException
- if an error occurred