Package org.ametys.plugins.userdirectory
Class AbstractDeleteUDContentComponent
java.lang.Object
org.ametys.plugins.userdirectory.AbstractDeleteUDContentComponent
- All Implemented Interfaces:
Component
,Configurable
,Serviceable
- Direct Known Subclasses:
DeleteOrgUnitComponent
,DeleteUserComponent
public abstract class AbstractDeleteUDContentComponent
extends Object
implements Component, Serviceable, Configurable
Delete UD content component
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record
Store information related to a deletion operation to perform -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected ObservationManager
The observation managerprotected int
The action id to call when references are removedprotected AmetysObjectResolver
The Ametys object resolverprotected SmartContentClientSideElementHelper
Helper for smart content client elementsprotected SolrIndexHelper
The solr index helperprotected TrashElementDAO
The trash element DAO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
True if we can delete the content (check if removable, rights and if locked)protected abstract boolean
_checkBeforeDeletion
(Content content, Map<String, String> rights, Map<String, Object> results, org.slf4j.Logger logger) Check that deletion can be performed without blocking errorsprotected void
_deleteContent
(Content content, Map<String, Object> parameters, Map<String, String> rights, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) Delete one contentprotected void
_finalizeDeleteContents
(Set<AbstractDeleteUDContentComponent.DeletionInfo> contentIdsToDelete, ModifiableAmetysObject parent, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) Finalize the deletion of contents.protected abstract Set
<AbstractDeleteUDContentComponent.DeletionInfo> _getContentIdsToDelete
(Content content, Map<String, Object> parameters, Map<String, String> rights, boolean hidden, Map<String, Object> results, org.slf4j.Logger logger) Get the id of children to be deleted._getEventParametersForDeletion
(Content content) Get parameters for content deletedEvent
protected boolean
Determines if the user has sufficient right for the given contentprotected boolean
Determines if the content is lockedprotected void
_processContentDeletion
(Content content, Map<String, Object> parameters, Map<String, String> rights, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) Delete one contentprotected abstract boolean
_removeRelations
(Content content, Map<String, Object> parameters, org.slf4j.Logger logger) Remove relationsvoid
configure
(Configuration configuration) deleteContents
(List<String> contentsId, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Delete contentsint
deleteContentsWithLog
(List<Content> contentsToRemove, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Delete contents and logs resultsabstract boolean
isContentReferenced
(Content content, org.slf4j.Logger logger) True if the content is referencedvoid
service
(ServiceManager smanager) trashContents
(List<String> contentsId, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Trash contents if possible, or delete it.int
trashContentsWithLog
(List<Content> contentsToRemove, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Trash contents if possible or delete it and logs results
-
Field Details
-
_resolver
The Ametys object resolver -
_observationManager
The observation manager -
_currentUserProvider
The current user provider -
_smartHelper
Helper for smart content client elements -
_solrIndexHelper
The solr index helper -
_trashElementDAO
The trash element DAO -
_removeReferenceActionId
The action id to call when references are removed
-
-
Constructor Details
-
AbstractDeleteUDContentComponent
public AbstractDeleteUDContentComponent()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
trashContentsWithLog
public int trashContentsWithLog(List<Content> contentsToRemove, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Trash contents if possible or delete it and logs results- Parameters:
contentsToRemove
- the list of contents to removeparameters
- the additional parametersrights
- the map of rights id with its prefixlogger
- The logger- Returns:
- the number of deleted contents
-
deleteContentsWithLog
public int deleteContentsWithLog(List<Content> contentsToRemove, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Delete contents and logs results- Parameters:
contentsToRemove
- the list of contents to removeparameters
- the additional parametersrights
- the map of rights id with its prefixlogger
- The logger- Returns:
- the number of deleted contents
-
trashContents
public Map<String,Object> trashContents(List<String> contentsId, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Trash contents if possible, or delete it.- Parameters:
contentsId
- The ids of contents to deleteparameters
- the additional parametersrights
- the map of rights id with its prefixlogger
- The logger- Returns:
- the deleted and undeleted contents
-
deleteContents
public Map<String,Object> deleteContents(List<String> contentsId, Map<String, Object> parameters, Map<String, String> rights, org.slf4j.Logger logger) Delete contents- Parameters:
contentsId
- The ids of contents to deleteparameters
- the additional parametersrights
- the map of rights id with its prefixlogger
- The logger- Returns:
- the deleted and undeleted contents
-
_deleteContent
protected void _deleteContent(Content content, Map<String, Object> parameters, Map<String, String> rights, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) Delete one content- Parameters:
content
- the content to deleteparameters
- the additional parametersrights
- the map of rights id with its prefixresults
- the results maponlyDeletion
-true
to really delete the content, otherwise the content will be trashed if trashablelogger
- The logger
-
_processContentDeletion
protected void _processContentDeletion(Content content, Map<String, Object> parameters, Map<String, String> rights, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) Delete one content- Parameters:
content
- the content to deleteparameters
- the additional parametersrights
- the map of rights id with its prefixresults
- the results maponlyDeletion
-true
to really delete the content, otherwise the content will be trashed if trashablelogger
- The logger
-
_finalizeDeleteContents
protected void _finalizeDeleteContents(Set<AbstractDeleteUDContentComponent.DeletionInfo> contentIdsToDelete, ModifiableAmetysObject parent, Map<String, Object> results, boolean onlyDeletion, org.slf4j.Logger logger) 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 maponlyDeletion
-true
to really delete the contents, otherwise the contents will be trashed if trashablelogger
- The logger
-
_canDeleteContent
protected boolean _canDeleteContent(Content content, Map<String, String> rights, Map<String, Object> results) True if we can delete the content (check if removable, rights and if locked)- Parameters:
content
- the contentrights
- the map of rights id with its prefixresults
- the results map- Returns:
- true if we can delete the content
-
_getEventParametersForDeletion
Get parameters for content deletedEvent
- Parameters:
content
- the removed content- Returns:
- the event's parameters
-
_isLocked
Determines if the content is locked- Parameters:
content
- the content- Returns:
- true if the content is locked
-
_hasRight
Determines if the user has sufficient right for the given content- Parameters:
content
- the contentrights
- the map of rights id with its prefix- Returns:
- true if user has sufficient right
-
isContentReferenced
True if the content is referenced- Parameters:
content
- the contentlogger
- The logger- Returns:
- true if the content is referenced
-
_checkBeforeDeletion
protected abstract boolean _checkBeforeDeletion(Content content, Map<String, String> rights, Map<String, Object> results, org.slf4j.Logger logger) Check that deletion can be performed without blocking errors- Parameters:
content
- The initial content to deleterights
- the map of rights id with its prefixresults
- The resultslogger
- The logger- Returns:
- true if the deletion can be performed
-
_removeRelations
protected abstract boolean _removeRelations(Content content, Map<String, Object> parameters, org.slf4j.Logger logger) Remove relations- Parameters:
content
- the contentparameters
- the additional parameterslogger
- The logger- Returns:
true
if all relations have been removed
-
_getContentIdsToDelete
protected abstract Set<AbstractDeleteUDContentComponent.DeletionInfo> _getContentIdsToDelete(Content content, Map<String, Object> parameters, Map<String, String> rights, boolean hidden, Map<String, Object> results, org.slf4j.Logger logger) 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:
content
- The content to deleteparameters
- the additional parametersrights
- the map of rights id with its prefixhidden
- to hide the trash elementresults
- The resultslogger
- The logger- Returns:
- The id of contents to be deleted
-