Get an Item From its URL


This came up on the form recently. It is interesting, because in several areas, including the web UI the URL is what is exposed and not an item ID.

I basically browsed the RTC SDK (using my standard setup described here) and searched for java.net.URI as parameter.

I finally found com.ibm.team.repository.common.Location being used for this purpose. You can basically create a location from an URI and get to the object. There are several methods to get at the item handle. For example Location.itemOidUriToHandle(). See Arne’s answer to his own question for details how he does the trick in an example. To be able to find it in searches, here the code:

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

I used Location also in this post to create links with back links between items.

Just Starting With Extending RTC?

If you just get started with extending Rational Team Concert, or create API based automation, start with the post Learning To Fly: Getting Started with the RTC Java API’s and follow the linked resources.

You should be able to use the following code in this environment and get your own automation or extension working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.