private boolean interpreterHasUser(InterpreterSetting intp) { return intp.getOption().permissionIsSet() && intp.getOption().getUsers() != null; }
@Override protected Object jobRun() throws Throwable { String replName = getRequiredReplName(); Interpreter repl = getRepl(replName); logger.info("run paragraph {} using {} " + repl, getId(), replName); if (repl == null) { logger.error("Can not find interpreter name " + repl); throw new RuntimeException("Can not find interpreter for " + getRequiredReplName()); } InterpreterSetting intp = getInterpreterSettingById(repl.getInterpreterGroup().getId()); while (intp.getStatus() .equals( org.apache.zeppelin.interpreter.InterpreterSetting.Status.DOWNLOADING_DEPENDENCIES)) { Thread.sleep(200); } if (this.noteHasUser() && this.noteHasInterpreters()) { if (intp != null && interpreterHasUser(intp) && isUserAuthorizedToAccessInterpreter(intp.getOption()) == false) { logger.error("{} has no permission for {} ", authenticationInfo.getUser(), repl); return new InterpreterResult( Code.ERROR, authenticationInfo.getUser() + " has no permission for " + getRequiredReplName()); } } String script = getScriptBody(); // inject form if (repl.getFormType() == FormType.NATIVE) { settings.clear(); } else if (repl.getFormType() == FormType.SIMPLE) { String scriptBody = getScriptBody(); Map<String, Input> inputs = Input.extractSimpleQueryParam(scriptBody); // inputs will be built // from script body final AngularObjectRegistry angularRegistry = repl.getInterpreterGroup().getAngularObjectRegistry(); scriptBody = extractVariablesFromAngularRegistry(scriptBody, inputs, angularRegistry); settings.setForms(inputs); script = Input.getSimpleQuery(settings.getParams(), scriptBody); } logger.debug("RUN : " + script); try { InterpreterContext context = getInterpreterContext(); InterpreterContext.set(context); InterpreterResult ret = repl.interpret(script, context); if (Code.KEEP_PREVIOUS_RESULT == ret.code()) { return getReturn(); } context.out.flush(); List<InterpreterResultMessage> resultMessages = context.out.toInterpreterResultMessage(); resultMessages.addAll(ret.message()); return new InterpreterResult(ret.code(), resultMessages); } finally { InterpreterContext.remove(); } }