Set content on node version?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2014 10:27 AM
Hi all,
is there a way to set the content on the node version using Java API. For example I create node version using VersionService.java and I want to set the version content, is it possible and if yes how to do that?
Thanks…
is there a way to set the content on the node version using Java API. For example I create node version using VersionService.java and I want to set the version content, is it possible and if yes how to do that?
Thanks…
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2014 12:24 PM
You have it backwards. You create a version of the current content and properties not the other way around.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2014 12:28 PM
You can try following and see if it works for you or not.
Get the frozenStateNodeRef from the Version object you get after creating a new version using CreateVersion method and try setting up content property for this node.
Get the frozenStateNodeRef from the Version object you get after creating a new version using CreateVersion method and try setting up content property for this node.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2014 03:44 AM
Hi romschn,
this works thank you. I now noticed that I have problems to set version labels to right values? Is it possible to set the label somehow on version creation, or to update version label?
Thanks a lot
this works thank you. I now noticed that I have problems to set version labels to right values? Is it possible to set the label somehow on version creation, or to update version label?
Thanks a lot
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2014 09:03 AM
okay, can you try simply setting up the ContentModel.PROP_VERSION_LABEL using nodeservice.setProperty method with your right values and see if it works for you or not?
this.nodeService.setProperty(nodeRef,ContentModel.PROP_VERSION_LABEL,"Label-1");‍

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2014 03:51 PM
That does not work,I already tried that. Also if you look at implementation of
you will see that setting label is not possible on version creation also. I found this also:
http://code.google.com/p/alfresco-bulk-filesystem-import/issues/detail?id=85
So it seams that it is not possible?!
Thanks
VersionService#createVersion( NodeRef nodeRef,Map<String, Serializable> versionProperties);‍‍‍
you will see that setting label is not possible on version creation also. I found this also:
http://code.google.com/p/alfresco-bulk-filesystem-import/issues/detail?id=85
So it seams that it is not possible?!
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2014 10:20 PM
In out of the Box alfresco design:
1.You can not set PROP_VERSION_LABEL property when you create a new version for a node,PROP_VERSION_LABEL property is automatically calculated by CalculateVersionLabelPolicy .If you want to change the default serial version label,you can customize a CalculateVersionLabelPolicy for your custom type and use it to override the default one.
2.After a version is created ,you can't modify any properties(include PROP_VERSION_LABEL) unless you revert it ,and the content were not supposed to be updated at all.But it seems alfresco overlooked this fact ,now you can get the reference to the node of the version and change it's content,it should be wrong to update it directly.
So ,
if you want to use version lable policy of your own ,please customize CalculateVersionLabelPolicy
if you really want to update a version node's property, you shoud implement a new NodeService class and use it as the version store node service implementation
1.You can not set PROP_VERSION_LABEL property when you create a new version for a node,PROP_VERSION_LABEL property is automatically calculated by CalculateVersionLabelPolicy .If you want to change the default serial version label,you can customize a CalculateVersionLabelPolicy for your custom type and use it to override the default one.
2.After a version is created ,you can't modify any properties(include PROP_VERSION_LABEL) unless you revert it ,and the content were not supposed to be updated at all.But it seems alfresco overlooked this fact ,now you can get the reference to the node of the version and change it's content,it should be wrong to update it directly.
So ,
if you want to use version lable policy of your own ,please customize CalculateVersionLabelPolicy
if you really want to update a version node's property, you shoud implement a new NodeService class and use it as the version store node service implementation
