Hello,
How can i upload a new version of the document using Java API?
There are two services which may be useful in this case. CheckOutCheckInService and VersionService.
The second one seemed to be more appropriate.
This was my initial code:
Version currentVersion = versionservice.getCurrentVersion(docNode);
Map<String, Serializable> versionProps = new HashMap<String, Serializable>();
versionProps.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
versionservice.createVersion(docNode, versionProps);
nodeService.setProperties(docNode, newprops); // after uploading new version I want to update also the metadata
And I encountered:
project-acs_1 | org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 08020024 The current version label of the node does not exist in the version history.
This error occurs AFTER the first version change (so only when this code is executed 2 or more times)
-------------------------------------------------
After seeing some errors i tried to add:
String newVersionLabel = String.valueOf(Float.valueOf( currentVersion.getVersionLabel() ) + 0.1);
versionprops.put(VersionModel.PROP_VERSION_LABEL, newVersionLabel);
But it resulted in other errors:
project-acs_1 | org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: The version property name versionLabel clashes with a reserved verison property name.
-------------------------------------------------------
I also tried to change the node ref:
NodeRef docNode = new NodeRef(versionservice.getVersionStoreReference(), docNode.getId());
But it does not exists and throws and error:
Caused by: org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Node does not exist: workspace://version2Store/534aa85c-1466-4ead-a950-2d8b24e51945 (status:null)
I do not know how to get the proper node id (docNode.getId() returns diffrend id)
Does anyone know what am i doing wrong?
Solved! Go to Solution.
That should be still working with current versions:
Did you find a solution ?
That should be still working with current versions:
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.