It's all about the answers!

Ask a question

RTC: Find a Stream by ProjectArea and Contributor using Java API 3 (or 5)

Javier Beneito Barquero (612) | asked Sep 23 '14, 4:13 a.m.
edited Sep 23 '14, 4:57 a.m. by Ralph Schoon (62.3k33643)

I'd like to find Streams using project areas and contributors as query parameters using the Java API.

I'm currently working with the Java API, but soon I could use the 5.0.1 version.

I've found a blog post from Ralph Schoon: "Managing Workspaces, Streams and Components Using the Plain Java Client Libraries" ( that has methods for finding Streams by using the class IWorkspaceManager, specifically, findWorkspaces with a IWorkspaceSearchCriteria.

Fatla 777 asked something similar, Get Stream from ProjectArea using RTC API 4 , and I've used the code that is included in the comment that was made in Feb 22 '13, 3:00 p.m:

IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName); //I've donde this
// How can I provide the Contributor?
List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor()); //It returns an empty list in my case
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor());

But it doesn't work. It returns an empty List.

I've searched the Stream for printing its projectArea (actually, its process area) and the name that I've provided seems correct.

Can anyone tell me if I'm providing the project area name erroneously? and how can I filter Streams by Contributor?

Thank you very much,

Ralph Schoon commented Sep 23 '14, 4:22 a.m. | edited Sep 23 '14, 4:22 a.m.

I only know the solution I posted in . I would suggest to search for references to the calls you are doing and try to figure out how these are used in the API. also provides some links to blogs with API usage. Some SCM development colleagues post at

The 3.x and the 5.x APIs are to 99% the same, as far as I can see.

2 answers

permanent link
Javier Beneito Barquero (612) | answered Sep 23 '14, 4:40 a.m.
Thanks Ralph for the reply and for your very interesting blog.

I've been searching for a while, but I have found only the two solutions that I mentioned.

It should work, but it seems it doesn't. As an alternative I'm thinking in finding all the Streams and validate if each of them belongs to the desired Project Area and Contributor.

But it's too "brute force", because there are currently more than 100 Streams.

I'll try with the Java API 5 (but I have to install a RTC v5 before)


Ralph Schoon commented Sep 23 '14, 5:01 a.m.

I think the key here is to look at how the different search criteria are used and which one to pick and how to combine them. As mentioned in several of my blog posts, you can search the SDK for usage of classes etc. provided you set it up as described in my "Setting up" blog. I would try that first and try to understand what the search criteria select, how to set them up and how to get what you want.

As I said, there is very little differences between the 3.x and the 5.x API. All my 3.x work still works in 4.x and 5.x.

Javier Beneito Barquero commented Sep 24 '14, 11:23 a.m.
I did my best. I'll write an answer with my approach.

Please, feel free to make corrections, make any suggestion or whatever you want. Thanks


permanent link
Javier Beneito Barquero (612) | answered Sep 24 '14, 11:24 a.m.
 Almost solved.

The code above works, but in my case (and I don't know if it's a general rule) the Stream belongs to an ItemArea, and I was using the name of the projectArea instead of the particular teamArea.

Anyway, I still miss a clear way to filter by Contributor.

What I've done is to obtain the ProcessArea that the IComponent belongs to, via IWorkspaceConnection.getOwner() (I tried with IWorkspaceConnection.getProcessArea(IProgressMonitor but it didn't return what I expected), and after fetching the complete item...

IProcessArea processArea = (IProcessArea) repository.itemManager().fetchCompleteItem(workspaceConnection.getOwner(), ItemManager.REFRESH, monitor);

... I use the processArea's member list to verify if some of them has an ItemID that is the same of the Contributor I'm interested in.

Brute force again, but I don't know any easier way.

I accept any suggestion.


Your answer

Register or to post your answer.