AnsweredAssumed Answered

Can't update document with version in cmis

Question asked by arunr307 on Jan 21, 2015
Latest reply on Dec 20, 2016 by dhy9452
I am trying to update a document (with version support) in cmis-alfresco. Normal document update successfully. But when I tried to update a document that have a relation, its getting a error.

            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");
             } 



error:

Constraint violation: 00190010 Found 1 integrity violations:
The association source multiplicity has been violated:

Outcomes