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
public abstract class AbstractTrashService extends Object implements TrashService
Basic implementation ofTrashService
.- Since:
- 10.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractTrashService.PathComparator
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
Fields Modifier and Type Field Description protected static Pattern
COLLISION_PATTERN
Matches names resulting from a collision, suffixed with a time in milliseconds, created by DuplicatedNameFixer.static String
LEGAL_HOLD_QUERY
Deprecated.since 2023protected static String
PATH_SEPARATOR
static String
RETENTION_QUERY
Deprecated.since 2023protected static Pattern
TRASHED_PATTERN
Matches names of documents in the trash, created byTrashService.trashDocuments(List)
.static String
TRASHED_QUERY
-
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
Constructors Constructor Description AbstractTrashService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
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
checkDeletePermOnParents(List<DocumentModel> docs)
Is at least one doc deletable according to its container?boolean
folderAllowsDelete(DocumentModel folder)
Can a child of the folder be trashed?DocumentModel
getAboveDocument(DocumentModel doc, Set<Path> rootPaths)
Gets the closest document's ancestor above all the paths.DocumentModel
getAboveDocument(DocumentModel doc, NuxeoPrincipal principal)
Gets the first non trashed ancestor.protected static String
getDocumentLocker(DocumentModel doc)
DocumentModelList
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)
TrashInfo
getTrashInfo(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted)
Gets the trash info for a list of documents.boolean
isMangledName(String docName)
String
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)
String
unmangleName(CoreSession session, DocumentRef parentRef, String docName)
Unmangles the name of a document in the trash to find its un-trashed name.String
unmangleName(DocumentModel doc)
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 Detail
-
TRASHED_QUERY
public static final String TRASHED_QUERY
- See Also:
- Constant Field Values
-
RETENTION_QUERY
@Deprecated public static final String RETENTION_QUERY
Deprecated.since 2023- See Also:
- Constant Field Values
-
LEGAL_HOLD_QUERY
@Deprecated public static final String LEGAL_HOLD_QUERY
Deprecated.since 2023- See Also:
- Constant Field Values
-
PATH_SEPARATOR
protected static final String PATH_SEPARATOR
- Since:
- 11.1
- See Also:
- Constant Field Values
-
TRASHED_PATTERN
protected static final Pattern TRASHED_PATTERN
Matches names of documents in the trash, created byTrashService.trashDocuments(List)
.
-
COLLISION_PATTERN
protected static final Pattern 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.
-
-
Method Detail
-
folderAllowsDelete
public boolean folderAllowsDelete(DocumentModel folder)
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
public boolean checkDeletePermOnParents(List<DocumentModel> docs)
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
public boolean canDelete(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies)
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
public boolean canPurgeOrUntrash(List<DocumentModel> docs, NuxeoPrincipal principal)
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
protected static String getDocumentLocker(DocumentModel doc)
-
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
public DocumentModel getAboveDocument(DocumentModel doc, Set<Path> rootPaths)
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
public DocumentModel getAboveDocument(DocumentModel doc, NuxeoPrincipal principal)
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
-
purgeDocuments
public void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
Description copied from interface:TrashService
Purges (completely deletes) documents.- Specified by:
purgeDocuments
in interfaceTrashService
- Parameters:
session
- the sessiondocRefs
- the documents to purge
-
purgeDocumentsUnder
public void purgeDocumentsUnder(DocumentModel parent)
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
protected void notifyEvent(CoreSession session, String eventId, DocumentModel doc)
-
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
public DocumentModelList getDocuments(DocumentModel parent)
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
public void untrashDocuments(List<DocumentModel> docs)
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
public boolean isMangledName(String docName)
- Specified by:
isMangledName
in interfaceTrashService
- Parameters:
docName
- the document's name- Returns:
- true if the document's name is mangled, false otherwise
-
mangleName
public String mangleName(DocumentModel doc)
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
public String unmangleName(DocumentModel doc)
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
public String unmangleName(CoreSession session, DocumentRef parentRef, String docName)
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
-
checkCanTrash
@Deprecated protected void checkCanTrash(DocumentModel model)
Deprecated.since 2023,AbstractSession.canRemoveDocument(DocumentRef)
does this checkThrows aDocumentExistsException
if a descendant document cannot be trashed.- Since:
- 2021.14
-
-