It's all about the answers!

Ask a question

How to create duplicate stream using Server Side plugin


priyanka jogdand (155) | asked Jun 05 '19, 4:38 a.m.

 Hi All,

I have requirement to create duplicate stream based on previous stream using Server Side API on Workitem save operation. To achieve this firstly I need to fetch all streams and then need to duplicate stream.
To fetch all stream  I am trying to use following code the getting following error:

public class DuplicateStream extends AbstractService implements
IOperationParticipant {
Object operationData = operation.getOperationData();
if(data instanceof ISaveParameter)
      {
DeliverOperationData data1 = (DeliverOperationData) operationData;
IWorkspace target = data1.getSourceWorkspace();
String targetStream = target.getName();
      }
}
code is breaking on DeliverOperationData and says: 
com.ibm.team.workitem.common.internal.SaveParameter incompatible with com.ibm.team.scm.common.process.DeliverOperationData

How to make DeliverOperationData and DeliverOperationData compatible?
Or Is there any other approach to achieve this?
Thanks!



One answer



permanent link
David Lafreniere (4.8k7) | answered Jun 05 '19, 1:06 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
"com.ibm.team.scm.common.process.DeliverOperationData" is the data associated with a delivery operation (i.e. change set deliveries to a stream), and "com.ibm.team.workitem.common.internal.SaveParameter" is the data associated with a work item save operation. These are two different operations and are not at all related to each other (i.e. there's no way to make a "DeliverOperationData and DeliverOperationData compatible", as part of your question).

Also, would you mind explaining your use case a little more?

Comments
priyanka jogdand commented Jun 06 '19, 1:15 a.m. | edited Jun 06 '19, 10:02 a.m.

  Thanks David for your quick response. Yes, you are right, we can not make two different operation compatible.

My use case is like Auto duplicating stream from existing stream on Workitem save operation using Server side API. Creating stream using client side API is available but I want to do this using Server Side API. 
I have changed my approach and found out SCM API to achieve this.
Firstly, created instance IScmService and used IScmQueryService to search stream that I want to duplicate and used following code.

 IScmService scmService = (IScmService) Service.getService(IScmService.class);
// To search stream 
 IWorkspaceSearchCriteria search = IWorkspaceSearchCriteria.FACTORY.newInstance();
// To create  duplicate stream 
 WorkspaceRefreshResult i3= scmService1.copyWorkspace(IAuditableHandle scopehandle, IWorkspaceHandle workspacehandle, RemoteRepoDescriptor null, "Stream Name", "Stream Description", ISynchronizationTimes[] null , IRepositoryProgressMonitorHandle monitor);

It works for me!

Your answer


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