Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to modify access list for Project area?

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.

0 votes



9 answers

Permanent link
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

1 vote


Permanent link
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

1 vote


Permanent link
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?

1 vote


Permanent link
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

1 vote


Permanent link
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

1 vote


Permanent link
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?

0 votes


Permanent link
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?

0 votes


Permanent link
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?

0 votes


Permanent link
Hello,
It works! Thanks :)

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948

Question asked: Dec 12 '11, 5:07 a.m.

Question was seen: 7,943 times

Last updated: Dec 12 '11, 5:07 a.m.

Confirmation Cancel Confirm