有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法使用cmis中的版本更新文档

我正在尝试更新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: 

共 (1) 个答案

  1. # 1 楼答案

    我也有同样的问题,并且相当绝望,因为它在Alfresco 5之前曾经起作用。x、 同时更新化学和导入组织。露天的。cmis。客户户外文件包没有帮助

    但我发现了以下解决方法。我们的Alfresco安装始终配置为自动版本,因此我只需在文档中设置一个新内容,即可完成签出/更新/签入过程:

    theDoc.setContentStream(contentStream, true);
    

    请注意,这将在我们的配置中添加新版本,因此“theDoc”从现在起指向文档的旧版本。因此,您可能需要再次获取文档,使其指向最新版本,以避免“文档不是最新版本”错误