How to find a workspace by name
Hello,
I need a help. I found several examples, but only for "client-side". My advisor is "server-side" and I need to find a workspace by name. I'll set the UUDI in a build definition property on the request. Already tried to use "IRepositoryItemService", "IScmService", but I don't found a "findWorkspacesByName" method. Can anybody help me? |
Accepted answer
Hi, on server side you need to use the IScmQueryService.findWorkspaces method using a IWorkspaceSearchCriteria.
In the IWorkspaceSearchCriteria you can set the type of the workspace (IWorkspaceSearchCriteria.STREAMS or WORKSPACE or ALL), the name (exact or partial) and the owner. You can obtain a IWorkspaceSearchCriteria object using its own factory. Michele. Pietro Bottino selected this answer as the correct answer
Comments Thanks by answer Michele.
Pietro Bottino
commented Apr 19 '16, 9:38 a.m.
I used the IScmQueryService and worked.
|
One other answer
I resolved this question.
Below is the used code: private UUID getWorkspaceUUIDFromName(String workspaceName) throws TeamRepositoryException { IWorkspaceSearchCriteria search = IWorkspaceSearchCriteria.FACTORY.newInstance(); search.setExactName(workspaceName); IScmQueryService service = getService(IScmQueryService.class); ItemQueryResult foundWorkspace = service.findWorkspaces(search, 10, null); if (foundWorkspace != null) { IWorkspaceHandle workspaceHandle = (IWorkspaceHandle) foundWorkspace.getItemHandles().get(0); return workspaceHandle.getItemId(); } return null; } |
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.
Comments
Are you referring a "repository workspace"?
In https://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/ I use the workspace manager and findWorkspaces(). Not sure if this is available in the server API.
Thanks Donald and Ralph.
Donald,
yes, I refer to the "repository workspace".
Ralph,
I already read this article, but in the server API I don't found a "workspace manager".