Getting a user's repository workspaces under a project area using RTC Java API
![](http://jazz.net/_images/myphoto/6b4ab387e2c37082e6d09fe45a566689.jpg)
Hi everyone,
I'm using the RTC Java APIs to access our Jazz server (version 4.x). Is there a way to get a list of all of a user's repository workspaces that are under a certain IProjectArea? I've been looking at the samples, and I see how to get a list of ALL the workspaces that a user made using the WorkspaceSearchCriteria methods, but I don't see an obvious way to check what project area each IWorkspace belongs to.
This seems like it should be simple, but I just can't find a way to do it. Does anyone have any suggestions?
Thanks!
I'm using the RTC Java APIs to access our Jazz server (version 4.x). Is there a way to get a list of all of a user's repository workspaces that are under a certain IProjectArea? I've been looking at the samples, and I see how to get a list of ALL the workspaces that a user made using the WorkspaceSearchCriteria methods, but I don't see an obvious way to check what project area each IWorkspace belongs to.
This seems like it should be simple, but I just can't find a way to do it. Does anyone have any suggestions?
Thanks!
Accepted answer
![](http://jazz.net/_images/myphoto/6b4ab387e2c37082e6d09fe45a566689.jpg)
Workspaces aren't associated with project/team areas, just the user that created them. You can make some guesses based on the components and flow targets of the workspace, however. Can you tell us a bit more about your use case?
You might be interested in
com.ibm.team.scm.common.internal.IScmQueryService.findWorkspaces()
. If you know the streams in the project/team area, you can use
IWorkspaceSearchCriteria.setFlowFilter()
to limit the set of workspaces returned to those that currently flow with each stream. If there are a lot of streams, you'll have to make lots of calls.
If there are one or more components that are only accessible to members of the project/team area, you can use those to query for workspaces as well. Take a look at
IScmQueryService.searchForWorkspacesForComponent()
.
2 other answers
![](http://jazz.net/_images/myphoto/6b4ab387e2c37082e6d09fe45a566689.jpg)
here is code I use
final IWorkspaceManager wspcmgr = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceSearchCriteria workspacesearchcriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
// say we want workspaces
workspacesearchcriteria.setKind(IWorkspaceSearchCriteria.WORKSPACES);
// for THIS user
workspacesearchcriteria.setExactOwnerName(wkspace_owner.getName());
// get the list
List<IWorkspaceHandle> user_workspacehandles = (List<IWorkspaceHandle>) wpscmgr.findWorkspaces(workspacesearchcriteria, IWorkspaceManager.MAX_QUERY_SIZE, null);
final IWorkspaceManager wspcmgr = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceSearchCriteria workspacesearchcriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
// say we want workspaces
workspacesearchcriteria.setKind(IWorkspaceSearchCriteria.WORKSPACES);
// for THIS user
workspacesearchcriteria.setExactOwnerName(wkspace_owner.getName());
// get the list
List<IWorkspaceHandle> user_workspacehandles = (List<IWorkspaceHandle>) wpscmgr.findWorkspaces(workspacesearchcriteria, IWorkspaceManager.MAX_QUERY_SIZE, null);
Comments
![](http://jazz.net/_images/myphoto/a36d1dcfd3e1e1e00aeb18c860d1443d.jpg)
You will note that Sam's code never refers to a project area, because workspaces do not live in/under a project area. The just live as global objects in the repository, but if you want to think of them as living under something, you can think of them as living under the user that owns them.