0

我正在尝试使用化学 CMIS 创建文档,如下所示

final Map<String, Object> reportProps = new HashMap<String, Object>();
        reportProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
        reportProps.put(PropertyIds.NAME,file.getName());

session.getFolder().createDocument(reportProps, contentStream, VersioningState.MAJOR);

如果已存在同名文档,则会抛出 CmisContentAlreadyExistsException。

如果抛出此异常,我想创建文档的新版本。

或者有没有一种方法可以让我使用化学 CMIS 检查具有给定名称的文档是否已经存在于 Alfresco 存储库中,这样我无论如何都可以获取该文档并使用新版本签入该文档。

欢迎任何其他方法。

4

1 回答 1

2

我通常检查文档是否已经存在,如果存在,我会进行更新。我不进行签出/签入过程,因为我设置 Alfresco 为每个更新创建版本(但我想这两种方法都可以)。

我对 CMIS 不太熟悉,但我确实记得这篇文章谈到了您的用例。

http://ecmarchitect.com/archives/2013/08/26/3528

Document document = null;
try {
  document = parentFolder.createDocument(props, contentStream, null);
  System.out.println("Created new document: " + document.getId());
} catch (CmisContentAlreadyExistsException ccaee) {
  document = (Document) cmisSession.getObjectByPath(parentFolder.getPath() + "/" + fileName);
  System.out.println("Document already exists: " + fileName);
}
return document;
于 2016-06-14T18:50:59.050 回答