It's all about the answers!

Ask a question

How can I retrieve files from a changeset using the Java API?


Andy Jewell (24236174) | asked Mar 09 '17, 7:51 p.m.

I am trying to extract the files of a changeset using the Java API to the filesystem but haven't found a single reference in the forum for doing that.  Is the approach supposed to be to load a workspace and then copy out the files from the paths contained in the changeset?  Or is there a way to directly extract the files?  I seem to remember seeing something about the latter method but I can't find anything.


Any help or suggestions would be greatly appreciated!

Andy

Accepted answer


permanent link
Ralph Schoon (63.2k33646) | answered Mar 10 '17, 2:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Mar 10 '17, 2:48 a.m.

Here some clues: Getting an IFileItem

            IChangeSet changeSet = (IChangeSet) changeSetIterator.next();
            if (changeSet == null) {
                // It's possible that we don't have read access to this change
                // set?
                continue;
            }
            for (IChange change : (List<ichange>) changeSet.changes()) {
                IVersionableHandle after = change.afterState();
                IVersionable item = (IVersionable) scmService.fetchState(after,
                        null, null);
                if (item instanceof IFileItem) {
                    IFileItem fileItem = (IFileItem) item;

</ichange>

Getting the data for an IFileItem is here: http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html


How to get the ISCMService in a Plain Java Client is explained here: https://rsjazz.wordpress.com/2016/02/04/setting-custom-attributes-for-scm-versionables/

Andy Jewell selected this answer as the correct answer

Comments
Andy Jewell commented Mar 10 '17, 10:38 a.m.

 Perfect!  Thanks, Ralph!

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.