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
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; } |
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".