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 classAbstractTrashService.PathComparatorPath-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 PatternCOLLISION_PATTERNMatches names resulting from a collision, suffixed with a time in milliseconds, created by DuplicatedNameFixer.static StringLEGAL_HOLD_QUERYDeprecated.since 2023protected static StringPATH_SEPARATORstatic StringRETENTION_QUERYDeprecated.since 2023protected static PatternTRASHED_PATTERNMatches names of documents in the trash, created byTrashService.trashDocuments(List).static StringTRASHED_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 booleancanDelete(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies)Is at least one doc deletable?booleancanPurgeOrUntrash(List<DocumentModel> docs, NuxeoPrincipal principal)Are all documents purgeable/undeletable?protected voidcheckCanTrash(DocumentModel model)Deprecated.since 2023,AbstractSession.canRemoveDocument(DocumentRef)does this checkbooleancheckDeletePermOnParents(List<DocumentModel> docs)Is at least one doc deletable according to its container?booleanfolderAllowsDelete(DocumentModel folder)Can a child of the folder be trashed?DocumentModelgetAboveDocument(DocumentModel doc, Set<Path> rootPaths)Gets the closest document's ancestor above all the paths.DocumentModelgetAboveDocument(DocumentModel doc, NuxeoPrincipal principal)Gets the first non trashed ancestor.protected static StringgetDocumentLocker(DocumentModel doc)DocumentModelListgetDocuments(DocumentModel parent)Get all documents from the trash of the current document.protected StringgetFirstGroup(Pattern pattern, String name)protected TrashInfogetInfo(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted)TrashInfogetTrashInfo(List<DocumentModel> docs, NuxeoPrincipal principal, boolean checkProxies, boolean checkDeleted)Gets the trash info for a list of documents.booleanisMangledName(String docName)StringmangleName(DocumentModel doc)Mangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.protected voidnotifyEvent(CoreSession session, String eventId, DocumentModel doc)protected voidnotifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate)protected voidnotifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate, boolean inline)voidpurgeDocuments(CoreSession session, List<DocumentRef> docRefs)Purges (completely deletes) documents.voidpurgeDocumentsUnder(DocumentModel parent)Purges (completely deletes) trashed documents under the given parent.protected static booleanunderOneOf(Path testedPath, Set<Path> paths)StringunmangleName(CoreSession session, DocumentRef parentRef, String docName)Unmangles the name of a document in the trash to find its un-trashed name.StringunmangleName(DocumentModel doc)Unmangles the name of a document in the trash to find its un-trashed name.voiduntrashDocuments(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:TrashServiceCan a child of the folder be trashed?- Specified by:
folderAllowsDeletein interfaceTrashService- Parameters:
folder- the folder- Returns:
trueif the folder allows its children to be trashed
-
checkDeletePermOnParents
public boolean checkDeletePermOnParents(List<DocumentModel> docs)
Description copied from interface:TrashServiceIs at least one doc deletable according to its container?- Specified by:
checkDeletePermOnParentsin interfaceTrashService- Parameters:
docs- the documents- Returns:
trueif 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:TrashServiceIs at least one doc deletable?- Specified by:
canDeletein interfaceTrashService- Parameters:
docs- the documentsprincipal- the current user (to check locks)checkProxies-trueto count proxies as non-deletable- Returns:
trueif at least one doc is deletable
-
canPurgeOrUntrash
public boolean canPurgeOrUntrash(List<DocumentModel> docs, NuxeoPrincipal principal)
Description copied from interface:TrashServiceAre 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:
canPurgeOrUntrashin interfaceTrashService- Parameters:
docs- the documentsprincipal- the current user (to check locks)- Returns:
trueif 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:TrashServiceGets the trash info for a list of documents.- Specified by:
getTrashInfoin interfaceTrashService- Parameters:
docs- the documentsprincipal- the current user (to check locks)checkProxies-trueto count proxies as non-deletablecheckDeleted-trueif 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:TrashServiceGets 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:
getAboveDocumentin 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:TrashServiceGets the first non trashed ancestor.This is used to find what safe document to redirect to when deleting one.
- Specified by:
getAboveDocumentin 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:TrashServicePurges (completely deletes) documents.- Specified by:
purgeDocumentsin interfaceTrashService- Parameters:
session- the sessiondocRefs- the documents to purge
-
purgeDocumentsUnder
public void purgeDocumentsUnder(DocumentModel parent)
Description copied from interface:TrashServicePurges (completely deletes) trashed documents under the given parent.- Specified by:
purgeDocumentsUnderin 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:TrashServiceGet all documents from the trash of the current document.- Specified by:
getDocumentsin 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:TrashServiceUnmoves documents from the trash.Also fires async events to untrash the children.
- Specified by:
untrashDocumentsin interfaceTrashService- Parameters:
docs- the documents to untrash
-
isMangledName
public boolean isMangledName(String docName)
- Specified by:
isMangledNamein 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:TrashServiceMangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.- Specified by:
mangleNamein interfaceTrashService- Parameters:
doc- the document
-
unmangleName
public String unmangleName(DocumentModel doc)
Description copied from interface:TrashServiceUnmangles the name of a document in the trash to find its un-trashed name.- Specified by:
unmangleNamein interfaceTrashService- Parameters:
doc- the trashed document- Returns:
- the unmangled name
-
unmangleName
public String unmangleName(CoreSession session, DocumentRef parentRef, String docName)
Description copied from interface:TrashServiceUnmangles the name of a document in the trash to find its un-trashed name.- Specified by:
unmangleNamein 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 aDocumentExistsExceptionif a descendant document cannot be trashed.- Since:
- 2021.14
-
-