Details
-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
None
-
None
Description
Graham BallantyneGraham Ballantyne 1 hour ago
Within a GSH template (v1 for now), is it possible to determine if the template is being executed via WS or the UI? Use case is for differential output – print things to the UI as the script executes if called from the UI, vs returning JSON if called by WS.
1 reply
Chris HyzerChris Hyzer < 1 minute ago
we should add something. right now one of these workarounds might work # you only need this line if you are v2
GshTemplateRuntime gsh_builtin_gshTemplateRuntime = gshTemplateV2input.getGsh_builtin_gshTemplateRuntime();
2. If there is json input it should be there
boolean isUi = true; if (GrouperUtil.length(gsh_builtin_gshTemplateRuntime.getWsInput()) > 0) { isUi = false; }
Or you could check the grouper context
boolean isUi = true; GrouperContext grouperContext = GrouperContext.retrieveDefaultContext(); if (grouperContext != null && grouperContext.getGrouperEngine() == GrouperEngineBuiltin.WS) { isUi = false; }
but yeah we can add that to the template runtime so its just a boolean