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

ALM_How to update the access list using java or OSLC api.

Hi all,


The Access Control for my project area is selected as "Users in the access list only".

I am able to get the list of users already present in the access list by using RTC Api code snippet as below.

IReadAccessListHandle accessListHandle=area.getReadAccessList();
IReadAccessList iReadAccessList = (IReadAccessList) itemManager.fetchCompleteItem(accessListHandle, itemManager.DEFAULT,new NullProgressMonitor());
IContributorHandle[] memberHandles=iReadAccessList.getContributors();

But i am unable to find any method to update this list.




0 votes



One answer

Permanent link

This is easy enough to find for the Java API, provided you follow the hint in https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ to setup the RTC Eclipse client with the SDK.

That allows to search e.g. for the stuff you use un your question and in 2 minute you can find the JUnit test cases with the working code. Foe example you find com.ibm.team.process.internal.client.tests.ProcessWorkingCopyTests.testAddToAndRemoveFromProjectAreaAccessList()


with this code:

    public void testAddToAndRemoveFromProjectAreaAccessList() throws TeamRepositoryException {
        // This will be the list that we expect at the end: user1, guest1, and guest2
        List expectedUsers = new ArrayList();
        // First, set up the project area by manually adding members to the access list.
        IContributor user1 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_USER1, null);
        expectedUsers.add(user1);
        IContributor user2 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_USER2, null);
        IReadAccessListHandle accessHandle = fProjectArea.getReadAccessList();
        IReadAccessList accessList = (IReadAccessList) repo.itemManager().fetchCompleteItem(accessHandle, IItemManager.REFRESH, null).getWorkingCopy();
        accessList.addContributors(new IContributorHandle[] { user1, user2 });
        getProcessItemService().save(accessList, null);

    IContributor guest1 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_GUEST1, null);
    expectedUsers.add(guest1);
    IContributor guest2 = repo.contributorManager().fetchContributorByUserId(TestUserNames.TEST_JAZZ_GUEST2, null);
    expectedUsers.add(guest2);

    // Make the working copy changes
    IProjectArea projectArea = getProjectAreaWithSettings();
    fWorkingCopy = (IProcessAreaWorkingCopy) getProcessItemService().getWorkingCopyManager().createPrivateWorkingCopy(projectArea);
    syncInitializeWorkingCopy(fWorkingCopy, null);
    ProjectAreaAccessControlWorkingCopy accessControl = ((ProjectAreaWorkingCopy) fWorkingCopy).getAccessControl();
    accessControl.addContributor(guest1);
    accessControl.addContributor(guest2);
    accessControl.removeContributor(user2);
    fWorkingCopy.save(null);
    fWorkingCopy.dispose();

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
× 1,220

Question asked: Mar 22 '18, 2:37 a.m.

Question was seen: 2,086 times

Last updated: Mar 22 '18, 11:18 a.m.

Confirmation Cancel Confirm