Package org.ametys.odf.helper
Class DeleteODFContentHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.odf.helper.DeleteODFContentHelper
-
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
public class DeleteODFContentHelper extends AbstractLogEnabled implements Component, Serviceable
Helper to delete an ODF content.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeleteODFContentHelper.DeleteModeEnumeration for the mode of deletion
-
Field Summary
Fields Modifier and Type Field Description private ContentHelper_contentHelperThe content helperprivate ContentWorkflowHelper_contentWorkflowHelperThe Content workflow helperprivate CurrentUserProvider_currentUserProviderThe current user providerprivate ObservationManager_observationManagerObserver manager.private ODFHelper_odfHelperThe ODF helperprivate AmetysObjectResolver_resolverAmetys object resolverprivate RightManager_rightManagerThe rights managerprivate SmartContentClientSideElementHelper_smartHelperHelper for smart content client elementsprivate SolrIndexer_solrIndexerThe Solr indexer.static StringROLEAvalon role.
-
Constructor Summary
Constructors Constructor Description DeleteODFContentHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_applyChanges(WorkflowAwareContent content, int actionId)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)private boolean_checkBeforeDeletion(Content content, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)Check that deletion can be performed without blocking errorsprivate boolean_checkChildrenBeforeDeletion(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)Browse children to check if deletion could succeedprivate boolean_checkChildrenBeforeDeletionOfOrgUnit(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)private boolean_checkChildrenBeforeDeletionOfProgramItem(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)private boolean_checkParentsBeforeDeletion(Content content, Map<String,Object> results)private void_commitAllChanges()Commit all changes in solrprivate void_deleteContent(Content content, DeleteODFContentHelper.DeleteMode deleteMode, boolean ignoreRights, Map<String,Object> results)Delete one contentprivate void_deleteOrgUnit(OrgUnit orgUnit, boolean ignoreRights, Map<String,Object> results)Delete one orgUnitprivate void_deleteProgramItem(ProgramItem item, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)Delete a program itemprivate void_finalizeDeleteContents(Set<String> contentIdsToDelete, ModifiableAmetysObject parent, Map<String,Object> results)Finalize the deletion of contents.private Set<String>_getChildrenIdToDelete(OrgUnit orgUnit, boolean ignoreRights, Map<String,Object> results)Get the id of children to be deleted.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.private Map<String,Object>_getEventParametersForDeletion(Content content)Get parameters for content deletedEventprivate List<? extends WorkflowAwareContent>_getParents(Content content)private String_getRightId(Content content)private boolean_isContentReferenced(Content content, Content rootContent)Test if content is still referenced before removing it.private boolean_isReferencedContentCheckingRoot(ProgramItem programItem, Content initialContentToDelete)True if the content is referenced (we are ignoring parent references if they have same root)private boolean_isReferencedOrgUnit(OrgUnit orgUnit)True if the orgUnit is referencedprivate boolean_removeRelation(WorkflowAwareContent contentToEdit, Content refContentToRemove, String metadataName, int actionId, Map<String,Object> results)Remove the relation parent-child relation on content.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 listMap<String,Object>deleteContents(List<String> contentsId, String modeParam)Delete ODF contentsMap<String,Object>deleteContents(List<String> contentsId, String modeParam, boolean ignoreRights)Delete ODF contentsMap<String,Object>deleteContentsWithLog(List<String> contentsId, String modeParam)Delete ODF contentsMap<String,Object>deleteContentsWithLog(List<String> contentsId, String modeParam, boolean ignoreRights)Delete ODF contentsbooleanhasRight(Content content)Determines if the user has sufficient right for the given contentbooleanisContentReferenced(Content content)Test if content is still referenced before removing itvoidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_resolver
private AmetysObjectResolver _resolver
Ametys object resolver
-
_odfHelper
private ODFHelper _odfHelper
The ODF helper
-
_observationManager
private ObservationManager _observationManager
Observer manager.
-
_solrIndexer
private SolrIndexer _solrIndexer
The Solr indexer.
-
_contentWorkflowHelper
private ContentWorkflowHelper _contentWorkflowHelper
The Content workflow helper
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
The current user provider
-
_rightManager
private RightManager _rightManager
The rights manager
-
_contentHelper
private ContentHelper _contentHelper
The content helper
-
_smartHelper
private SmartContentClientSideElementHelper _smartHelper
Helper for smart content client elements
-
-
Constructor Detail
-
DeleteODFContentHelper
public DeleteODFContentHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
deleteContents
public Map<String,Object> deleteContents(List<String> contentsId, String modeParam)
Delete ODF contents- Parameters:
contentsId- The ids of contents to deletemodeParam- The mode of deletion- Returns:
- the deleted and undeleted contents
-
deleteContents
public Map<String,Object> deleteContents(List<String> contentsId, String modeParam, boolean ignoreRights)
Delete ODF contents- Parameters:
contentsId- The ids of contents to deletemodeParam- The mode of deletionignoreRights- If true, bypass the rights check during the deletion- Returns:
- the deleted and undeleted contents
-
deleteContentsWithLog
public Map<String,Object> deleteContentsWithLog(List<String> contentsId, String modeParam)
Delete ODF contents- Parameters:
contentsId- The ids of contents to deletemodeParam- The mode of deletion- Returns:
- the deleted and undeleted contents
-
deleteContentsWithLog
public Map<String,Object> deleteContentsWithLog(List<String> contentsId, String modeParam, boolean ignoreRights)
Delete ODF contents- Parameters:
contentsId- The ids of contents to deletemodeParam- The mode of deletionignoreRights- 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 deletedeleteMode- The deletion modeignoreRights- If true, bypass the rights check during the deletionresults- 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 removerootContent- 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 deletemode- The deletion modeignoreRights- If true, bypass the rights check during the deletionresults- The results- Returns:
- true if the deletion can be performed
-
_checkParentsBeforeDeletion
private boolean _checkParentsBeforeDeletion(Content content, Map<String,Object> results)
-
_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 deletecontentToCheck- The current content to checkmode- The deletion modeignoreRights- If true, bypass the rights check during the deletionresults- The result- Returns:
- true if the deletion can be processed
-
_checkChildrenBeforeDeletionOfProgramItem
private boolean _checkChildrenBeforeDeletionOfProgramItem(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)
-
_checkChildrenBeforeDeletionOfOrgUnit
private boolean _checkChildrenBeforeDeletionOfOrgUnit(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)
-
_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 editrefContentToRemove- The referenced content to be removed from contentsmetadataName- The name of metadata holding the relationshipactionId- The id of workflow action to edit the relationresults- 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 modifiedrefContentToRemove- The referenced content to be removed from contentmetadataName- The name of metadata holding the child or parent relationshipactionId- The id of workflow action to edit the relationresults- the results map- Returns:
- boolean true if remove relation successfully
-
_deleteProgramItem
private void _deleteProgramItem(ProgramItem item, DeleteODFContentHelper.DeleteMode mode, boolean ignoreRights, Map<String,Object> results)
Delete a program item- Parameters:
item- The program item to deletemode- The deletion modeignoreRights- If true, bypass the rights check during the deletionresults- The results
-
_deleteOrgUnit
private void _deleteOrgUnit(OrgUnit orgUnit, boolean ignoreRights, Map<String,Object> results)
Delete one orgUnit- Parameters:
orgUnit- the orgUnit to deleteignoreRights- If true, bypass the rights check during the deletionresults- 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 deleteparent- the jcr parent for saving changesresults- the results map
-
_commitAllChanges
private void _commitAllChanges()
Commit all changes in solr
-
_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 contentignoreRights- If true, bypass the rights check during the deletionresults- 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
-
_getEventParametersForDeletion
private Map<String,Object> _getEventParametersForDeletion(Content content)
Get parameters for content deletedEvent- Parameters:
content- the removed content- Returns:
- the event's parameters
-
_getParents
private List<? extends WorkflowAwareContent> _getParents(Content content)
-
_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 deleteignoreRights- If true, bypass the rights check during the deletionresults- 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 deleteinitialContentToDelete- The initial content to deleteresults- The resultsmode- The deletion modeignoreRights- 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
-
_getRightId
private String _getRightId(Content content)
-
_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 iteminitialContentToDelete- the initial content to delete- Returns:
- true if the content is referenced
-
-