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?
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.
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.
One other answer
I resolved this question.
Below is the used code:
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
Donald Nong
Apr 18 '16, 11:42 p.m.Are you referring a "repository workspace"?
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Apr 19 '16, 2:58 a.m.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.
Pietro Bottino
Apr 19 '16, 8:01 a.m.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".