我想创建一个工作流验证程序,它不允许问题的报告者从工作流程执行某些步骤。出于这个目的,我必须得到User对象或执行该操作的用户的用户ID。我怎么能这样做?
答案 0 :(得分:1)
注入JiraAuthenticationContext
,然后拨打jiraAuthenticationContext.getLoggedInUser();
您可以在此处找到有关JiraAuthenticationContext的文档: https://docs.atlassian.com/jira/5.0.1/com/atlassian/jira/security/JiraAuthenticationContext.html
答案 1 :(得分:0)
以下是我设法做到的方法:
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;
}
其中ARG_CONTEXT
是字符串context
,ARG_USER_NAME
是字符串username