It's all about the answers!

Ask a question

Add administrator to existing team area using Java API


Kaushambi Singh (371310379) | asked Jul 15 '13, 9:27 a.m.
edited Jul 15 '13, 2:24 p.m.
 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



permanent link
Ralph Schoon (63.1k33645) | 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.

permanent link
Kaushambi Singh (371310379) | answered Jul 15 '13, 2:26 p.m.
 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


Register or to post your answer.