Class CopyODFContentClientSideElement

    • Method Detail

      • canCopyTo

        public Map<String,​ObjectcanCopyTo​(String copiedContentId,
                                                  String targetContentId,
                                                  Map<String,​Object> contextualParameters)
        Determines if a ODF content can be copied and linked to a target content
        Parameters:
        copiedContentId - The id of copied content
        targetContentId - The id of target content
        contextualParameters - the contextual parameters
        Returns:
        the result with success to true if copy is available
      • createContentByCopy

        public Map<String,​ObjectcreateContentByCopy​(String baseContentId,
                                                            String newContentTitle,
                                                            String metadataSetNameToCopy,
                                                            String fallbackMetadataSetNameToCopy,
                                                            String metadataSetTypeToCopy,
                                                            int initActionId,
                                                            int editActionId,
                                                            String duplicationModeAsString,
                                                            String parentContentId)
                                                     throws Exception
        Creates a content by copy of another one.
        Also handle the possible inner duplication depending on the duplication mode for each metadata of type "content".
        Parameters:
        baseContentId - The id of content to copy
        newContentTitle - The title of content to create
        metadataSetNameToCopy - The metadata set name to copy. Can be null
        fallbackMetadataSetNameToCopy - The fallback metadata set name to use if 'metadataSetNameToCopy' does not exist. Can be null
        metadataSetTypeToCopy - The metadata set type to copy. Can be null
        initActionId - The init workflow action id for copy
        editActionId - The workflow action for editing content
        duplicationModeAsString - the duplication mode
        parentContentId - the parent id under which the duplicated content will be created. Can be null
        Returns:
        the copy result
        Throws:
        Exception - if an error occurred during copy
      • _initializeShareableFields

        protected void _initializeShareableFields​(String copiedContentId,
                                                  String parentContentId)
        Initialize shareable fields for the copied content
        Parameters:
        copiedContentId - the copied content id
        parentContentId - the parent content id
      • checkBeforeDuplication

        protected boolean checkBeforeDuplication​(String programItemId,
                                                 String parentContentId,
                                                 CopyODFContentClientSideElement.DuplicationMode duplicationMode,
                                                 Map<String,​Object> results)
        Check that duplication can be performed without blocking errors
        Parameters:
        programItemId - The program item id to copy
        parentContentId - The parent content id
        duplicationMode - The duplication mode
        results - the results map
        Returns:
        true if the duplication can be performed
      • _getCourse

        protected Set<Course_getCourse​(ProgramItem programItem)
        Get all first courses in sub item of the program item
        Parameters:
        programItem - the program item
        Returns:
        a set of courses
      • _linkCopiedContentToParent

        protected void _linkCopiedContentToParent​(String copiedContentId,
                                                  String parentContentId)
        Check if we can add the copied content to the parent content and set the relation
        Parameters:
        copiedContentId - the copied content id
        parentContentId - the parent content id
      • _addRelation

        protected boolean _addRelation​(WorkflowAwareContent parentContent,
                                       WorkflowAwareContent childContent,
                                       String parentMetadataName,
                                       String childMetadataName,
                                       int actionId)
        Add the relation parent-child relation on content.
        Parameters:
        parentContent - The parent content
        childContent - The child content to be added from parentContent
        parentMetadataName - The name of the parent metadata holding the child relationship
        childMetadataName - The name of the child metadata holding the parent relationship
        actionId - The id of workflow action to edit the relation
        Returns:
        boolean true if add relation successfully
      • setJCRReference

        protected void setJCRReference​(WorkflowAwareContent contentToEdit,
                                       Content refContent,
                                       String attributeName)
        Add the jcr relation on content.
        Parameters:
        contentToEdit - The content edit
        refContent - The referenced content to be added
        attributeName - The name of the attribute holding the relationship
      • _applyChanges

        protected void _applyChanges​(WorkflowAwareContent content,
                                     int actionId)
                              throws com.opensymphony.workflow.WorkflowException
        Apply changes to the content
        Parameters:
        content - the content changed
        actionId - the workflow action id
        Throws:
        com.opensymphony.workflow.WorkflowException - if an error occurred