Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

0 votes

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


Accepted answer

Permanent link
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

0 votes

Comments

Thanks by answer Michele.

Currently I'm trying to use the IWorkspaceSearchCriteria, but I don't know how to execute the "search". In the client API has a "findWorkspaces" and in the server API I don't found a similar method.

I used the IScmQueryService and worked.

I'll post the code.


One other answer

Permanent link
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;
	
    }
	

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952

Question asked: Apr 18 '16, 4:36 p.m.

Question was seen: 2,538 times

Last updated: Apr 19 '16, 10:31 a.m.

Confirmation Cancel Confirm