create new version when update metadata

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
manuelgentile
Member II

create new version when update metadata

How can we create new version of a versioned content when i update metadata?
I want to add "Save as New Version" in document-details.jsp
but i don't know how realize the method.

Thanks
2 Replies
rwetherall
Active Member II

Re: create new version when update metadata

Hi,

In order to create a new version 'by hand' you need to call the createVersion method on the VersionService.

Assumming the node in question has the versionable aspect applied, then this method will add a new version, containing the current state of the node, to the version history of that node.

Hope this helps,
Roy
manuelgentile
Member II

Re: create new version when update metadata

I made this method in DocumentPropertiesBean and add an actionlink to it in the document-details.jsp page.

After call it i have an exception indicates the Store is not present!
Where is the error?


public String saveAsNewVersion() {
      NodeRef nodeRef2 = this.browseBean.getDocument().getNodeRef();
      Map<String, Object> props = this.editableNode.getProperties();
      Map<QName, Serializable> properties2 = this.nodeService
            .getProperties(nodeRef2);
      Map<String, Serializable> properties3 = new HashMap<String, Serializable>();
      for (Entry<QName, Serializable> e : properties2.entrySet()) {
         properties3.put(e.getKey().toString(), e.getValue());
      }
      this.browseBean.setDocument(new Node(this.versionService.createVersion(
            nodeRef2, properties3).getFrozenStateNodeRef()));
      return this.save();
   }