cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to get version of a document?

matjazmuhic
Champ on-the-rise
Champ on-the-rise
I pass for example "1.0" for args.version.

var version=doc.getVersion(args.version);var id = version.node.id;var requestedVersion = search.findNode("workspace://version2Store/"+id); ‍‍‍‍‍

Is this a correct way to get a version of a document?
2 REPLIES 2

patil
Champ on-the-rise
Champ on-the-rise
Hi,
Find the code for getting the version
   String versionLabel = "1.0";   //replace the above line with the version u want              String  nodeRef="workspace://SpacesStore/83196957-6bdb-4caa-87ff-d08f773cda4a"//replace the above line with the noderef u want                  VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(new NodeRef(nodeRef));      String fileName = (String)this.serviceRegistry.getNodeService().getProperty(new NodeRef(nodeRef), ContentModel.PROP_NAME);      if(null!= versionHistory){                  Iterator<Version> versionIterator = versionHistory.getAllVersions().iterator();         Version version;                           /*          * Frame the below url to get the contet of specific version          * http://localhost:8080/alfresco/d/d/versionStore/version2Store/551de18e-e94a-4ad1-a867-898d1adb0e22/W...          * the frozenNoderef to be used for the same to get the content of different version          */                                    while(versionIterator.hasNext()){            version = versionIterator.next();            if(version.getVersionLabel().equals(versionLabel)){               versionURL = DownloadContentServlet.generateBrowserURL(version.getFrozenStateNodeRef(),fileName);               //LOGGER.debug("Frozen nodeRef:::"+version.getFrozenStateNodeRef());               LOGGER.debug("The version URL of the contetn is:::"+versionURL);               model.put(SutherlandBlmConstants.XMLRESPONSE, GetContentByVersionXML.getContentByVersion(versionURL, versionLabel , contextPath));            }            }                        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Thanks,
Patil
Cignex Technologies
Bangalore

matjazmuhic
Champ on-the-rise
Champ on-the-rise
So. My way is no good?

Cause I want the whole document so I can do
model.doc = doc;‍
and make my ftl template the same for every document requested, either original or some old version.