It's all about the answers!

Ask a question

How to retrieve IBaseLineSetHandle from URI (rather than UUID) ?


0
1
Arne Bister (2.6k12832) | asked Jun 10 '14, 3:22 p.m.
JAZZ DEVELOPER
edited Jun 10 '14, 3:24 p.m.
Jazzers,

currently I am passing to my class a String which is the UUID of a snapshot.
I am then transforming it to UUID snapId = UUID.valueOf(String)
and finding the snapshot item handle by means of:
IBaselineSetHandle snapshotHandle = (IBaselineSetHandle) IBaselineSet.ITEM_TYPE.createItemHandle(snapId, null);

This works pretty well but I really would like to pass the full URI to the snapshot object rather than the UUID for various reasons. Is there any easy out of the box way of obtaining an ItemHandle from the URI of an object? Or do I need to write a parser for the URI, keeping in mind that while the UUID starts with _ there might be plenty _ elsewhere in the URI?

If you know a call or have such a parser please share.

Best,
Arne

Accepted answer


permanent link
Arne Bister (2.6k12832) | answered Jun 10 '14, 5:10 p.m.
JAZZ DEVELOPER
Thanks to Michael Valenta I was able to find an easy way to achieve this. This is the code snippet:

URI snapUri= URI.create(snapshotIdentifier.replaceAll(" ", "%20"));
           
Location snapLoc = Location.location(snapUri);
IBaselineSet snapshotItem = (IBaselineSet)
         teamRepository.itemManager().fetchCompleteItem(snapLoc,IItemManager.DEFAULT, monitor);


The advantage of passing a snapshot URI rather than the UUID is that the URI can be easily retrieved e.g. from Snapshot Context Menu (copy URL).

- Arne
Ralph Schoon selected this answer as the correct answer

Comments
Ralph Schoon commented Jun 11 '14, 3:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Thanks for sharing Arne!

One other answer



permanent link
sam detweiler (12.5k6195201) | answered Jun 10 '14, 3:58 p.m.
how is it that u have the URI? but not the UUID?

Comments
Arne Bister commented Jun 10 '14, 5:12 p.m.
JAZZ DEVELOPER

Sam, I am feeding that parameter manually into a build run. Previously, I simply copied the latter part of the URI because I only knew how to construct the ItemHandle from UUID. But I know that now ;-)


sam detweiler commented Jun 11 '14, 7:16 a.m.

I read your words, but didn't get any info!..

where did u get the 'parameter' data from?   I got the point IF you had a URI, how to find the object.

above it says 'snapshotIdentifier', what is that? cause u CREATE the URI from it.

you must have some piece of code that s running for same reason.


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.