ドキュメントをゴミ箱に移動するために使用したコードは次のとおりです。
public boolean deleteDocument(Session session, String documentId) throws Exception {
try {
Document document = getDocumentById(session, documentId);
// When delete a document, only move it to Trash
session.newRequest("Document.SetLifeCycle")
.setInput(document).set("value", "delete").execute();
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
次のコードは、ドキュメントを完全に削除します。
public static boolean deleteDocument(Session session, String documentId) throws Exception {
try {
Document document = getDocumentById(session, documentId);
// Delete the document permanently
session.newRequest("Document.Delete").setInput(document).execute();
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
}
1 つの方法は、次のように NXQL を介して最初にゴミ箱内のドキュメントを見つけることです。
SELECT * FROM Document WHERE ecm:currentLifeCycleState = 'deleted'
そして、上記の方法でそれらを完全に削除します。これについて言及している投稿もあります: http://answers.nuxeo.com/questions/1830/actioncommand-to-permanently-delete-all-document-in-trash
ユーティリティ メソッド: documentId でドキュメントをフェッチします。
public static Document getDocumentById(Session session, String documentId) throws Exception {
try {
return (Document) session.newRequest("Document.Fetch").set("value", documentId)
.setHeader(Constants.HEADER_NX_SCHEMAS, "*").execute();
} catch (Exception e) {
log.error("Failed to fetch document: " + e.getMessage(), e);
throw e;
}
}