public class TrashServiceImpl extends DefaultComponent implements TrashService
| Modifier and Type | Class and Description |
|---|---|
protected static class |
TrashServiceImpl.PathComparator
Path-based comparator used to put folders before their children.
|
| Modifier and Type | Field and Description |
|---|---|
protected static Pattern |
COLLISION_PATTERN
Matches names resulting from a collision, suffixed with a time in milliseconds, created by DuplicatedNameFixer.
|
protected static Pattern |
TRASHED_PATTERN
Matches names of documents in the trash, created by
trashDocument(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.api.DocumentModel). |
lastModified| Constructor and Description |
|---|
TrashServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDelete(List<DocumentModel> docs,
Principal principal,
boolean checkProxies)
Is at least one doc deletable?
|
boolean |
canPurgeOrUndelete(List<DocumentModel> docs,
Principal principal)
Are all documents purgeable/undeletable?
|
boolean |
canUndelete(List<DocumentModel> docs) |
boolean |
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 deleted?
|
DocumentModel |
getAboveDocument(DocumentModel doc,
Set<Path> rootPaths)
Gets the closest document's ancestor above all the paths.
|
protected static String |
getDocumentLocker(DocumentModel doc) |
DocumentModelList |
getDocuments(DocumentModel currentDoc)
Get all documents from the trash of the current document.
|
protected TrashInfo |
getInfo(List<DocumentModel> docs,
Principal principal,
boolean checkProxies,
boolean checkDeleted) |
TrashInfo |
getTrashInfo(List<DocumentModel> docs,
Principal principal,
boolean checkProxies,
boolean checkDeleted)
Gets the trash info for a list of documents.
|
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) |
void |
purgeDocuments(CoreSession session,
List<DocumentRef> docRefs)
Purges (completely deletes) documents .
|
protected void |
trashDocument(CoreSession session,
DocumentModel doc) |
void |
trashDocuments(List<DocumentModel> docs)
Moves documents to the trash, or directly deletes them if their lifecycle does not allow trash use.
|
protected void |
undeleteAncestors(CoreSession session,
DocumentRef docRef,
Set<DocumentRef> undeleted)
Undeletes ancestors of a document.
|
protected void |
undeleteDocument(CoreSession session,
DocumentModel doc) |
protected Set<DocumentRef> |
undeleteDocumentList(CoreSession session,
List<DocumentModel> docs)
Undeletes a list of documents.
|
Set<DocumentRef> |
undeleteDocuments(List<DocumentModel> docs)
Undeletes documents (and ancestors if needed to make them visible).
|
protected static boolean |
underOneOf(Path testedPath,
Set<Path> paths) |
String |
unmangleName(DocumentModel doc)
Unmangles the name of a document in the trash to find its un-trashed name.
|
activate, deactivate, getAdapter, getLastModified, registerContribution, registerExtension, setLastModified, setModifiedNow, start, stop, unregisterContribution, unregisterExtensionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitapplicationStarted, getApplicationStartedOrderprotected static final Pattern TRASHED_PATTERN
trashDocument(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.api.DocumentModel).protected static final Pattern COLLISION_PATTERN
public TrashServiceImpl()
public boolean folderAllowsDelete(DocumentModel folder)
TrashServicefolderAllowsDelete in interface TrashServicefolder - the foldertrue if the folder allows its children to be deletedpublic boolean checkDeletePermOnParents(List<DocumentModel> docs)
TrashServicecheckDeletePermOnParents in interface TrashServicedocs - the documentstrue if one doc is in a folder that allows its children to be deletedpublic boolean canDelete(List<DocumentModel> docs, Principal principal, boolean checkProxies)
TrashServicecanDelete in interface TrashServicedocs - the documentsprincipal - the current user (to check locks)checkProxies - true to count proxies as non-deletabletrue if at least one doc is deletablepublic boolean canPurgeOrUndelete(List<DocumentModel> docs, Principal principal)
TrashServiceDocuments need to be in the deleted lifecycle state for this to be true, in addition to the standard permission checks.
canPurgeOrUndelete in interface TrashServicedocs - the documentsprincipal - the current user (to check locks)true if the documents are purgeable/undeletablepublic boolean canUndelete(List<DocumentModel> docs)
protected TrashInfo getInfo(List<DocumentModel> docs, Principal principal, boolean checkProxies, boolean checkDeleted)
protected static String getDocumentLocker(DocumentModel doc)
public TrashInfo getTrashInfo(List<DocumentModel> docs, Principal principal, boolean checkProxies, boolean checkDeleted)
TrashServicegetTrashInfo in interface TrashServicedocs - the documentsprincipal - the current user (to check locks)checkProxies - true to count proxies as non-deletablecheckDeleted - true if documents have to be in the deleted state to be considered (otherwise
forbidden)public DocumentModel getAboveDocument(DocumentModel doc, Set<Path> rootPaths)
TrashServiceThis is used to find what safe document to redirect to when deleting some.
getAboveDocument in interface TrashServicedoc - the documentrootPaths - the pathsprotected static boolean underOneOf(Path testedPath, Set<Path> paths)
public void trashDocuments(List<DocumentModel> docs)
TrashServiceDo nothing if the document current state is deleted.
Placeless documents are deleted immediately.
trashDocuments in interface TrashServicedocs - the documents to trashpublic void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
TrashServicepurgeDocuments in interface TrashServicesession - the sessiondocRefs - the documents to purgepublic Set<DocumentRef> undeleteDocuments(List<DocumentModel> docs)
TrashServiceAlso fires async events to undelete the children.
undeleteDocuments in interface TrashServicedocs - the documents to undeleteprotected void notifyEvent(CoreSession session, String eventId, DocumentModel doc)
protected Set<DocumentRef> undeleteDocumentList(CoreSession session, List<DocumentModel> docs)
protected void undeleteAncestors(CoreSession session, DocumentRef docRef, Set<DocumentRef> undeleted)
public String mangleName(DocumentModel doc)
TrashServicemangleName in interface TrashServicedoc - the documentpublic String unmangleName(DocumentModel doc)
TrashServiceunmangleName in interface TrashServicedoc - the trashed documentprotected void trashDocument(CoreSession session, DocumentModel doc)
protected void undeleteDocument(CoreSession session, DocumentModel doc)
public DocumentModelList getDocuments(DocumentModel currentDoc)
getDocuments in interface TrashServicecurrentDoc - The current/parent document of trash document.Copyright © 2018 Nuxeo. All rights reserved.