cancel
Showing results for 
Search instead for 
Did you mean: 

Get Version Content, How to?

manmeet
Champ in-the-making
Champ in-the-making
Hi,

There is a txt file with 4-5 versions. I am trying to get the contents of the older version using the webservice API. Here I am hardcoding the UUID of a node in the lightWeightVersionStore store. See the code as below:

public static void main(String[] args) throws Exception{

   Store storeRef = new Store(StoreEnum.workspace, "lightWeightVersionStore");   
   
       String uuid = "d7e29d6c-2965-11db-9253-5f4da51af059";
       String path = null;

   //start Session
   AuthenticationUtils.startSession("admin", "admin");
      
   // Get the content service
   ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
      
   // Create a reference to the node to be read
   Reference newContentReference = new Reference (storeRef,uuid,path);
          
          // Read the newly added content from the respository
          Content[] contents = contentService.read(
              new Predicate(new Reference[]{newContentReference}, storeRef, null),
                   Constants.PROP_CONTENT);
   
        //Print the file contents
         System.out.println(ContentUtils.getContentAsString(contents[0]));

        // End the session
        AuthenticationUtils.endSession();
}


But I keep getting the following error:

Exception in thread "main" org.alfresco.webservice.util.WebServiceException: Unable to get content as string.
   at org.alfresco.webservice.util.ContentUtils.getContentAsString(ContentUtils.java:87)
   at ReadFile.readFile(ReadFile.java:52)
   at ReadFile.main(ReadFile.java:30)
Caused by: java.net.MalformedURLException: no protocol: null?ticket=TICKET_87c3cdd6-296a-11db-9253-5f4da51af059
   at java.net.URL.<init>(URL.java:567)
   at java.net.URL.<init>(URL.java:464)
   at java.net.URL.<init>(URL.java:413)
   at org.alfresco.webservice.util.ContentUtils.getContentAsString(ContentUtils.java:75)
   … 2 more

I think its able to locate the content, but while trying to read the contents it fails.

Please let me know how to go about this. Is tehre anything wrong with the code?? Do I need to make some modifications??

————————————
Thanks, Manmeet Bhavsar
4 REPLIES 4

manmeet
Champ in-the-making
Champ in-the-making
Anyone with a probable solution???

cludt
Champ in-the-making
Champ in-the-making
Have a look at the SDK, there is an example GetVersions. Use the VersionHistory to fetch the versions.

manmeet
Champ in-the-making
Champ in-the-making
Hi,

Thanks for your reply!

I couldn't locate a GetVersions sample in the SDK under WebserviceSamples.
I am using the 1.3.0 SDK. Is it under sum other samples project?? I am looking to use the Webservice API to achieve the results.

Any pointers shall be useful.

Thanks,
Manmeet

cludt
Champ in-the-making
Champ in-the-making
Hi Manmeet,

if you use Eclipse, it's in the SDK WebServiceSamples project.
Or have a look at \samples\WebServiceSamples\source\org\alfresco\sample\webservice\GetVersions.java

Christian