public class DeleteODFContentHelper extends AbstractLogEnabled implements Component, Serviceable
Modifier and Type | Class and Description |
---|---|
static class |
DeleteODFContentHelper.DeleteMode
Enumeration for the mode of deletion
|
Modifier and Type | Field and Description |
---|---|
private ContentDAO |
_contentDAO
The Content DAO
|
private ContentWorkflowHelper |
_contentWorkflowHelper
The Content workflow helper
|
private CurrentUserProvider |
_currentUserProvider
The current user provider
|
private ObservationManager |
_observationManager
Observer manager.
|
private ODFHelper |
_odfHelper
The ODF helper
|
private AmetysObjectResolver |
_resolver
Ametys object resolver
|
private RightManager |
_rightManager
The rights manager
|
private SmartContentClientSideElementHelper |
_smartHelper
Helper for smart content client elements
|
private SolrIndexer |
_solrIndexer
The Solr indexer.
|
static String |
ROLE
Avalon role.
|
Constructor and Description |
---|
DeleteODFContentHelper() |
Modifier and Type | Method and Description |
---|---|
private void |
_applyChanges(WorkflowAwareContent content,
int actionId) |
private boolean |
_canDeleteContent(Content content,
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,
Map<String,Object> results)
Check that deletion can be performed without blocking errors
|
private boolean |
_checkChildrenBeforeDeletion(Content rootContentToDelete,
Content contentToCheck,
DeleteODFContentHelper.DeleteMode mode,
Map<String,Object> results)
Browse children to check if deletion could succeed
|
private boolean |
_checkChildrenBeforeDeletionOfOrgUnit(Content rootContentToDelete,
Content contentToCheck,
DeleteODFContentHelper.DeleteMode mode,
Map<String,Object> results) |
private boolean |
_checkChildrenBeforeDeletionOfProgramItem(Content rootContentToDelete,
Content contentToCheck,
DeleteODFContentHelper.DeleteMode mode,
Map<String,Object> results) |
private boolean |
_checkParentsBeforeDeletion(Content content,
Map<String,Object> results) |
private void |
_commitAllChanges()
Commit all changes in solr
|
private void |
_deleteContent(Content content,
DeleteODFContentHelper.DeleteMode deleteMode,
Map<String,Object> results)
Delete one content
|
private void |
_deleteOrgUnit(OrgUnit orgUnit,
Map<String,Object> results)
Delete one orgUnit
|
private void |
_deleteProgramItem(ProgramItem item,
DeleteODFContentHelper.DeleteMode mode,
Map<String,Object> results)
Delete a program item
|
private void |
_finalizeDeleteContents(Set<String> contentIdsToDelete,
ModifiableAmetysObject parent,
Map<String,Object> results)
Finalize the deletion of contents.
|
private Set<String> |
_getChildrenIdToDelete(OrgUnit orgUnit,
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)
Get the id of children to be deleted.
|
private Map<String,Object> |
_getContentDefaultParameters(Content content) |
private Map<String,Object> |
_getEventParametersForDeletion(Content content)
Get parameters for content deleted
Event |
private 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 referenced
|
private 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 list
|
Map<String,Object> |
deleteContents(List<String> contentsId,
String modeParam)
Delete ODF contents
|
boolean |
hasRight(Content content)
Determines if the user has sufficient right for the given content
|
boolean |
isContentReferenced(Content content)
Test if content is still referenced before removing it
|
void |
service(ServiceManager manager) |
getLogger, setLogger
private AmetysObjectResolver _resolver
private ODFHelper _odfHelper
private ObservationManager _observationManager
private SolrIndexer _solrIndexer
private ContentWorkflowHelper _contentWorkflowHelper
private ContentDAO _contentDAO
private CurrentUserProvider _currentUserProvider
private RightManager _rightManager
private SmartContentClientSideElementHelper _smartHelper
public DeleteODFContentHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,Object> deleteContents(List<String> contentsId, String modeParam)
contentsId
- The ids of contents to deletemodeParam
- The mode of deletionprivate void _deleteContent(Content content, DeleteODFContentHelper.DeleteMode deleteMode, Map<String,Object> results)
content
- the content to deletedeleteMode
- The deletion moderesults
- the results mappublic boolean isContentReferenced(Content content)
content
- The content to removeprivate boolean _isContentReferenced(Content content, Content rootContent)
content
- The content to removerootContent
- the initial content to delete (can be null if checkRoot is false)private boolean _isReferencedOrgUnit(OrgUnit orgUnit)
orgUnit
- the orgUnitprivate Map<String,Object> _getContentDefaultParameters(Content content)
private boolean _checkBeforeDeletion(Content content, DeleteODFContentHelper.DeleteMode mode, Map<String,Object> results)
content
- The initial content to deletemode
- The deletion moderesults
- The resultsprivate boolean _checkParentsBeforeDeletion(Content content, Map<String,Object> results)
private boolean _checkChildrenBeforeDeletion(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, Map<String,Object> results)
rootContentToDelete
- The initial content to deletecontentToCheck
- The current content to checkmode
- The deletion moderesults
- The resultprivate boolean _checkChildrenBeforeDeletionOfProgramItem(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, Map<String,Object> results)
private boolean _checkChildrenBeforeDeletionOfOrgUnit(Content rootContentToDelete, Content contentToCheck, DeleteODFContentHelper.DeleteMode mode, Map<String,Object> results)
private boolean _removeRelations(List<? extends WorkflowAwareContent> contentsToEdit, Content refContentToRemove, String metadataName, int actionId, Map<String,Object> results)
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 mapprivate boolean _removeRelation(WorkflowAwareContent contentToEdit, Content refContentToRemove, String metadataName, int actionId, Map<String,Object> results)
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 mapprivate void _deleteProgramItem(ProgramItem item, DeleteODFContentHelper.DeleteMode mode, Map<String,Object> results)
item
- The program item to deletemode
- The deletion moderesults
- The resultsprivate void _deleteOrgUnit(OrgUnit orgUnit, Map<String,Object> results)
orgUnit
- the orgUnit to deleteresults
- the results mapprivate void _finalizeDeleteContents(Set<String> contentIdsToDelete, ModifiableAmetysObject parent, Map<String,Object> results)
contentIdsToDelete
- the list of content id to deleteparent
- the jcr parent for saving changesresults
- the results mapprivate void _commitAllChanges()
private boolean _canDeleteContent(Content content, Map<String,Object> results)
content
- the contentresults
- the results mapprivate void _applyChanges(WorkflowAwareContent content, int actionId) throws com.opensymphony.workflow.WorkflowException
com.opensymphony.workflow.WorkflowException
private Map<String,Object> _getEventParametersForDeletion(Content content)
Event
content
- the removed contentprivate List<? extends WorkflowAwareContent> _getParents(Content content)
private Set<String> _getChildrenIdToDelete(OrgUnit orgUnit, Map<String,Object> results)
orgUnit
- The orgunit to deleteresults
- The resultsprivate Set<String> _getChildrenIdToDelete(ProgramItem contentToDelete, ProgramItem initialContentToDelete, Map<String,Object> results, DeleteODFContentHelper.DeleteMode mode)
contentToDelete
- The content to delete in the tree of initial content to deleteinitialContentToDelete
- The initial content to deleteresults
- The resultsmode
- The deletion modepublic boolean hasRight(Content content)
content
- the contentprivate String _getRightId(Content content)
private boolean _isReferencedContentCheckingRoot(ProgramItem programItem, Content initialContentToDelete)
programItem
- the program iteminitialContentToDelete
- the initial content to delete