It's all about the answers!

Ask a question

Getting a user's repository workspaces under a project area using RTC Java API


Mike Polan (2234) | asked Mar 08 '15, 6:17 p.m.
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!

Accepted answer


permanent link
Evan Hughes (2.4k1118) | answered Mar 09 '15, 2:26 p.m.
JAZZ DEVELOPER
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() .
Mike Polan selected this answer as the correct answer

2 other answers



permanent link
sam detweiler (12.4k6179201) | answered Mar 09 '15, 12:17 a.m.
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);

Comments
Geoffrey Clemm commented Mar 09 '15, 2:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


permanent link
Mike Polan (2234) | answered Mar 12 '15, 11:52 a.m.
Thanks for the replies everyone. Indeed I was misunderstanding where the repository workspaces live, so my original use case is probably not valid. Fetching all of a user's workspaces is the approach I will go with.

Your answer


Register or to post your answer.