It's all about the answers!

Ask a question

How to change the ownership of a component ?


Rinkal Garg (1729) | asked Jun 12 '18, 2:24 a.m.

 I have found one code snippet from somewhere but it is not working for me. Can you please help me on this 

IScmService scmService = null; 
IRepositoryItemService itemService;
IComponentHandle componentH;
ComponentOwnerHandle componentOwnerH = scmService.getComponentOwnerRecord((ComponentHandle) componentH);
ComponentOwner componentOwner = (ComponentOwner) itemService.fetchItem(componentOwnerH, IRepositoryRemoteService.COMPLETE);
IAuditableHandle ownerH = componentOwner.getOwner();
if (componentHandle == null) {
// Rename component
componentHandle = wm.createComponent(componentName,
teamRepository.loggedInContributor(), monitor);
wm.setComponentOwner(componentHandle, ownerH, monitor);
} else {
// Rename component
wm.renameComponent(componentHandle, componentName, monitor);
wm.setComponentOwner(componentHandle, ownerH, monitor);
}

One answer



permanent link
Ralph Schoon (63.7k33648) | answered Jun 12 '18, 4:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
  1. " I have found one code snippet from somewhere but it is not working for me." This is a pointless statement.
  2. The snippet is from https://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/ it basically works
  3. The code to get a component owner in your example seems to be pretty pointless and does not seem to do anything useful. If you had a reasonable value in ownerH your code might even do something. Since you seem to get the old owner and set that, what do you expect?


Comments
Ralph Schoon commented Jun 12 '18, 4:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
wm.setComponentOwner(componentHandle, newOwnerHandle , monitor);

newOwnerHandle the new owner; must be either a IContributorHandle or a IProcessAreaHandle; must not be null (IProcessAreaHandle = ProjectAreaHandle or TeamAreaHandle)

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.