It's all about the answers!

Ask a question

create Team Area from Server API


0
1
Miguel Tomico (5001323) | asked Feb 20 '15, 8:35 a.m.
There are many posts on how to manage Team Areas using the client API.
In particular, to create a Team Area:
IProcessItemService processItemService = (IProcessItemService) repo.getClientLibrary(IProcessServerService.class);
ITeamArea newTeam = processItemService.createTeamArea();

But what if we need to create a Team Area from an OperationParticipant (server side)?
I haven't been able to find the proper ItemService (note that IProcessItemService belongs to the com.ibm.team.process.client package)

Has anybody dealt with this before?

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Feb 20 '15, 9:00 a.m.
Looking thru the SDK source it seems like the com.ibm.team.process\service\internal\ProcessService should do it..
in com.ibm.team.process.service_???.jar

has a method saveProcessItem()  which is effectively what I use in my client side project copy utility.

create a TeamArea object, populate it and then 'save' it using the save ProcessItem() api.

note that the Participant is running in the context of the user that made the change, and as such may NOT have permissions to do this operation.. (save teamarea)
Miguel Tomico selected this answer as the correct answer

One other answer



permanent link
Miguel Tomico (5001323) | answered Feb 20 '15, 9:52 a.m.
Thank you, Sam. Helpful as usual ;-)
Playing with com.ibm.team.process\service\internal\ProcessService, as you suggested, I remembered a similar class I had used in the past: IAuditableServer. It belongs to com.ibm.team.workitem.service, so I have given it a try and it seems to work.
Here's the sample code: 

IAuditableServer auditableService = workItemService.getAuditableServer();
ITeamArea newTeam = (ITeamArea) auditableService.createAuditable(ITeamArea.ITEM_TYPE);
IProjectArea prj = (IProjectArea) itemService.fetchItem(newWorkItem.getProjectArea(), IRepositoryItemService.COMPLETE);
prj = (IProjectArea) prj.getWorkingCopy();
newTeam.setName("myteam");
newTeam.setProjectArea(prj);
//This assumes we already have the parent ITeamArea in parentTeam variable
prj.getTeamAreaHierarchy().addChild(parentTeam, newTeam);
List<IProcessItem> itemsToSave = new ArrayList();
itemsToSave.add(prj);
itemsToSave.add(newTeam);
auditableService.saveProcessItems(itemsToSave, monitor);

Comments
sam detweiler commented Feb 20 '15, 11:08 a.m.

great!.. I give you an answer, then you go off on your own!!.. :-)

thanks for posting back, will help others..
I forget about that AuditableServer service!..

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.