Add administrator to existing team area using Java API
I want to add administrator in the existing team area using plain Java API. I can successfully add administrator while creating new team areas but the same thing doesn't work when I try to add administrator to existing team areas. I get a long error message.
List <TeamAreaHandle> teamlist = area.getTeamAreas();
ITeamAreaHandle newTAHandle = findTeamAreaByName(teamlist,teamAreaName,monitor);
ITeamArea TA = (ITeamArea)teamRepository.itemManager().fetchCompleteItem(newTAHandle,ItemManager.DEFAULT,monitor);
IContributor contributor =teamRepository.contributorManager().fetchContributorByUserId(administrator, monitor);
if (TA !=null){
TA.addAdministrator(contributor);
}
Error message:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2060)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:255)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:310)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
at com.ibm.team.process.internal.common.impl.ProcessAreaImpl.addAdministrator(ProcessAreaImpl.java:1390)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:597)
at $Proxy15.addAdministrator(Unknown Source)
|
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Jul 15 '13, 9:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jul 15 '13, 9:54 a.m.
Please have a look into the snippets that ship with the Plain Java Client Libraries. Snippet 3 shows code how to do this. http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ talks about getting working copies so that you can modify artifacts.
|
I could get this working now. Thanks Ralph for your hint.
IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy)service.getWorkingCopyManager().createPrivateWorkingCopy(TA);
areaWc.getAdministrators().addContributors(new IContributor[] {contributor});
areaWc.save(monitor);
|
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.