/** * Exposed for testing - to escape from testing internals of that bloody static WorkflowUtil.getCallerKey */ @VisibleForTesting protected String getCallerKey(final Map transientVars) { return WorkflowUtil.getCallerKey(transientVars); } }
/** * Given a map of transientVars from a Workflow Function, returns the {@link ApplicationUser} object of the caller. * * @param transientVars the "transientVars" from the workflow FunctionProvider * @return the username of the caller (can be null for anonymous). * @since 6.0 */ public static ApplicationUser getCallerUser(Map transientVars) { return WorkflowFunctionUtils.getUserByKey(getCallerKey(transientVars)); }
/** * Get the Key of user executing this condition. * * @param transientVars workflow context - parameters passed to workflow engine * @param args workflow's function arguments * @return The user's Key, or null if run anonymously. */ public static String getCallerKey(Map transientVars, Map args) { //at first, try to fetch userKey from args if(args != null){ String userKey = (String) args.get("userKey"); if(TextUtils.stringSet(userKey)){ return userKey; } } //then try to pull it from context return WorkflowUtil.getCallerKey(transientVars); }