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

How Do I Use the getPermittedActions Function?

I am creating a server-side follow-up action that modifies a work item after a user has hit save while making a specific change. My follow-up action modifies the description attribute (which is not the same attribute that the user touched). I want to handle the case where the user had permissions to modify the custom attribute that I care about, but they do not have permissions to modify the description field. In this case, if I don't catch that scenario, my follow-up action will fail and will prevent the user from being able to save the work item. I would prefer for my follow-up action to fail silently and allow the user to commit their save.

In researching this, I found a function that seems promising, the IServerProcess#getPermittedActions function. The description for the function reads:

boolean [] com.ibm.team.process.service.IServerProcess.getPermittedActions(String projectOperationId, String [] actions) throws TeamRepositoryException

Queries whether the current user has permissions to perform each of the given actions for the given project operation. Each entry in the returned array specifies whether the user has permissions for the corresponding action in the given array.

Parameters:
     projectOperationId the identifier of the project operation
     actions the collection of actions to consider

Returns:
     an array of booleans which specifies whether each of the given actions are permitted

Throws:
     TeamRepositoryException

Here is how I've tried to use it so far:

IProcessServerService pss = getService(IProcessServerService.class);
IServerProcess sp = pss.getServerProcess(operation.getProcessArea());
String [] actionList = {"modify/description", "description"};
boolean [] resultPermissions = sp.getPermittedActions("com.ibm.team.workitem.operation.workItemSave", actionList);

I'm not sure if I'm populating my "actionList" with the correct values. The values shown above were to try and catch either possibility. Evidently the function doesn't have issues if you pass it an action that doesn't exist. For the case above, I changed the permissions in my test project area so that I could not modify the description field, then I ran the follow-up action. The resultPermissions array contained "false, false" for both actions. I then changed the permissions to re-enable the ability to modify the description and triggered the follow-up action again. The result was still "false, false". This suggests to me that I have not picked either the correct actions or the correct projectOperationId.

Has anyone used this function before? Can you describe how to use it correctly?

0 votes



One answer

Permanent link
I don't know how to use this, and will have to read the code that implements the getPermittedActions to figure it out.

you can see the defined operations and actions by looking at the plugin.xml for com.ibm.team.workitem.service in the sdk.

the start of the list is
    <operation
            id="com.ibm.team.workitem.operation.workItemSave"
            name="%SaveWorkItem.operation.name"
            categoryId="com.ibm.team.workitem.category"
            allowsPermissionSpecification="true"
            allowsBehaviorSpecification="true">
            <action id="modify" label="%ModifyWorkItem.action.name">
                <action
                      id="projectArea"
                      label="%ModifyWorkItemProjectArea.action.name">
                       <description>
                      %ModifyWorkItemProjectArea.action.description
                       </description>
                </action>

Looks like you are close, operation_id, followed by array of strings of action_ids
the action id for description is
                <action
                      id="description"
                      label="%ModifyWorkItemDescription.action.name">
                   <description>
                      %ModifyWorkItemDescription.action.description
                   </description>
                </action>

0 votes

Comments

I also found a page that lists all of the operations and their ids:

https://jazz.net/wiki/bin/view/Main/CustomPreconditionsTable#operations

It looks like "modify/description" should be valid and so should my "com.ibm.team.workitem.operation.workItemSave". So I'm not sure why it doesn't work.

I don't think its "modify/..."   cause that is not one of the id= fields for the actions
only 'description'..

I think the 'modify' is obvious as this is a save operation. so that is the only action you could do.. you cannot delete the attribute

the code for this runs thru all the roles for this user in this project area and then checks the actions.

r u sure that the user has permissions on one of the assigned role(s)

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,936
× 411

Question asked: Jul 17 '14, 8:48 a.m.

Question was seen: 4,762 times

Last updated: Jul 17 '14, 10:24 a.m.

Confirmation Cancel Confirm