It's all about the answers!

Ask a question

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


masoom Abdullah (5315) | asked Mar 22 '18, 2:37 a.m.

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.




One answer



permanent link
Ralph Schoon (62.0k33643) | answered Mar 22 '18, 11:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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();

Your answer


Register or to post your answer.