Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Get Stream from ProjectArea using RTC API 4

Hello I have been trying to get the stream name using projectArea. I have the following parameter: Repository IFileItem WorkItem and its ChangeSets

Is it possible to get it.

Thanks in advance.

Please don't give me a link to the advisor example as I already read it and I couldn't make it as I couldn't figure how to create AdvisableOperation as I just search of the full path of a specific file within a project area.

At this post,it was mentioned the following : https://jazz.net/forum/questions/49910/how-to-get-an-iconfiguration-from-ichangeset

There is a hint that is often useful (but not necessarily always correct), hidden in the ILink which serves as the binding between the IChangeSetHandle (source) and the IWorkItemHandle (target). The IItemReference for the source side has a String extraInfo field which can be retrieved via IItemReference#getExtraInfo(). This string will be of the format IWorkspace= which indicates the originating workspace. You can create a handle to the IWorkspace by using IWorkspace.ITEM_TYPE.createItemHandle(suppliedUUID, null).

public void testWorkspaceConnection(ITeamRepository repository, IWorkItem workItem) throws TeamRepositoryException, IOException{
       List<ILink> changeSetLinks = (List<ILink>)linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set");
       List<IReference> changeSetReferences = new ArrayList<IReference>();

         for (ILink link : changeSetLinks) {
            changeSetReferences.add(link.getSourceRef());
         }

         List<IItemHandle> itemHandles = new ArrayList<IItemHandle>();

         for (IReference reference : changeSetReferences) {
             itemHandles.add((IItemHandle)reference.resolve());
         }

         if(itemHandles.isEmpty()){
             return;
         }

         IItemHandle itemHandle = itemHandles.get(itemHandles.size() - 1);
         IChangeSet changeSet = (IChangeSet)repository.itemManager().fetchCompleteItem(itemHandle, 0, monitor);
         List changes = changeSet.changes();         

         IFileItem fileItem = getLogidiagFile(changeSet, repository);
         // TILL HERE THAT WAS AN EXISTING CODE THAT WAS ALREADY THERE AND IT FETCHES THE REQUIRED FILE.
         //NEXT IS WHAT |'VE ADDED TO BE ABLE TO DETERMINE THE FULL PATH
         String uuid=changeSetReferences.get(changeSetReferences.size()-1).getExtraInfo(); //Here I need to get workspace uuid to be abble to create a connection over as the post said
         IWorkspaceHandle workspaceHandle = (IWorkspaceHandle)IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf(uuid), null);

         IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
         IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle,monitor);
	

Exception I get is the following:

Exception in thread "main" java.lang.IllegalArgumentException: invalid UUID [Workspace=_iibA0GlNEeKd76sMjPDLRA] at com.ibm.team.repository.common.UUID.valueOf(UUID.java:76)

So am I walking on the right course or there are a better one you can guide me through!

1

0 votes


Accepted answer

Permanent link
You're getting that invalid UUID exception because, as JohnC mentioned in the answer you referenced, the value you're getting back is in the format: IWorkspace=<UUID>.  It looks like you're passing this entire string to UUID#valueOf() -- you need to pass only the part following the equal sign.

Note, though, that this is the UUID of the change set's originating workspace, not that of the stream, so your current code will end up giving you a connection to the originating workspace of the change set, which may or may not be suitable for your needs.  If you want to find a stream in a project area, I suggest you look into the IWorkspaceManager#findWorkspaces() API.
Fatla 777 selected this answer as the correct answer

1 vote

Comments

Million Thanks John.

I have followed your advice and use the stream instead as follows:

 IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);

IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();

wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);

wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName);

List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor()); 

IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor());

I would appreciate if you can assist me into the rest of my concern:

https://jazz.net/forum/questions/103697/get-the-full-path-of-fileitem

Thanks.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Feb 22 '13, 12:13 p.m.

Question was seen: 6,279 times

Last updated: Feb 22 '13, 4:01 p.m.

Confirmation Cancel Confirm