Package org.nuxeo.ecm.core.api.trash
Interface TrashService
-
- All Known Subinterfaces:
TrashService
- All Known Implementing Classes:
AbstractTrashService
,BridgeTrashService
,LifeCycleTrashService
,PropertyTrashService
public interface TrashService
Service containing the logic about deleting/purging/undeleting a document.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TrashService.Feature
Features of the implementation of the service.
-
Field Summary
Fields Modifier and Type Field Description static String
ABOUT_TO_TRASH
Event for a document about to be trashed by the user.static String
ABOUT_TO_UNTRASH
Event for a document about to be untrashed by the user.static String
DISABLE_TRASH_RENAMING
Key forDocumentModel.getContextData(String)
which skips the renaming during trash/untrash mechanism when the value isBoolean.TRUE
.static String
DOCUMENT_TRASHED
Event for a document trashed by the user.static String
DOCUMENT_UNTRASHED
Event for a document untrashed by the user.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description boolean
canPurgeOrUntrash(List<DocumentModel> docs, NuxeoPrincipal principal)
Are all documents purgeable/undeletable?default boolean
canPurgeOrUntrash(DocumentModel doc, NuxeoPrincipal principal)
Is document purgeable/untrashable?DocumentModel
getAboveDocument(DocumentModel doc, NuxeoPrincipal principal)
Gets the first non trashed ancestor.DocumentModelList
getDocuments(DocumentModel parent)
Deprecated.since 11.1, not scalableboolean
hasFeature(TrashService.Feature feature)
Checks if a feature is available.boolean
isMangledName(String docName)
boolean
isTrashed(CoreSession session, DocumentRef doc)
String
mangleName(DocumentModel doc)
Mangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.void
purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
Purges (completely deletes) documents.void
purgeDocumentsUnder(DocumentModel parent)
Purges (completely deletes) trashed documents under the given parent.default void
trashDocument(DocumentModel doc)
Moves document to the trash.void
trashDocuments(List<DocumentModel> docs)
Moves documents to the trash.String
unmangleName(CoreSession session, DocumentRef parentRef, String docName)
Unmangles the name of a document in the trash to find its un-trashed name.String
unmangleName(DocumentModel doc)
Unmangles the name of a document in the trash to find its un-trashed name.default void
untrashDocument(DocumentModel doc)
Unmoves document from the trash.void
untrashDocuments(List<DocumentModel> docs)
Unmoves documents from the trash.
-
-
-
Field Detail
-
ABOUT_TO_TRASH
static final String ABOUT_TO_TRASH
Event for a document about to be trashed by the user.- Since:
- 2021.30
- See Also:
- Constant Field Values
-
DOCUMENT_TRASHED
static final String DOCUMENT_TRASHED
Event for a document trashed by the user. Triggers an async listener that trashes its children too.- Since:
- 10.1
- See Also:
- Constant Field Values
-
ABOUT_TO_UNTRASH
static final String ABOUT_TO_UNTRASH
Event for a document about to be untrashed by the user.- Since:
- 2021.30
- See Also:
- Constant Field Values
-
DOCUMENT_UNTRASHED
static final String DOCUMENT_UNTRASHED
Event for a document untrashed by the user. Triggers an async listener that untrashes its children too.- Since:
- 10.1
- See Also:
- Constant Field Values
-
DISABLE_TRASH_RENAMING
static final String DISABLE_TRASH_RENAMING
Key forDocumentModel.getContextData(String)
which skips the renaming during trash/untrash mechanism when the value isBoolean.TRUE
.- Since:
- 10.1
- See Also:
- Constant Field Values
-
-
Method Detail
-
isTrashed
boolean isTrashed(CoreSession session, DocumentRef doc)
- Returns:
- whether or not the input
DocumentRef
is trashed. - Since:
- 10.1
-
canPurgeOrUntrash
boolean canPurgeOrUntrash(List<DocumentModel> docs, NuxeoPrincipal principal)
Are all documents purgeable/undeletable?Documents need to be in the trash for this to be true, in addition to the standard permission checks.
- Parameters:
docs
- the documentsprincipal
- the current user (to check locks)- Returns:
true
if the documents are purgeable/undeletable
-
canPurgeOrUntrash
default boolean canPurgeOrUntrash(DocumentModel doc, NuxeoPrincipal principal)
Is document purgeable/untrashable?Documents need to be in the trash for this to be true, in addition to the standard permission checks.
- Parameters:
doc
- the documentprincipal
- the current user (to check locks)- Returns:
true
if the documents are purgeable/untrashable
-
getAboveDocument
DocumentModel getAboveDocument(DocumentModel doc, NuxeoPrincipal principal)
Gets the first non trashed ancestor.This is used to find what safe document to redirect to when deleting one.
- Parameters:
doc
- the trashed documentprincipal
- the current user- Returns:
- the first non trashed ancestor
-
trashDocuments
void trashDocuments(List<DocumentModel> docs)
Moves documents to the trash.Do nothing if the document current state is trashed.
Proxies are removed.
Since 10.3, sublevels are trashed asynchronously using BAF.
- Parameters:
docs
- the documents to trash
-
trashDocument
default void trashDocument(DocumentModel doc)
Moves document to the trash.Do nothing if the document current state is trashed.
Proxies are removed.
Since 10.3, sublevels are trashed asynchronously using BAF.
- Parameters:
doc
- the document to trash- Since:
- 10.1
-
purgeDocuments
void purgeDocuments(CoreSession session, List<DocumentRef> docRefs)
Purges (completely deletes) documents.- Parameters:
session
- the sessiondocRefs
- the documents to purge
-
purgeDocumentsUnder
void purgeDocumentsUnder(DocumentModel parent)
Purges (completely deletes) trashed documents under the given parent.- Parameters:
parent
- The parent document of trashed documents.- Since:
- 10.1
-
untrashDocuments
void untrashDocuments(List<DocumentModel> docs)
Unmoves documents from the trash.Also fires async events to untrash the children.
- Parameters:
docs
- the documents to untrash
-
untrashDocument
default void untrashDocument(DocumentModel doc)
Unmoves document from the trash.Also fires async events to untrash the children.
- Parameters:
doc
- the document to untrash- Since:
- 10.1
-
getDocuments
@Deprecated(since="11.1") DocumentModelList getDocuments(DocumentModel parent)
Deprecated.since 11.1, not scalableGet all documents from the trash of the current document.- Parameters:
parent
- The parent document of trash document.- Returns:
- All documents in the trash of the current document.
- Since:
- 7.1
-
isMangledName
boolean isMangledName(String docName)
- Parameters:
docName
- the document's name- Returns:
- true if the document's name is mangled, false otherwise
- Since:
- 11.1
-
mangleName
String mangleName(DocumentModel doc)
Mangles the name of a document to avoid collisions with non-trashed documents when it's in the trash.- Parameters:
doc
- the document- Since:
- 7.3
-
unmangleName
String unmangleName(CoreSession session, DocumentRef parentRef, String docName)
Unmangles the name of a document in the trash to find its un-trashed name.- Parameters:
session
- the session used for collisions checkparentRef
- the parent document refdocName
- the document name- Returns:
- the unmangled name
- Since:
- 11.1
-
unmangleName
String unmangleName(DocumentModel doc)
Unmangles the name of a document in the trash to find its un-trashed name.- Parameters:
doc
- the trashed document- Returns:
- the unmangled name
- Since:
- 7.3
-
hasFeature
boolean hasFeature(TrashService.Feature feature)
Checks if a feature is available.- Since:
- 10.1
-
-