Howto use method setWorkspaceFlows in IScmService
I am implementing a service and have to set the deliver flow target of the workspace that is going to be built to a specific target stream to be able to get a reference to this stream again after a successful build using the build result to get the build definition, the build definition to get the workspace that has been built and the workspace to get its deliver flow target to finally compare the workspace to the target stream and release the outgoing change sets from the workspace into the target stream.
I am trying to use the method
but I do not really understand what parameters I have to use to make it work. Especially the parameter 'CurrentFlows currentFlows' causes either an ImmutablePropertyException when I try to set the CurrentDeliverFlow of the workspace directly using '((Workspace)workspace).setCurrentDeliverFlow(targetStream), an IllegalArgumentAcception when I am trying to use the working copy of the workspace or an IllegalArgumentAcception with reason 'Specified current deliver flow is not in the list of deliver flows' when I do not try to set the current deliver flow at all in the currentFlows-parameter.
I am also unsure about the 'acceptFlows'-, the 'deliverFlows'- and the 'componentCurrentFlows'-parameters. As explained above, all I need to do is to set the deliver flow target of the workspace to the target stream.
I am trying to use the method
com.ibm.team.scm.common.IScmService.setWorkspaceFlows(IWorkspaceHandle workspace, IFlowEntry[] acceptFlows, IFlowEntry[] deliverFlows, CurrentFlows currentFlows, IComponentHandle[] components, CurrentFlows[] componentCurrentFlows, ISynchronizationTimes[] syncTimes, IRepositoryProgressMonitorHandle monitor) throws TeamRepositoryException
but I do not really understand what parameters I have to use to make it work. Especially the parameter 'CurrentFlows currentFlows' causes either an ImmutablePropertyException when I try to set the CurrentDeliverFlow of the workspace directly using '((Workspace)workspace).setCurrentDeliverFlow(targetStream), an IllegalArgumentAcception when I am trying to use the working copy of the workspace or an IllegalArgumentAcception with reason 'Specified current deliver flow is not in the list of deliver flows' when I do not try to set the current deliver flow at all in the currentFlows-parameter.
I am also unsure about the 'acceptFlows'-, the 'deliverFlows'- and the 'componentCurrentFlows'-parameters. As explained above, all I need to do is to set the deliver flow target of the workspace to the target stream.
One answer
I have never used that call.. seems pretty challenging..
when up update the flow table of a workspace, you update it directly, and then set the flow table back into the workspace..
from my copy workspace utility
// get the flow table working copy
IFlowTable dest_flowtable = new_destworkspace.getFlowTable().getWorkingCopy();
// add the flow target to the table
dest_flowtable.addAcceptFlow(destacceptStream.getResolvedWorkspace(), destrepo.getId(), destrepo.getRepositoryURI(), null, destacceptStream.getDescription());
// if you need to set current/default
// AFTER you have added to the flow table, you get the handle back out
// get the flow entry from the table for this stream
IFlowEntry newnode = dest_flowtable.getAcceptFlow(destacceptStream.getResolvedWorkspace());
// set current
dest_flowtable.setCurrent(newnode);
// save the updated flow table
new_destworkspace.setFlowTable(dest_flowtable, null);
when up update the flow table of a workspace, you update it directly, and then set the flow table back into the workspace..
from my copy workspace utility
// get the flow table working copy
IFlowTable dest_flowtable = new_destworkspace.getFlowTable().getWorkingCopy();
// add the flow target to the table
dest_flowtable.addAcceptFlow(destacceptStream.getResolvedWorkspace(), destrepo.getId(), destrepo.getRepositoryURI(), null, destacceptStream.getDescription());
// if you need to set current/default
// AFTER you have added to the flow table, you get the handle back out
// get the flow entry from the table for this stream
IFlowEntry newnode = dest_flowtable.getAcceptFlow(destacceptStream.getResolvedWorkspace());
// set current
dest_flowtable.setCurrent(newnode);
// save the updated flow table
new_destworkspace.setFlowTable(dest_flowtable, null);
Comments
I am afraid this does not work because you are using an IWorkspaceConnection object which is available in the client API only (i. e. com.ibm.team.scm.client.IWorkspaceConnection). I am trying to change the flow target in a service on the RTC server, so I can only use the Server API and just have an IWorkspace object.