Class ContentWorkflowHelper

    • Method Detail

      • createContent

        public Map<String,​ObjectcreateContent​(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 create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        contentTitle - The new title
        contentTypes - 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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • createContent

        public Map<String,​ObjectcreateContent​(String workflowName,
                                                      int initialActionId,
                                                      String contentName,
                                                      Map<String,​String> titleVariants,
                                                      String[] contentTypes,
                                                      String[] mixins)
                                               throws AmetysRepositoryException,
                                                      com.opensymphony.workflow.WorkflowException
        Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).
        Parameters:
        workflowName - The name of the workflow to create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        titleVariants - The title's variants
        contentTypes - 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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • createContent

        public Map<String,​ObjectcreateContent​(String workflowName,
                                                      int initialActionId,
                                                      String contentName,
                                                      String contentTitle,
                                                      String[] contentTypes,
                                                      String[] mixins,
                                                      String languageCode,
                                                      String parentContentId,
                                                      String parentContentMetadatapath)
                                               throws AmetysRepositoryException,
                                                      com.opensymphony.workflow.WorkflowException
        Creates a content using the workflow (with the CreateContentFunction).
        Parameters:
        workflowName - The name of the workflow to create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        contentTitle - The new title
        contentTypes - 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 parent
        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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • createContent

        public Map<String,​ObjectcreateContent​(String workflowName,
                                                      int initialActionId,
                                                      String contentName,
                                                      Map<String,​String> titleVariants,
                                                      String[] contentTypes,
                                                      String[] mixins,
                                                      String parentContentId,
                                                      String parentContentMetadatapath)
                                               throws AmetysRepositoryException,
                                                      com.opensymphony.workflow.WorkflowException
        Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).
        Parameters:
        workflowName - The name of the workflow to create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        titleVariants - The title's variants
        contentTypes - 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 parent
        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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • createContent

        public Map<String,​ObjectcreateContent​(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
        Creates a content using the workflow (with the CreateContentFunction).
        Parameters:
        workflowName - The name of the workflow to create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        contentTitle - The new title
        contentTypes - 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 parent
        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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • createContent

        public Map<String,​ObjectcreateContent​(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
        Creates a multilingual content with a multilingual title using the workflow (with the CreateContentFunction).
        Parameters:
        workflowName - The name of the workflow to create
        initialActionId - The workflow action id that creates content
        contentName - The new name
        titleVariants - The title's variants
        contentTypes - 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 parent
        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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • isAvailableAction

        public boolean isAvailableAction​(WorkflowAwareContent content,
                                         int actionId)
        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
      • getAvailableActions

        public int[] getAvailableActions​(WorkflowAwareContent content)
        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

        public int[] getAvailableActions​(WorkflowAwareContent content,
                                         Map<String,​Object> inputs)
        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,​ObjectdoAction​(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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • doAction

        public Map<String,​ObjectdoAction​(WorkflowAwareContent content,
                                                 int actionId,
                                                 Map<String,​Object> inputs)
                                          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
        inputs - 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 workflow
        AmetysRepositoryException - If cannot get the workflow identifier of the content
      • removeMetadata

        public boolean removeMetadata​(WorkflowAwareContent contentToEdit,
                                      String valuePath,
                                      int actionId,
                                      String comment)
                               throws com.opensymphony.workflow.WorkflowException
        Remove metadata from content and apply changes
        Parameters:
        contentToEdit - the content to edit
        valuePath - the value path of the metadata to remove
        actionId - the workflow action id to execute if changes have been made
        comment - the comment of the action. Can be null.
        Returns:
        true if changes are made
        Throws:
        com.opensymphony.workflow.WorkflowException - if failed to remove metadata
      • removeStringValueFromMultipleMetadata

        public boolean removeStringValueFromMultipleMetadata​(WorkflowAwareContent contentToEdit,
                                                             String valuePath,
                                                             String valueToRemove,
                                                             int actionId,
                                                             String comment)
                                                      throws com.opensymphony.workflow.WorkflowException
        Remove string value of multiple metadata from content and apply changes
        Parameters:
        contentToEdit - the content to edit
        valuePath - the value path of the metadata
        valueToRemove - the value to remove
        actionId - the workflow action id to execute if changes have been made
        comment - the comment of the action. Can be null.
        Returns:
        true if changes are made
        Throws:
        com.opensymphony.workflow.WorkflowException - if an error occurred
      • removeRepeaterEntry

        public boolean removeRepeaterEntry​(WorkflowAwareContent contentToEdit,
                                           String entryPath,
                                           int actionId,
                                           String comment)
                                    throws com.opensymphony.workflow.WorkflowException
        Remove repeater entry from content and apply changes
        Parameters:
        contentToEdit - the content to edit
        entryPath - the path of the entry to remove
        actionId - the workflow action id to execute if changes have been made
        comment - the comment of the action
        Returns:
        true if changes are made
        Throws:
        com.opensymphony.workflow.WorkflowException - if an error occurred
      • _removeEntry

        protected void _removeEntry​(int position,
                                    ModifiableCompositeMetadata repositoryComposite)
        Removes the repeater entry at the given position. The position starts at index 1. The position can be an integer between 1 and the repeater size to remove an entry from the beginning Or the position can an integer between 0 and - the repeater size to remove an entry from the end (0 means at the end, -1 means before the last one and so on)
        Parameters:
        position - The position of the entry to remove
        repositoryComposite - the repository composite of the repeater
        Throws:
        IllegalArgumentException - if the position is not between the negative and positive repeater size
      • _getCompositeFromValuePath

        protected ModifiableCompositeMetadata _getCompositeFromValuePath​(WorkflowAwareContent contentToEdit,
                                                                         String valuePath)
        Get the last composite and the metadata name from a value path. For example, values[1]/value returns the composite of the first data of values repeater and the metadata name value
        Parameters:
        contentToEdit - the content to edit
        valuePath - the value path
        Returns:
        the pair of composite and metadata name
      • _applyChanges

        protected void _applyChanges​(WorkflowAwareContent content,
                                     int actionId,
                                     String comment)
                              throws com.opensymphony.workflow.WorkflowException
        Apply changes on content: create a new version and notify listeners.
        Parameters:
        content - the content to apply changes
        actionId - the id of workflow action to execute
        comment - the action comment. Can be null.
        Throws:
        com.opensymphony.workflow.WorkflowException - if an error occurred