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

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.

0 votes

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,

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.

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.

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.

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

showing 5 of 6 show 1 more comments

Accepted answer

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

0 votes

Comments

AbstractScmService is only used if you extend an SCM operation. Not if you are in a work item save context.

I made changes as you suggested.
It worked for me.

Thank You


2 other answers

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

0 votes

Comments

 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.

 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

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

0 votes

Comments

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.

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.

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

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,941

Question asked: Aug 03 '15, 2:42 a.m.

Question was seen: 3,034 times

Last updated: Aug 05 '15, 9:42 a.m.

Confirmation Cancel Confirm