Class DeleteODFContentHelper

    • Method Detail

      • deleteContents

        public Map<String,​ObjectdeleteContents​(List<String> contentsId,
                                                       String modeParam)
        Delete ODF contents
        Parameters:
        contentsId - The ids of contents to delete
        modeParam - The mode of deletion
        Returns:
        the deleted and undeleted contents
      • deleteContents

        public Map<String,​ObjectdeleteContents​(List<String> contentsId,
                                                       String modeParam,
                                                       boolean ignoreRights)
        Delete ODF contents
        Parameters:
        contentsId - The ids of contents to delete
        modeParam - The mode of deletion
        ignoreRights - If true, bypass the rights check during the deletion
        Returns:
        the deleted and undeleted contents
      • deleteContentsWithLog

        public Map<String,​ObjectdeleteContentsWithLog​(List<String> contentsId,
                                                              String modeParam)
        Delete ODF contents
        Parameters:
        contentsId - The ids of contents to delete
        modeParam - The mode of deletion
        Returns:
        the deleted and undeleted contents
      • deleteContentsWithLog

        public Map<String,​ObjectdeleteContentsWithLog​(List<String> contentsId,
                                                              String modeParam,
                                                              boolean ignoreRights)
        Delete ODF contents
        Parameters:
        contentsId - The ids of contents to delete
        modeParam - The mode of deletion
        ignoreRights - If true, bypass the rights check during the deletion
        Returns:
        the deleted and undeleted contents
      • _deleteContent

        private void _deleteContent​(Content content,
                                    DeleteODFContentHelper.DeleteMode deleteMode,
                                    boolean ignoreRights,
                                    Map<String,​Object> results)
        Delete one content
        Parameters:
        content - the content to delete
        deleteMode - The deletion mode
        ignoreRights - If true, bypass the rights check during the deletion
        results - the results map
      • isContentReferenced

        public boolean isContentReferenced​(Content content)
        Test if content is still referenced before removing it
        Parameters:
        content - The content to remove
        Returns:
        true if content is still referenced
      • _isContentReferenced

        private boolean _isContentReferenced​(Content content,
                                             Content rootContent)
        Test if content is still referenced before removing it.
        Parameters:
        content - The content to remove
        rootContent - the initial content to delete (can be null if checkRoot is false)
        Returns:
        true if content is still referenced
      • _isReferencedOrgUnit

        private boolean _isReferencedOrgUnit​(OrgUnit orgUnit)
        True if the orgUnit is referenced
        Parameters:
        orgUnit - the orgUnit
        Returns:
        true if the orgUnit is referenced
      • _checkBeforeDeletion

        private boolean _checkBeforeDeletion​(Content content,
                                             DeleteODFContentHelper.DeleteMode mode,
                                             boolean ignoreRights,
                                             Map<String,​Object> results)
        Check that deletion can be performed without blocking errors
        Parameters:
        content - The initial content to delete
        mode - The deletion mode
        ignoreRights - If true, bypass the rights check during the deletion
        results - The results
        Returns:
        true if the deletion can be performed
      • _checkChildrenBeforeDeletion

        private boolean _checkChildrenBeforeDeletion​(Content rootContentToDelete,
                                                     Content contentToCheck,
                                                     DeleteODFContentHelper.DeleteMode mode,
                                                     boolean ignoreRights,
                                                     Map<String,​Object> results)
        Browse children to check if deletion could succeed
        Parameters:
        rootContentToDelete - The initial content to delete
        contentToCheck - The current content to check
        mode - The deletion mode
        ignoreRights - If true, bypass the rights check during the deletion
        results - The result
        Returns:
        true if the deletion can be processed
      • _removeRelations

        private boolean _removeRelations​(List<? extends WorkflowAwareContent> contentsToEdit,
                                         Content refContentToRemove,
                                         String metadataName,
                                         int actionId,
                                         Map<String,​Object> results)
        Remove the relations between the content and its contents list
        Parameters:
        contentsToEdit - the contents to edit
        refContentToRemove - The referenced content to be removed from contents
        metadataName - The name of metadata holding the relationship
        actionId - The id of workflow action to edit the relation
        results - the results map
        Returns:
        true if remove relation successfully
      • _removeRelation

        private boolean _removeRelation​(WorkflowAwareContent contentToEdit,
                                        Content refContentToRemove,
                                        String metadataName,
                                        int actionId,
                                        Map<String,​Object> results)
        Remove the relation parent-child relation on content.
        Parameters:
        contentToEdit - The content to modified
        refContentToRemove - The referenced content to be removed from content
        metadataName - The name of metadata holding the child or parent relationship
        actionId - The id of workflow action to edit the relation
        results - the results map
        Returns:
        boolean true if remove relation successfully
      • _deleteOrgUnit

        private void _deleteOrgUnit​(OrgUnit orgUnit,
                                    boolean ignoreRights,
                                    Map<String,​Object> results)
        Delete one orgUnit
        Parameters:
        orgUnit - the orgUnit to delete
        ignoreRights - If true, bypass the rights check during the deletion
        results - the results map
      • _finalizeDeleteContents

        private void _finalizeDeleteContents​(Set<String> contentIdsToDelete,
                                             ModifiableAmetysObject parent,
                                             Map<String,​Object> results)
        Finalize the deletion of contents. Call observers and remove contents
        Parameters:
        contentIdsToDelete - the list of content id to delete
        parent - the jcr parent for saving changes
        results - the results map
      • _canDeleteContent

        private boolean _canDeleteContent​(Content content,
                                          boolean ignoreRights,
                                          Map<String,​Object> results)
        True if we can delete the content (check if removable, rights and if locked)
        Parameters:
        content - the content
        ignoreRights - If true, bypass the rights check during the deletion
        results - the results map
        Returns:
        true if we can delete the content
      • _applyChanges

        private void _applyChanges​(WorkflowAwareContent content,
                                   int actionId)
                            throws com.opensymphony.workflow.WorkflowException
        Throws:
        com.opensymphony.workflow.WorkflowException
      • _getChildrenIdToDelete

        private Set<String_getChildrenIdToDelete​(OrgUnit orgUnit,
                                                   boolean ignoreRights,
                                                   Map<String,​Object> results)
        Get the id of children to be deleted. All children shared with other contents which are not part of deletion, will be not deleted.
        Parameters:
        orgUnit - The orgunit to delete
        ignoreRights - If true, bypass the rights check during the deletion
        results - The results
        Returns:
        The id of contents to be deleted
      • _getChildrenIdToDelete

        private Set<String_getChildrenIdToDelete​(ProgramItem contentToDelete,
                                                   ProgramItem initialContentToDelete,
                                                   Map<String,​Object> results,
                                                   DeleteODFContentHelper.DeleteMode mode,
                                                   boolean ignoreRights)
        Get the id of children to be deleted. All children shared with other contents which are not part of deletion, will be not deleted.
        Parameters:
        contentToDelete - The content to delete in the tree of initial content to delete
        initialContentToDelete - The initial content to delete
        results - The results
        mode - The deletion mode
        ignoreRights - If true, bypass the rights check during the deletion
        Returns:
        The id of contents to be deleted
      • hasRight

        public boolean hasRight​(Content content)
        Determines if the user has sufficient right for the given content
        Parameters:
        content - the content
        Returns:
        true if user has sufficient right
      • _isReferencedContentCheckingRoot

        private boolean _isReferencedContentCheckingRoot​(ProgramItem programItem,
                                                         Content initialContentToDelete)
        True if the content is referenced (we are ignoring parent references if they have same root)
        Parameters:
        programItem - the program item
        initialContentToDelete - the initial content to delete
        Returns:
        true if the content is referenced