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

In the Java Server API, How Can I Trap a Permissions Error from a Work Item Save Operation?

I have a follow-up action that saves the work item. Sometimes this action will generate a permissions error. In those cases, I want the operation behavior to abort gracefully without interfering with the save operation. If the permissions error had been an exception, I could have caught it in a try-catch block. However, since a permissions error is something else, I'm not sure how to trap for that scenario and allow a graceful exit of the operation behavior.

0 votes

Comments

Have you tried to catch Throwable? This is the super super class for exceptions as far as I know. You should be able to find out what is thrown, if anything. Otherwise do you check the status of the work item save?

        IStatus saveStatus = fWorkItemServer.saveWorkItem3(parentworkingcopy, null, null,
                additionalParams);
        if (!saveStatus.isOK()) {
            return false;
        }

I am not currently checking the status of the work item save. I'll give that a try. Thanks.

Edit: Unfortunately, neither of those suggestions has panned out. Got any other ideas?

Edit 2: Actually, I just realized that the permissions error is happening long before my saveWorkItem3 operation (it occurs when tracing links). I need to put the try/catch block earlier in the code. I'll try that and come back here.

Edit 3: Looks like the catch Throwable does the trick. Stack exchange seems to argue that it's bad practice to do that though so I guess I need to do some testing to figure out exactly which exception is being thrown for the permissions error. I'll mark your answer as the accepted solution.


Accepted answer

Permanent link

I should follow up on this post and provide some more details since I have the solution now. Ralph's answer set me on the correct path, but I just noticed this post in my search results and saw that the answer count was "0" which implied it was still unanswered.

Rather than catching a generic throwable exception, I ultimately found that I needed to catch "PermissionDeniedException". Catching this exception allowed me to continue the operation behavior without failing the save operation.

Ralph Schoon selected this answer as the correct answer

1 vote

Comments

Thanks for the update Nate!

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

Question asked: Aug 04 '15, 8:30 a.m.

Question was seen: 3,387 times

Last updated: Oct 09 '15, 9:18 a.m.

Confirmation Cancel Confirm