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, applicationStarted, deactivate, getAdapter, getApplicationStartedOrder, getLastModified, registerContribution, registerExtension, setLastModified, setModifiedNow, unregisterContribution, unregisterExtension
protected 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)
TrashService
folderAllowsDelete
in interface TrashService
folder
- the foldertrue
if the folder allows its children to be deletedpublic boolean checkDeletePermOnParents(List<DocumentModel> docs)
TrashService
checkDeletePermOnParents
in interface TrashService
docs
- 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)
TrashService
canDelete
in interface TrashService
docs
- 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)
TrashService
Documents need to be in the deleted lifecycle state for this to be true, in addition to the standard permission checks.
canPurgeOrUndelete
in interface TrashService
docs
- 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)
TrashService
getTrashInfo
in interface TrashService
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 deleted state to be considered (otherwise
forbidden)public DocumentModel getAboveDocument(DocumentModel doc, Set<Path> rootPaths)
TrashService
This is used to find what safe document to redirect to when deleting some.
getAboveDocument
in interface TrashService
doc
- the documentrootPaths
- the pathsprotected static boolean underOneOf(Path testedPath, Set<Path> paths)
public void trashDocuments(List<DocumentModel> docs)
TrashService
trashDocuments
in interface TrashService
docs
- the documents to trashpublic void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
TrashService
purgeDocuments
in interface TrashService
session
- the sessiondocRefs
- the documents to purgepublic Set<DocumentRef> undeleteDocuments(List<DocumentModel> docs)
TrashService
Also fires async events to undelete the children.
undeleteDocuments
in interface TrashService
docs
- 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)
TrashService
mangleName
in interface TrashService
doc
- the documentpublic String unmangleName(DocumentModel doc)
TrashService
unmangleName
in interface TrashService
doc
- the trashed documentprotected void trashDocument(CoreSession session, DocumentModel doc)
protected void undeleteDocument(CoreSession session, DocumentModel doc)
public DocumentModelList getDocuments(DocumentModel currentDoc)
getDocuments
in interface TrashService
currentDoc
- The current/parent document of trash document.Copyright © 2015 Nuxeo SA. All rights reserved.