Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.trash
Class TrashServiceImpl

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.core.trash.TrashServiceImpl
All Implemented Interfaces:
TrashService, Adaptable, Component, Extensible

public class TrashServiceImpl
extends DefaultComponent
implements TrashService


Constructor Summary
TrashServiceImpl()
           
 
Method Summary
 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.
 TrashInfo getTrashInfo(List<DocumentModel> docs, Principal principal, boolean checkProxies, boolean checkDeleted)
          Gets the trash info for a list of documents.
 void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
          Purges (completely deletes) documents .
 void trashDocuments(List<DocumentModel> docs)
          Moves documents to the trash, or directly deletes them if their lifecycle does not allow trash use.
 Set<DocumentRef> undeleteDocuments(List<DocumentModel> docs)
          Undeletes documents (and ancestors if needed to make them visible).
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, applicationStarted, deactivate, getAdapter, registerContribution, registerExtension, unregisterContribution, unregisterExtension
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrashServiceImpl

public TrashServiceImpl()
Method Detail

folderAllowsDelete

public boolean folderAllowsDelete(DocumentModel folder)
                           throws ClientException
Description copied from interface: TrashService
Can a child of the folder be deleted?

Specified by:
folderAllowsDelete in interface TrashService
Parameters:
folder - the folder
Returns:
true if the folder allows its children to be deleted
Throws:
ClientException

checkDeletePermOnParents

public boolean checkDeletePermOnParents(List<DocumentModel> docs)
                                 throws ClientException
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 deleted
Throws:
ClientException

canDelete

public boolean canDelete(List<DocumentModel> docs,
                         Principal principal,
                         boolean checkProxies)
                  throws ClientException
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
Throws:
ClientException

canPurgeOrUndelete

public boolean canPurgeOrUndelete(List<DocumentModel> docs,
                                  Principal principal)
                           throws ClientException
Description copied from interface: TrashService
Are all documents purgeable/undeletable?

Documents need to be in the deleted lifecycle state for this to be true, in addition to the standard permission checks.

Specified by:
canPurgeOrUndelete in interface TrashService
Parameters:
docs - the documents
principal - the current user (to check locks)
Returns:
true if the documents are purgeable/undeletable
Throws:
ClientException

canUndelete

public boolean canUndelete(List<DocumentModel> docs)
                    throws ClientException
Throws:
ClientException

getTrashInfo

public TrashInfo getTrashInfo(List<DocumentModel> docs,
                              Principal principal,
                              boolean checkProxies,
                              boolean checkDeleted)
                       throws ClientException
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 deleted state to be considered (otherwise forbidden)
Returns:
the trash info
Throws:
ClientException

getAboveDocument

public DocumentModel getAboveDocument(DocumentModel doc,
                                      Set<Path> rootPaths)
                               throws ClientException
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
Throws:
ClientException

trashDocuments

public void trashDocuments(List<DocumentModel> docs)
                    throws ClientException
Description copied from interface: TrashService
Moves documents to the trash, or directly deletes them if their lifecycle does not allow trash use.

Specified by:
trashDocuments in interface TrashService
Parameters:
docs - the documents to trash
Throws:
ClientException

purgeDocuments

public void purgeDocuments(CoreSession session,
                           List<DocumentRef> docRefs)
                    throws ClientException
Description copied from interface: TrashService
Purges (completely deletes) documents .

Specified by:
purgeDocuments in interface TrashService
Parameters:
session - the session
docRefs - the documents to purge
Throws:
ClientException

undeleteDocuments

public Set<DocumentRef> undeleteDocuments(List<DocumentModel> docs)
                                   throws ClientException
Description copied from interface: TrashService
Undeletes documents (and ancestors if needed to make them visible).

Also fires async events to undelete the children.

Specified by:
undeleteDocuments in interface TrashService
Parameters:
docs - the documents to undelete
Returns:
the set of ancestors whose children have been undeleted (for UI notification)
Throws:
ClientException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.