It's all about the answers!

Ask a question

download changesets of a workitem via JAVA APIs


Megha Nair (116) | asked Mar 07 '18, 6:57 a.m.

Is it possible to download the changesets of a workitem from the RTC server into local PC using java API's ?

One answer



permanent link
Luca Martinucci (1.0k397112) | answered Mar 13 '18, 7:15 a.m.

Using plain java API, once you got a IChangeSet cs object,

  for (Object o: cs.changes()) {
   IChange change = (IChange) o;

 IVersionableHandle afterHandle = change.afterState();

IVersionable afterVersionable = wm.versionableManager().fetchCompleteState(afterHandle, new SysoutProgressMonitor());

IFileItem fileAfter = (IFileItem) afterVersionable;

string outputDir= "C:/temp";

        PrintWriter afterOnDisk = new PrintWriter(outputDir+"after", "UTF-8");
         String lineAfter;
         InputStream isAfter = contentManager.retrieveContentStream(fileAfter, fileAfter.getContent(), null);
         BufferedReader brAfter = new BufferedReader(new InputStreamReader(isAfter));
      while ((lineAfter = brAfter.readLine()) != null) {
       afterOnDisk.println(lineAfter);
         }
         afterOnDisk.close();

[.....]

}

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.