1

从 Nuxeo REST API 文档中,我可以使用此代码在 TRASH 中看到已删除的文件/文件夹

SELECT * FROM Document WHERE ecm:mixinType != 'HiddenInNavigation' 
AND ecm:currentLifeCycleState = 'deleted' AND ecm:isProxy = 0 AND ecm:isCheckedInVersion = 0

但是如何更新文档ecm:currentLifeCycleState以将文档移动到垃圾箱?

谢谢

4

2 回答 2

2

您应该使用Document.SetLifeCycle操作来跟随delete转换。

于 2014-12-04T14:28:14.923 回答
2

这是我用来将文档移动到垃圾箱的代码。

  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;
    }
  }

一种方法是首先通过 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;
    }
  }
于 2014-12-05T02:12:44.663 回答