我正在尝试在 cmis-alfresco 中更新文档(包含版本支持)。正常文档更新成功。但是当我尝试更新具有relation
的文档时,会出现错误。
newFileProps = new HashMap<String, String>();
newFileProps.put(PropertyIds.OBJECT_TYPE_ID,
"D:cmiscustom:document");
newFileProps.put(PropertyIds.NAME, "ADGFileSource1");
Document sourceDoc = folderAssociations.createDocument(
newFileProps, null, VersioningState.MAJOR);
newFileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
newFileProps.put(PropertyIds.NAME, "ADGFileTarget1");
newFileProps.put(PropertyIds.OBJECT_TYPE_ID,
"D:cmiscustom:document");
Document targetDoc = folderAssociations.createDocument(
newFileProps, null, VersioningState.MAJOR);
Map<String, String> relProps = new HashMap<String, String>();
relProps.put("cmis:sourceId", sourceDoc.getId());
relProps.put("cmis:targetId", targetDoc.getId());
relProps.put("cmis:objectTypeId", "R:cmiscustom:assoc");
ObjectId relId = session.createRelationship(relProps, null,
null, null);
if (sourceDoc.getAllowableActions().getAllowableActions().contains(org.apache.chemistry.opencmis.commons.enums.Action.CAN_CHECK_OUT)) {
sourceDoc.refresh();
String testName = sourceDoc.getContentStream().getFileName();
ObjectId idOfCheckedOutDocument = sourceDoc.checkOut();
Document pwc = (Document) session.getObject(idOfCheckedOutDocument);
String docText = "This is a sample document with an UPDATE";
byte[] content = docText.getBytes();
ByteArrayInputStream stream = new ByteArrayInputStream(content);
String filename=sourceDoc.getName();
ContentStream contentStream = session.getObjectFactory().createContentStream(filename, Long.valueOf(content.length), "text/plain", stream);
ObjectId objectId = pwc.checkIn(false, null, contentStream, "just a minor change");
}
错误:
Constraint violation: 00190010 Found 1 integrity violations:
The association source multiplicity has been violated:
答案 0 :(得分:1)
我遇到了同样的问题,与在Alfresco 5.x之前的工作一样绝望。另外,更新化学信息并导入org.alfresco.cmis.client.AlfrescoDocument软件包也无济于事。
但是我发现以下解决方法。我们的Alfresco安装始终配置为自动版本,因此我通过简单地为文档设置新内容来解决了checkout / update / checkin过程:
theDoc.setContentStream(contentStream, true);
请注意,这将在我们的配置中添加新版本,因此“ theDoc”从现在开始指向文档的旧版本。因此,您可能需要再次获取该文档以使其指向最新版本,以避免出现“文档不是最新版本”错误。