how to fetch streams and display its name on console using server side API
Hi All,
I want to fetch all the streams of a project area and display their names on console using server side API.
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(teamRepository);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName);
List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, monitor);
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),monitor);
String obj="";
obj=workspaceConnection.getName();
System.out.println(obj);
this code does the task on client side.
How this can be done using server side API ?
Thank You.
showing 5 of 6
show 1 more comments
|
Accepted answer
Ralph Schoon (63.3k●3●36●46)
| answered Aug 05 '15, 4:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
com.ibm.team.scm.common.dto.IWorkspaceSearchCriteria most likely does not belong there. You most likely have to add another service e.g. com.ibm.team.scm.common.IScmService
Your extension class also has to most likely extend AbstractScmService rather than AbstractService. See https://rsjazz.wordpress.com/2012/11/01/restrict-delivery-of-changesets-to-workitem-types-advisordelivery-of-changesets-associated-to-wrong-work-item-types-advisor/ for an example that works on an SCM operation. vikrant kamble selected this answer as the correct answer
Comments AbstractScmService is only used if you extend an SCM operation. Not if you are in a work item save context.
vikrant kamble
commented Aug 05 '15, 9:20 a.m.
I made changes as you suggested.
|
2 other answers
Hi,
you have to use com.ibm.team.scm.common.internal.IScmQueryService instead of IWorkspaceManager. This service have a findWorkspace method that accepts IWorkspaceCriteria.
Of course you have to obtain the service after you've defined it in the plugin.xml as requiredservice.
Comments
vikrant kamble
commented Aug 04 '15, 12:42 a.m.
Hi Michele,
I figured that out while searching for findWorkspaces method in server API.
I used this method as follows
findWorkspaces(workspacesearchcriteria, integer_variable,null);
I passed null as third parameter where we should pass object of IRepositoryProgressMonitor.
Please tell me if this is right?
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),monitor);
This method fetches stream of zeroth index in object of IWorkspaceConnection.
But I was not able to find method similar to this in server API.
Michele Pegoraro
commented Aug 04 '15, 4:21 a.m.
IWorkspaceConnection is used only on PlainAPI.
With SDK (server side) you have to get the IScmQueryService (using getServices method obtained by extended class AbstractService). This service has the findWorkspace method you need.
ProgressMonitor could be null, it's not a problem.
Hi Michele
Thanks for advice, however I am getting another problem here.
I tried to run this plugin on jetty.
following is the error
CRJAZ1094I The service "com.self.displaystream.DisplayStream" failed to be activated because a service it depends on, "com.ibm.team.scm.common.dto.IWorkspaceSearchCriteria;", has not been acquired and forcing service activation was not requested.
I am not getting reason of this error because in plugin.xml file, I added this interface under prerequisites tag. I also added scm.common and scm.service in the dependencies tab.
Could you please help me on this?
Put everything you get using getService() into the prerequisites and remove entries that the plugin might choke on.
Hi Ralph,
I have done that already.
It is still giving me same error
Michele Pegoraro
commented Aug 04 '15, 10:09 a.m.
That error is related to prerequisite tag on plugin.xml. Could you paste this extension part of the plugin.xml?
showing 5 of 6
show 1 more comments
|
I could not paste it in comment.
Here is my plugin.xml <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="com.ibm.team.process.service.operationParticipants"> <operationParticipant class="com.datamato.displaystream.DisplayStream" id="com.datamato.displaystream.operationParticipant1" name="Show Stream Name IN WIE" operationId="com.ibm.team.workitem.operation.workItemSave"> <extensionService componentId="com.datamato.displaystream.extensionService1" implementationClass="com.datamato.displaystream.DisplayStream"> <prerequisites> <requiredservice interface="com.ibm.team.workitem.service.IWorkItemServer"/> <requiredservice interface="com.ibm.team.workitem.common.IWorkItemCommon"/> <requiredservice interface="com.ibm.team.scm.common.internal.IScmQueryService"/> <requiredservice interface="com.ibm.team.scm.common.dto.IWorkspaceSearchCriteria"/> </prerequisites> </extensionService> </operationParticipant> </extension> </plugin> Comments
Michele Pegoraro
commented Aug 05 '15, 5:11 a.m.
As Ralph said required service have to include only services, not IWorkspaceSearchCriteria, I also think that having both IWorkItemServer and IWorkItemCommon is a duplication, but it should not give you problem.
vikrant kamble
commented Aug 05 '15, 9:27 a.m.
Yes,
Because the IScmService is the most fundamental service most SCM operations rely upon.
|
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
what server side console? there isn't one.
if you mean creating a web app that run on the same tomcat/websphere server, then its still a client to RTC.
server side runs IN the RTC server process..
Hi Sam,
Ok, I am confused again.. the work item editor is a client. so why do you need to display this on the server side?
the code is fundamentally the same, just need to understand that you are IN the repository, so you don't need to 'connect to it'. and link the client side, you need to load the services you want to use.. for plugins you have to do the dependencies in the plugin.xml..
I would take the extensions class to show how to do all this, altho not source specific.
I wrote this little routine to connect to the SCM service
import com.ibm.team.scm.common.IScmService;
private volatile IScmService scmService;
public IScmService getScmService()
{
if ( scmService == null ) {
scmService = getService(IScmService.class);
}
return scmService;
}
Actually I want to develop a plugin which will be deployed on server. This plugin will display all the stream names on work item editor after work item is saved. In short I want to create an operation participant.
Please tell me about server API which will fetch streams of a particular project area.
connect your dev environment to the SDK, and look at the SCMService class.. ti is the equivalent of the SCMPlatform client side class.
there is no doc on the server side classes.. you have to dig and discover them yourself..
what I did was find a built in plugin (the deliver plugin), configure it, look at the class names, and then search thru the sdk source to find it and figure out how it works.
import com.ibm.team.scm.common.IScmService
common means it works for both client and server..
so you could find the source for that in the SDK
I''m still not sure why you need to do this.. as the display is on client side, just use the client api calls.
you don't need to create another service (I've done that too) as the data is available to you already