cancel
Showing results for 
Search instead for 
Did you mean: 

change old version properties of a document

ingon
Champ in-the-making
Champ in-the-making
Hi all,

I'm trying to change an older version document properties and add some tags, but I'm unable to make it work.

Here is my code:

      NodeRef nodeRef = new NodeRef(stringNodeRef);
      VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
      Collection<Version> versions = versionHistory.getAllVersions();
      Iterator<Version> iterator = versions.iterator();
      while (iterator.hasNext()) {
         Version version = iterator.next();
         NodeRef versionNodeRef = version.getVersionedNodeRef();
         taggingService.addTag(versionNodeRef, "new tag version " + version.getVersionLabel());
         QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "description");
         nodeService.setProperty(versionNodeRef, qname, "Description version " + version.getVersionLabel());
      }

where stringNodeRef is the document current version nodeRef.

The problem is that this always chages the last version properties, since version.getVersionedNodeRef() always returns ne current version nodeRef.

Any ideas why it isn't working? Or am I doing something wrong?

Thank you very much in advance!
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
Yes you are doing something wrong.    The node ref does not change with each version so your code is simply setting the current version.

You are doing something odd here.  Why do you want to fiddle with old versions?

ingon
Champ in-the-making
Champ in-the-making
Actually I don't want to  fiddle, the client does  Smiley Indifferent … for post-migration tasks.

Anyway, I think we can manage to do it with the default alfresco bulk import functionality. Thank you!!