How to programmatically add components to workspace
We would programmatically add existing components to new workspace:
IScmService scmService = ... IContributorHandle contributorH = ... IWorkspaceHandle stream = ... IWorkspace wks = scmService.createWorkspace(contributorH, wksName, wksDescription, stream, null, stream, null, null, IRepositoryProgressMonitor.ITEM_FACTORY.createItem(monitor)).getWorkspace();
While the createWorkspace operation creates the new repository workspace, the addComponentFromWorkspace operation does not add the component... We have to call any save/refresh operation?
The code above is called by a save work-item follow up action.
Thanks in advance.
|
4 answers
Ralph Schoon (63.5k●3●36●46)
| answered Sep 09 '13, 10:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I worked from Snippet 2 from the plain Java Client Libraries. I am not sure where you have your code. On a client I was able to add components this way:
// Add new components Collection Comments The snippet is the correct way to do it. Using the service is a different layer, not recommended, and is also the deprecated call.
1
Ralph Schoon
commented Sep 09 '13, 10:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Tim, I think the snippets should be reworked, there are several deprecated methods in usage and I actually had to dig into the deprecated call to figure out the ones not deprecated.
We are using the IScmService service beacuse we are on a server extension, not on a client... IScmService#updateComponents2(...) is the current call to add a component to a workspace.
|
Ok, we found what was the problem! :D
The repository worskpace is created as well as components are added, but when that workspace is used as a build workspace (and this is our case!), components are dropped by the build request process if the flow targets table does not contain streams where components belong.
By the way, this behavior seems quite strange for us...
|
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
During further investigation, it appears that added components are dropped by the save transaction. Any advice?