cancel
Showing results for 
Search instead for 
Did you mean: 

Can't update document with version in cmis

arunr307
Champ in-the-making
Champ in-the-making
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("cmisSmiley SurprisedbjectTypeId", "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:
1 REPLY 1

dhy9452
Champ in-the-making
Champ in-the-making

I am also facing the same issue. Can any one help?