Package org.nuxeo.ecm.core.trash
Class AbstractTrashService
java.lang.Object
org.nuxeo.ecm.core.trash.AbstractTrashService
- All Implemented Interfaces:
TrashService
,TrashService
- Direct Known Subclasses:
BridgeTrashService
,LifeCycleTrashService
,PropertyTrashService
Basic implementation of
TrashService
.- Since:
- 10.1
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Path-based comparator used to put folders before their children.Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.api.trash.TrashService
TrashService.Feature
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Pattern
Matches names resulting from a collision, suffixed with a time in milliseconds, created by DuplicatedNameFixer.static final String
Deprecated.since 2023protected static final String
static final String
Deprecated.since 2023protected static final Pattern
Matches names of documents in the trash, created byTrashService.trashDocuments(List)
.static final String
Fields inherited from interface org.nuxeo.ecm.core.api.trash.TrashService
ABOUT_TO_TRASH, ABOUT_TO_UNTRASH, DISABLE_TRASH_RENAMING, DOCUMENT_TRASHED, DOCUMENT_UNTRASHED
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canDelete
(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies) Is at least one doc deletable?boolean
canPurgeOrUntrash
(List<DocumentModel> docs, NuxeoPrincipal principal) Are all documents purgeable/undeletable?protected void
checkCanTrash
(DocumentModel model) Deprecated.since 2023,AbstractSession.canRemoveDocument(DocumentRef)
does this checkboolean
Is at least one doc deletable according to its container?boolean
folderAllowsDelete
(DocumentModel folder) Can a child of the folder be trashed?getAboveDocument
(DocumentModel doc, Set<Path> rootPaths) Gets the closest document's ancestor above all the paths.getAboveDocument
(DocumentModel doc, NuxeoPrincipal principal) Gets the first non trashed ancestor.protected static String
getDocuments
(DocumentModel parent) Get all documents from the trash of the current document.protected String
getFirstGroup
(Pattern pattern, String name) protected TrashInfo
getInfo
(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted) getTrashInfo
(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted) Gets the trash info for a list of documents.boolean
isMangledName
(String docName) mangleName
(DocumentModel doc) Mangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.protected void
notifyEvent
(CoreSession session, String eventId, DocumentModel doc) protected void
notifyEvent
(CoreSession session, String eventId, DocumentModel doc, boolean immediate) protected void
notifyEvent
(CoreSession session, String eventId, DocumentModel doc, boolean immediate, boolean inline) void
purgeDocuments
(CoreSession session, List<DocumentRef> docRefs) Purges (completely deletes) documents.void
purgeDocumentsUnder
(DocumentModel parent) Purges (completely deletes) trashed documents under the given parent.protected static boolean
underOneOf
(Path testedPath, Set<Path> paths) unmangleName
(CoreSession session, DocumentRef parentRef, String docName) Unmangles the name of a document in the trash to find its un-trashed name.Unmangles the name of a document in the trash to find its un-trashed name.void
untrashDocuments
(List<DocumentModel> docs) Unmoves documents from the trash.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.ecm.core.api.trash.TrashService
canPurgeOrUntrash, hasFeature, isTrashed, trashDocument, trashDocuments, untrashDocument
Methods inherited from interface org.nuxeo.ecm.core.trash.TrashService
canPurgeOrUndelete, undeleteDocuments
-
Field Details
-
TRASHED_QUERY
- See Also:
-
RETENTION_QUERY
Deprecated.since 2023- See Also:
-
LEGAL_HOLD_QUERY
Deprecated.since 2023- See Also:
-
PATH_SEPARATOR
- Since:
- 11.1
- See Also:
-
TRASHED_PATTERN
Matches names of documents in the trash, created byTrashService.trashDocuments(List)
. -
COLLISION_PATTERN
Matches names resulting from a collision, suffixed with a time in milliseconds, created by DuplicatedNameFixer. We also attempt to remove this when getting a doc out of the trash.
-
-
Constructor Details
-
AbstractTrashService
public AbstractTrashService()
-
-
Method Details
-
folderAllowsDelete
Description copied from interface:TrashService
Can a child of the folder be trashed?- Specified by:
folderAllowsDelete
in interfaceTrashService
- Parameters:
folder
- the folder- Returns:
true
if the folder allows its children to be trashed
-
checkDeletePermOnParents
Description copied from interface:TrashService
Is at least one doc deletable according to its container?- Specified by:
checkDeletePermOnParents
in interfaceTrashService
- Parameters:
docs
- the documents- Returns:
true
if one doc is in a folder that allows its children to be trashed
-
canDelete
Description copied from interface:TrashService
Is at least one doc deletable?- Specified by:
canDelete
in interfaceTrashService
- Parameters:
docs
- the documentsprincipal
- the current user (to check locks)checkProxies
-true
to count proxies as non-deletable- Returns:
true
if at least one doc is deletable
-
canPurgeOrUntrash
Description copied from interface:TrashService
Are all documents purgeable/undeletable?Documents need to be in the trash for this to be true, in addition to the standard permission checks.
- Specified by:
canPurgeOrUntrash
in interfaceTrashService
- Parameters:
docs
- the documentsprincipal
- the current user (to check locks)- Returns:
true
if the documents are purgeable/undeletable
-
getInfo
protected TrashInfo getInfo(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted) -
getDocumentLocker
-
getTrashInfo
public TrashInfo getTrashInfo(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted) Description copied from interface:TrashService
Gets the trash info for a list of documents.- Specified by:
getTrashInfo
in interfaceTrashService
- Parameters:
docs
- the documentsprincipal
- the current user (to check locks)checkProxies
-true
to count proxies as non-deletablecheckDeleted
-true
if documents have to be in the trashed state to be considered (otherwise forbidden)- Returns:
- the trash info
-
getAboveDocument
Description copied from interface:TrashService
Gets the closest document's ancestor above all the paths.This is used to find what safe document to redirect to when deleting some.
- Specified by:
getAboveDocument
in interfaceTrashService
- Parameters:
doc
- the documentrootPaths
- the paths- Returns:
- the closer document above doc and above all the paths
-
getAboveDocument
Description copied from interface:TrashService
Gets the first non trashed ancestor.This is used to find what safe document to redirect to when deleting one.
- Specified by:
getAboveDocument
in interfaceTrashService
- Parameters:
doc
- the trashed documentprincipal
- the current user- Returns:
- the first non trashed ancestor
-
underOneOf
-
purgeDocuments
Description copied from interface:TrashService
Purges (completely deletes) documents.- Specified by:
purgeDocuments
in interfaceTrashService
- Parameters:
session
- the sessiondocRefs
- the documents to purge
-
purgeDocumentsUnder
Description copied from interface:TrashService
Purges (completely deletes) trashed documents under the given parent.- Specified by:
purgeDocumentsUnder
in interfaceTrashService
- Parameters:
parent
- The parent document of trashed documents.
-
notifyEvent
-
notifyEvent
protected void notifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate) -
notifyEvent
protected void notifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate, boolean inline) -
getDocuments
Description copied from interface:TrashService
Get all documents from the trash of the current document.- Specified by:
getDocuments
in interfaceTrashService
- Parameters:
parent
- The parent document of trash document.- Returns:
- All documents in the trash of the current document.
-
untrashDocuments
Description copied from interface:TrashService
Unmoves documents from the trash.Also fires async events to untrash the children.
- Specified by:
untrashDocuments
in interfaceTrashService
- Parameters:
docs
- the documents to untrash
-
isMangledName
- Specified by:
isMangledName
in interfaceTrashService
- Parameters:
docName
- the document's name- Returns:
- true if the document's name is mangled, false otherwise
-
mangleName
Description copied from interface:TrashService
Mangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.- Specified by:
mangleName
in interfaceTrashService
- Parameters:
doc
- the document
-
unmangleName
Description copied from interface:TrashService
Unmangles the name of a document in the trash to find its un-trashed name.- Specified by:
unmangleName
in interfaceTrashService
- Parameters:
doc
- the trashed document- Returns:
- the unmangled name
-
unmangleName
Description copied from interface:TrashService
Unmangles the name of a document in the trash to find its un-trashed name.- Specified by:
unmangleName
in interfaceTrashService
- Parameters:
session
- the session used for collisions checkparentRef
- the parent document refdocName
- the document name- Returns:
- the unmangled name
-
getFirstGroup
-
checkCanTrash
Deprecated.since 2023,AbstractSession.canRemoveDocument(DocumentRef)
does this checkThrows aDocumentExistsException
if a descendant document cannot be trashed.- Since:
- 2021.14
-