How to check for permission before save function call on server side
i have a plugin which will save the workitem and which will also change the state of workitem. but i have a role which is not allowed to save the workitem in particular state so when my function gets called i have a parameter actionId which is passed to save function which throws error because user dont have permission to save in that state. so i want a code which will check if role assigned to user has permission to save in that state or not. below is my code
IStatus saveWorkItem3 = workItemServer.saveWorkItem3(currentWorkItemObj,
workItemServer.resolveWorkItemReferences(currentWorkItemObj, monitor), targetStateActionId,
additionalSaveParameters);
if(!saveWorkItem3.isOK()){
String message = saveWorkItem3.getMessage();
}
before this function call i need to check
before this function call i need to check
One answer
My 2 cent.
You try to develop a follow up action (participant) that saves the work item. The work item save in the participant can fail.
A participant can only succeed or fail. If it fails, it provides a reason. A fail can prevent the operation. I do not recall, if there is a warning mode.
A participant can only succeed or fail. If it fails, it provides a reason. A fail can prevent the operation. I do not recall, if there is a warning mode.
So you can fail and someone else have to change the state, or you ignore the problem.
Another option might be to try to elevate the advisor into running in an administrative context. I do not know if that would help though, as the administration role does not grant permissions.
Another option might be to try to elevate the advisor into running in an administrative context. I do not know if that would help though, as the administration role does not grant permissions.