It's all about the answers!

Ask a question

RTC API add/remove user corupts team area


Kamil Jezek (4613) | asked Oct 21 '16, 8:46 a.m.
edited Oct 21 '16, 8:51 a.m.
I have a straightforward code to manipulate members in a team are:

IContributorManager conManager = repo.contributorManager();
IContributor contributor = conManager.fetchContributorByUserId(uid, new NullProgressMonitor());
IProcessItemService itemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
List<IProjectArea> areas = itemService.findAllProjectAreas(null, null);

for (IProjectArea projectArea : areas) {
 IProjectArea mutableProjectCopy = (IProjectArea) itemService.getMutableCopy(projectArea);
 if ("some logic") {
 processArea.addMember(contributor);
 } else {
 processArea.removeMember(contributor);
 }
 // similar code omitted here for add/remove administrator
itemService.save(new IProjectArea[] {mutableProjectCopy}, null);
}

The code works for most of the time, but time-to-time the project area is corrupted, showing an exception below in the project view.

Does my code need any kind of synchronization/transaction etc.?

The following record was not found in the database:  com.ibm.team.repository.common.model.impl.ContributorHandleImpl@7f8c1d4f (stateId: , itemId: [UUID _8lNyYNwSEd2pIJ5QVwgQGg], origin: null, immutable: )ID CRJAZ0215E

com.ibm.team.repository.common.ItemNotFoundException
com.ibm.team.repository.service.internal.RepositoryItemService.doFetchItem(RepositoryItemService.java:575) com.ibm.team.repository.service.internal.RepositoryItemService.access$4(RepositoryItemService.java:568) com.ibm.team.repository.service.internal.RepositoryItemService$5.run(RepositoryItemService.java:548) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:567) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:342) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withNewDeferredConnection(ConnectionPoolService.java:545) com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentDeferredConnection(ConnectionPoolService.java:563) sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) java.lang.reflect.Method.invoke(Method.java:611) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347) org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56) com.sun.proxy.$Proxy143.withCurrentDeferredConnection(Unknown Source) com.ibm.team.repository.service.internal.rdb.RepositoryDatabase.runTransaction(RepositoryDatabase.java:339)

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Oct 24 '16, 4:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I use the same code in https://rsjazz.wordpress.com/2013/09/18/deploying-templates-and-creating-projects-using-the-plain-java-clients-library/ and I have never experienced an issue with it so far.

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.