Getting a user's repository workspaces under a project area using RTC Java API
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
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
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);