NPE using IProcessAreaWorkingCopy
![]() Version 6.0.3 (also had same problem with Version 5.0.2)
|
Accepted answer
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Mar 07 '17, 8:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER In Snippet3 of the plain Java client Libraries there is no disconnect or dispose: I use this code and it does not disconnect either /* * Adds a user as a member with a specific role to a process area * * @param user * @param role * @param processArea * @param itemService * @param monitor * @throws TeamRepositoryException / public static void addMemberToProcessArea(IContributor user, IRole role, IProcessArea processArea, IProcessItemService itemService, IProgressMonitor monitor) throws TeamRepositoryException { IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy) itemService .getWorkingCopyManager().createPrivateWorkingCopy( processArea); areaWc.getTeam().addContributorsSettingRoleCast( new IContributor[] { user }, new IRole[] { role }); areaWc.save(monitor); } Sian O'Briain selected this answer as the correct answer
Comments thanks but I also tried using .createPrivateWorkingCopy(teamArea) instead of .getWorkingCopy(teamArea)
sorry I misunderstood! I had tried using .createPrivateWorkingCopy(teamArea) but had left in the copyManager.connect(teamArea)
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I have not used it for multiple project areas/team areas, sorry. There might be more effective API that can do more in parallel, but I have not looked that deep. This was sufficient for my needs.
Great that it is working for you now.
|
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
Previously I was using the ProcessAreaWorkingCopy class before I found this IProcessAreaWorkingCopy class. Previously I saw this error when deleting members but now it only seems to come up when adding roles. I have tried to use both methods
workingCopy.getTeam().addContributorsSettingRoleCast(userObjectArray,new IRole[]{teamMemberRole});
and also adding contributors and then setting role:
workingCopy.getTeam().setRoleCast(contrib, teamMemberRoleArray);
actually no, a red herring, seeing again for deletes: