How to get Stream, Component, Workspace using server api.
Accepted answer
What is your starting point?
I mean, when server API are invoked in a plugin, you are performing an action.
Anyway, you can retrieve a stream, or a workspace, that has a specific name with this code:
IWorkspaceHandle workspaceHandle = null;
IScmQueryService scmQueryService = getService(IScmQueryService.class);
IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
criteria.setKind(IWorkspaceSearchCriteria.ALL);
criteria.setExactName(streamName);
List<IWorkspaceHandle> workspaceHandles = scmQueryService.findWorkspaces(criteria, Integer.MAX_VALUE, repositoryProgressMonitorHandle).getItemHandles();
if (!workspaceHandles.isEmpty()) {
workspaceHandle = workspaceHandles.get(0);
}
return workspaceHandle;
If you are dealing with change sets (a typical situation during delivery or checkin), you can easily retrieve the component it belongs to:
changeSet.getComponent();
I hope that these snippets help.
One other answer
Since this totally depends on what data you have available and what the server API context is, there is no reasonable way to answer.
I have explained some of the SCM API in the posts https://rsjazz.wordpress.com/tag/scm/
Note, dependent on the post it is client or common or server API. In the server you can only use Common and Server API (look for common or server in the package name, avoid client or rcp in the package names).
Maybe there is more to answer, once you care to provide what you want to do, where and why. See: How should I ask a question in the Forum if I want to receive useful answers?