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 of TrashService.
Since:
10.1
  • Field Details

  • Constructor Details

    • AbstractTrashService

      public AbstractTrashService()
  • Method Details

    • folderAllowsDelete

      public boolean folderAllowsDelete(DocumentModel folder)
      Description copied from interface: TrashService
      Can a child of the folder be trashed?
      Specified by:
      folderAllowsDelete in interface TrashService
      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 interface TrashService
      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 interface TrashService
      Parameters:
      docs - the documents
      principal - 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 interface TrashService
      Parameters:
      docs - the documents
      principal - 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 interface TrashService
      Parameters:
      docs - the documents
      principal - the current user (to check locks)
      checkProxies - true to count proxies as non-deletable
      checkDeleted - 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 interface TrashService
      Parameters:
      doc - the document
      rootPaths - 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 interface TrashService
      Parameters:
      doc - the trashed document
      principal - the current user
      Returns:
      the first non trashed ancestor
    • underOneOf

      protected static boolean underOneOf(Path testedPath, Set<Path> paths)
    • purgeDocuments

      public void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
      Description copied from interface: TrashService
      Purges (completely deletes) documents.
      Specified by:
      purgeDocuments in interface TrashService
      Parameters:
      session - the session
      docRefs - 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 interface TrashService
      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 interface TrashService
      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 interface TrashService
      Parameters:
      docs - the documents to untrash
    • isMangledName

      public boolean isMangledName(String docName)
      Specified by:
      isMangledName in interface TrashService
      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 interface TrashService
      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 interface TrashService
      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 interface TrashService
      Parameters:
      session - the session used for collisions check
      parentRef - the parent document ref
      docName - the document name
      Returns:
      the unmangled name
    • getFirstGroup

      protected String getFirstGroup(Pattern pattern, String name)
    • checkCanTrash

      @Deprecated protected void checkCanTrash(DocumentModel model)
      Deprecated.
      Throws a DocumentExistsException if a descendant document cannot be trashed.
      Since:
      2021.14