It's all about the answers!

Ask a question

How to modify access list for Project area?


Krzysztof Kaźmierczyk (7.4k373103) | asked Dec 12 '11, 5:07 a.m.
Hi, I have following issue. I would like to modify access list for given project area. I found following method: projectArea.getReadAccessList() Is that a method I should use? Could you provide me sample of the code how to add given user and add him "developer" role?
Thanks in advance.

9 answers



permanent link
Krzysztof Kaźmierczyk (7.4k373103) | answered Dec 28 '11, 5:13 a.m.
Hello,
It works! Thanks :)

permanent link
Krzysztof Kaźmierczyk (7.4k373103) | answered Dec 27 '11, 7:30 a.m.
Hello,
I used workingCopy now, but the changes are not applied. IReadAccessList does not contain save() method. How I should apply the changes after adding to access list?

permanent link
Krzysztof Kaźmierczyk (7.4k373103) | answered Dec 21 '11, 6:15 a.m.
Thank you Martha :)

Now I believe have the last issue. Here is my code:


ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
IReadAccessList readAccessList = (IReadAccessList) teamRepository.itemManager().fetchCompleteItem(aCLhandle, IItemManager.DEFAULT, null);
IContributor second = teamRepository.contributorManager().fetchContributorByUserId("jerry", null);
IContributorHandle [] toAdd = {second};
readAccessList.addContributors(toAdd);


Now, I get following exception in the last line:

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.addAllUnique(NotifyingListImpl.java:473)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(NotifyingListImpl.java:406)
at org.eclipse.emf.common.util.AbstractEList.addAll(AbstractEList.java:374)
at com.ibm.team.process.internal.common.impl.ReadAccessListImpl.addContributors(ReadAccessListImpl.java:408)
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 $Proxy20.addContributors(Unknown Source)
at CreateWorkItem.run(CreateWorkItem.java:202)


What is wrong with my code?

permanent link
Krzysztof Kaźmierczyk (7.4k373103) | answered Dec 20 '11, 4:18 a.m.
Thank you Parker for your reply. Unfortunately I have another issue:

I know how to fetch IReadAccessListHandle but I do not have any idea how I can retrieve object of type IReadAccessList.

Here is my code:


ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
IReadAccessListHandle ACLhandle = pa.getReadAccessList();
IReadAccessList readAccessList = ????
teamRepository.logout();


Ho to retrieve IReadAccessList object?

permanent link
Kevin Gu (17131) | answered Dec 28 '11, 1:22 a.m.
JAZZ DEVELOPER
Hello,
I used workingCopy now, but the changes are not applied. IReadAccessList does not contain save() method. How I should apply the changes after adding to access list?


Hi,
Get IProcessItemService and then use it to save your changes.

IProcessItemService processItemService = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
processItemService ().save(readAccessList, null);

Kevin
Jazz Foundation Process Team

permanent link
Kevin Gu (17131) | answered Dec 23 '11, 7:09 a.m.
JAZZ DEVELOPER
Thank you Martha :)

Now I believe have the last issue. Here is my code:


ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
IReadAccessList readAccessList = (IReadAccessList) teamRepository.itemManager().fetchCompleteItem(aCLhandle, IItemManager.DEFAULT, null);
IContributor second = teamRepository.contributorManager().fetchContributorByUserId("jerry", null);
IContributorHandle [] toAdd = {second};
readAccessList.addContributors(toAdd);


Now, I get following exception in the last line:

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.addAllUnique(NotifyingListImpl.java:473)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllUnique(NotifyingListImpl.java:406)
at org.eclipse.emf.common.util.AbstractEList.addAll(AbstractEList.java:374)
at com.ibm.team.process.internal.common.impl.ReadAccessListImpl.addContributors(ReadAccessListImpl.java:408)
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 $Proxy20.addContributors(Unknown Source)
at CreateWorkItem.run(CreateWorkItem.java:202)


What is wrong with my code?


Hi krzysztofkazmierczyk,

If you want to modify an IItem, you have to use its workingCopy, e.g.

IReadAccessList readAccessList = (IReadAccessList) teamRepository.itemManager().fetchCompleteItem(aCLhandle, IItemManager.DEFAULT, null).getWorkingCopy();

Kevin
Jazz Foundation Process Team

permanent link
Martha (Ruby) Andrews (3.0k44251) | answered Dec 20 '11, 7:21 p.m.
JAZZ DEVELOPER
Hello,

Use teamRepository.itemManager() to get an IItemManager. Then, call IItemManager.fetchCompleteItem(ACLHandle, flags, progressMonitor) to get the full access list item.

Martha
Jazz Developer, Process team

Thank you Parker for your reply. Unfortunately I have another issue:

I know how to fetch IReadAccessListHandle but I do not have any idea how I can retrieve object of type IReadAccessList.

Here is my code:


ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
IReadAccessListHandle ACLhandle = pa.getReadAccessList();
IReadAccessList readAccessList = ????
teamRepository.logout();


Ho to retrieve IReadAccessList object?

permanent link
Parker Dunton (4064) | answered Dec 12 '11, 5:48 p.m.
JAZZ DEVELOPER
Hi,

You can use the IProjectArea#getReadAccessList() method, then fetch that item handle, then use the IReadAccessList#addContributors() method, then save that modified read access list.

If you don't actually need them to be on the access list specifically, you can also just use IProcessArea#addMember(). I don't think you will be able to assign a role to a user who is on the access list but not a member of the project anyways.

Unfortunately there isn't a public API way to add a role to a user via the client libraries. However, there is a REST service that allows you to.

Check out https://jazz.net/wiki/bin/view/Main/DraftTeamProcessRestApi#Role_Assignments_collection.

Hope that helps.

Parker
Jazz Foundation | Process team

permanent link
sam detweiler (12.5k6195201) | answered Dec 12 '11, 9:18 a.m.
Hi, I have following issue. I would like to modify access list for given project area. I found following method: projectArea.getReadAccessList() Is that a method I should use? Could you provide me sample of the code how to add given user and add him "developer" role?
Thanks in advance.


there is no 'api'.. there are a bunch of methods on objects as this is an Object Oriented system..

if you look at the new Javadoc for 3.0.1.1, you need to connect to the repository (ITeamRepository), and u need to create, update, save users (IContributor) with some manager class (IContributorManager) and there are a bunch of classes under IContributor (identity, userid, details, handle, record) and u will probably have to use the ItemManager to read/write stuff in the Repository.

A lot of those classes are in the com.ibm.team.repository.common package, some are in the com.ibm.team.repository.client package


Sam

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.