I want to create a workflow validator which will not allow the reporter of the issue to execute certain steps from the workflow. For that purpose somehow I have to get the User object or the user id of the user executing the action. How can I do that?
Asked
Active
Viewed 586 times
2 Answers
1
inject the JiraAuthenticationContext
And then call jiraAuthenticationContext.getLoggedInUser();
you can find the documentation about the JiraAuthenticationContext here: https://docs.atlassian.com/jira/5.0.1/com/atlassian/jira/security/JiraAuthenticationContext.html

Lama
- 2,886
- 6
- 43
- 59
-
I'm accepting your answer, although I'll left it as is now with my solution :) – Svetlin Zarev Nov 10 '15 at 13:54
-
Thanks! :) I recommend you stick with the atlassian API way, so there won't be any problems - e.g. in case of a minor upgrade of your jira instance. – Lama Nov 10 '15 at 13:55
0
Here is how I've managed to do it:
private String getCurrentIssueProcessorId(Map<?, ?> transientVars, Map<?, ?> args){
String processorId = (String) args.get(ARG_USER_NAME);
if(null == processorId || processorId.isEmpty()){
WorkflowContext workflowContext = (WorkflowContext) transientVars.get(ARG_CONTEXT);
processorId = workflowContext.getCaller();
}
if(logger.isDebugEnabled()){
logger.debug("Issue processor: " + processorId);
}
return processorId;
}
where ARG_CONTEXT
is the string context
and ARG_USER_NAME
is the string username

Svetlin Zarev
- 14,713
- 4
- 53
- 82
-
Can't you just inject the `JiraAuthenticationContext` And then call jiraAuthenticationContext.getUser(); ? – Lama Nov 10 '15 at 13:21
-
-
-
-
Developing with jira 5.0 API :) My eclipse marks this method as deprecated. – Svetlin Zarev Nov 10 '15 at 13:50
-
https://docs.atlassian.com/jira/5.0.1/com/atlassian/jira/security/JiraAuthenticationContext.html you need to call getLoggedInUser() now but it should also be fine to call getUser() with Jira 5.0 – Lama Nov 10 '15 at 13:50