【问题标题】:Update document content in Alfresco using Apache Chemistry Asynchronously使用 Apache Chemistry 异步更新 Alfresco 中的文档内容
【发布时间】:2017-12-22 14:09:37
【问题描述】:

我正在使用 OpenCMIS 1.1.0 在 Alfresco Content Repository 上执行 CRUD 操作。使用here 提供的示例,我能够对文件夹和文档执行所有 CRUD 操作。

现在我想异步执行这些操作(尤其是创建和更新)。使用这个出色的 SO post 我可以异步创建 文档。但是,OpenCMIS AsyncSession 类不提供 updateContentStream 方法。

有什么方法可以使用 OpenCMIS API 来异步更新文档内容。

【问题讨论】:

    标签: asynchronous alfresco cmis opencmis


    【解决方案1】:

    AsyncSession 中不提供所有需要更改令牌的操作,因为如果计划对同一对象执行两个操作,结果将无法预测。 但是您可以添加自己的 Callable。将您的 AsyncSession 对象转换为 AbstractExecutorServiceAsyncSession 并使用您自己的 Callable 对象调用 submit。在这里你可以为所欲为。

    这样的 Callable 类可能如下所示:

    public class SetContentStreamCallable extends SessionCallable<ObjectId> {
        private Document doc;
        private ContentStream contentStream;
        private boolean overwrite;
    
        public SetContentStreamCallable(Session session, Document doc, ContentStream contentStream, boolean overwrite) {
            super(session);
            this.doc = doc;
            this.contentStream = contentStream;
            this.overwrite = overwrite;
        }
    
        @Override
        public ObjectId call() throws Exception {
            return doc.setContentStream(contentStream, overwrite, false);
        }
    }
    

    但请记住不要在同一个文档上运行两个任务!

    【讨论】:

      猜你喜欢
      • 2019-05-01
      • 1970-01-01
      • 2016-04-27
      • 2014-05-21
      • 2019-12-15
      • 1970-01-01
      • 2012-03-21
      • 2021-09-11
      • 1970-01-01
      相关资源
      最近更新 更多