cancel
Showing results for 
Search instead for 
Did you mean: 

Java-backed webscript to change property of versioned document

metar
Champ in-the-making
Champ in-the-making
hey,

I have a versioned document (1.0, 1.1, 1.2, 1.3, …) based on a custom model and I want to change properties of older versions (eg 1.1).
Well, I thought thats not a big deal but im stuck Smiley Sad

I im trying to realize this with a java backed webscript.
I am able to find the corresponding NodeRef to the passed version.


When I try to set the property I get the following exception:

 java.lang.UnsupportedOperationException: This operation is not supported by a version store implementation of the node service.
   at org.alfresco.repo.version.NodeServiceImpl.setProperty(NodeServiceImpl.java:466)




So its not allowed to do any modifications on a "frozen" Node?
From what I read in the forums its possible to do so. But how?




here is my testcode


   //custom model
   static final String NAMESPACE = "http://www.sourcesense.com/model/1.0";
   static final QName TYPE_AUTHORTY = QName.createQName(NAMESPACE, "authority");


   public void execute(WebScriptRequest req, WebScriptResponse res)
         throws IOException {


      final String nodeUuid = (String) req.getParameter("uuid");
      final String versionLabel = (String) req.getParameter("versionLabel");
      final String authority = (String) req.getParameter("authority");

      String nodePath = "workspace://SpacesStore/" + nodeUuid;

      VersionHistory versionHistory = registry.getVersionService().getVersionHistory(new NodeRef(nodePath));
      if(null!= versionHistory){

         Iterator<Version> versionIterator = versionHistory.getAllVersions().iterator();
         Version version;
         while(versionIterator.hasNext()){
            version = versionIterator.next();
            if(version.getVersionLabel().equals(versionLabel)){
               System.out.println("Trying to change Property of version: "+versionLabel);
               NodeRef node = version.getFrozenStateNodeRef();
               registry.getNodeService().setProperty(node, TYPE_AUTHORTY, authority);
            }
         }
      }
   }



and the request
http://localhost:8080/alfresco/service/demo/changeProperties?uuid=da8b67e3-7f72-43b3-bc00-7a85fd5a20...



thank you
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
A "frozen" node is not editable ,if you want to modify it ,you should first revert the version.

metar
Champ in-the-making
Champ in-the-making
the api for revert says: "The node reference will be reverted to the current version."

so lets say my current version is 1.5 and I want to modifiy version 1.1
1) I have to revert the current version to 1.1?
registry.getVersionService().revert(nodeRef, version);

nodeRef: current version Node (1.5)
version: my target version from the versionHistory (eg. version 1.1)

2) than do my changes
3) and revert again using version 1.5? (to have my old state back)



coud you provide an working example?

thanks for your time

maheshdanaveni
Champ in-the-making
Champ in-the-making
Hi,

I'm also facing the same problem.Did you find the solution to edit or add a property the versioned node(i.e.frozen node)? Please provide your inputs.

Thanks,
Mahesh