Reputation: 21
I am using below script for uploading a file in alfresco but it refuses to create stating conflict.
"<?xml version='1.0' encoding='utf-8'?>\n" +
"<entry xmlns='http://www.w3.org/2005/Atom' xmlns:app=\"http://www.w3.org/2007/app\" xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\" xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\" xmlns:alf=\"http://www.alfresco.org\">\n" +
"<title>" + fileName + "</title>\n" +
"<summary>" + fileDescrption + "</summary>\n" +
"<author>" + author + "</author>\n" +
"<content type='" + mimeType.toString() + "'>" + encoder.encode(bytes) + "</content>\n" +
"<cmisra:object>\n"+
"<cmis:properties>\n" +
"<cmis:propertyId propertyDefinitionId=\"cmis:objectTypeId\">\n"+
"<cmis:value>D:hs:doc</cmis:value>\n"+
"</cmis:propertyId>\n" +
"<cmis:propertyId propertyDefinitionId=\"cmis:versionable\">\n"+
"<cmis:value>TRUE</cmis:value>\n"+
"</cmis:propertyId>\n" +
"</cmis:properties>\n" +
"</cmisra:object>\n" +
"</entry>\n";
how can i enable versioning using cmis rest .
Upvotes: 0
Views: 320
Reputation: 10538
I agree with Gagravarr that you will save yourself a lot of time and frustration by using one of the libraries available at http://chemistry.apache.org or some other source.
However, the answer to your question is that it sounds like you are trying to create a new object with the same name in the same folder as an existing object. Alfresco does not allow this, hence the error.
Instead, what you need to do is update the existing object. You are using the AtomPub Binding so if what you want to do is update the content stream, you can do a PUT on the content stream's URL.
If instead you are trying to update the properties, you can do a PUT on the object's URL.
This will change the object without creating a new version. If you instead want to create a new version, you need to check out the object (POST the object to the checked out collection) which will return the Private Working Copy (PWC). You can then set the content stream and update the properties on the PWC as noted above, then you can do a checkin. This will create a new version.
Note that if Alfresco hands you a change token you need to hand it back when performing these kinds of updates or you will get an update conflict exception.
If you need specifics on how to do any of this, read the spec. If you want a friendly API to do this rather than dealing with low-level AtomPub XML, PUTs, POSTs, and DELETEs, then grab a CMIS library.
Upvotes: 1