如果文档已存在于 Alfresco 中,则使用 Chemistry CMIS 创建文档的新版本
Create a new version of a document if document already exists in Alfresco using Chemistry CMIS
我正在尝试使用 Chemistry 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。
如果抛出此异常,我想创建文档的新版本。
或者有没有一种方法可以让我使用 Chemistry CMIS 检查具有给定名称的文档是否已经存在于 Alfresco 存储库中,以便我无论如何都可以获取文档并使用新版本签入文档。
欢迎任何其他方法。
我通常会检查文档是否已经存在,如果存在我会进行更新。我不去检查 out/check 过程中,因为我设置 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;
我正在尝试使用 Chemistry 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。
如果抛出此异常,我想创建文档的新版本。
或者有没有一种方法可以让我使用 Chemistry CMIS 检查具有给定名称的文档是否已经存在于 Alfresco 存储库中,以便我无论如何都可以获取文档并使用新版本签入文档。
欢迎任何其他方法。
我通常会检查文档是否已经存在,如果存在我会进行更新。我不去检查 out/check 过程中,因为我设置 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;