It's all about the answers!

Ask a question

how to fetch streams and display its name on console using server side API


vikrant kamble (132558) | asked Aug 03 '15, 2:42 a.m.
edited Aug 03 '15, 6:41 a.m.
 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.

Comments
sam detweiler commented Aug 03 '15, 7:43 a.m.

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


vikrant kamble commented Aug 03 '15, 8:17 a.m.

  Hi Sam,

Actually I want to develop a plug-in. Which will display all the streams names on work item editor.
But before going directly to that I referred some example provided on rsjazz.wordpress.com.
Above code displays stream names on RTC eclipse console. I want to know server API which will do the same task for me. I will first check it on jetty(I have configured jetty). Before directly displaying its value on work item editor I wanted to check if i can display it on console of jetty.


sam detweiler commented Aug 03 '15, 8:28 a.m. | edited Aug 03 '15, 8:30 a.m.

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


vikrant kamble commented Aug 03 '15, 8:41 a.m. | edited Aug 03 '15, 8:42 a.m.

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.

I cannot use 
 IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(teamRepository);
and
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),monitor); 

I cannot use above line of code because these are interfaces and methods are from client API.
I want to know server API which will do the same task.


vikrant kamble commented Aug 03 '15, 8:47 a.m.

Please tell me about server API which will fetch streams of a particular project area.


sam detweiler commented Aug 03 '15, 8:52 a.m.

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

showing 5 of 6 show 1 more comments

Accepted answer


permanent link
Ralph Schoon (57.0k23642) | 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
Ralph Schoon commented Aug 05 '15, 5:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.
It worked for me.

Thank You

2 other answers



permanent link
Michele Pegoraro (1.8k12110101) | answered Aug 03 '15, 10:24 a.m.
 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.


vikrant kamble commented Aug 04 '15, 6:04 a.m. | edited Aug 04 '15, 6:06 a.m.

 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?


Ralph Schoon commented Aug 04 '15, 7:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Put everything you get using getService() into the prerequisites and remove entries that the plugin might choke on.


vikrant kamble commented Aug 04 '15, 8:31 a.m. | edited Aug 04 '15, 9:25 a.m.

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

permanent link
vikrant kamble (132558) | answered Aug 05 '15, 3:42 a.m.
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,
I removed IWorkspaceSearchCriteria from prerequisites and added IScmServices in the prerequisites. I have no idea why I had to add IScmService in prerequisites because I did not used IScmService interface in my program.
But It solved my problem which I was getting before.


Ralph Schoon commented Aug 05 '15, 9:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Because the IScmService is the most fundamental service most SCM operations rely upon.

Your answer


Register or to post your answer.