Commit 6ad2aa0b authored by michael.simon's avatar michael.simon
Browse files

first script call successful

parent d2ba14ed
......@@ -4,6 +4,7 @@ import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.dao.GroupDao;
import edu.kit.scc.webreg.dao.RegistryDao;
......@@ -11,6 +12,7 @@ import edu.kit.scc.webreg.dao.ScriptDao;
import edu.kit.scc.webreg.dao.ServiceDao;
import edu.kit.scc.webreg.dao.UserDao;
@Named
@ApplicationScoped
public class ScriptingEnv implements Serializable {
......
......@@ -93,14 +93,24 @@ public class ScriptedLdapRegisterWorkflow
ScriptEntity scriptEntity = scriptingEnv.getScriptDao().findByName(scriptName);
if (scriptEntity == null)
throw new RegisterException("service not configured properly. script is missing.");
if (scriptEntity.getScriptType().equalsIgnoreCase("javascript")) {
ScriptEngine engine = (new ScriptEngineManager()).getEngineByName(scriptEntity.getScriptEngine());
if (engine == null)
throw new RegisterException("service not configured properly. engine not found: " + scriptEntity.getScriptEngine());
engine.eval(scriptEntity.getScript());
Invocable invocable = (Invocable) engine;
Object result = invocable.invokeFunction("updateRegistry", scriptingEnv, reconMap, user, registry, service, auditor);
}
Object result = invocable.invokeFunction("updateRegistry", scriptingEnv, reconMap, user, registry, service, auditor, logger);
}
else {
throw new RegisterException("unkown script type: " + scriptEntity.getScriptType());
}
} catch (PropertyReaderException e) {
throw new RegisterException(e);
} catch (ScriptException e) {
......@@ -339,7 +349,7 @@ public class ScriptedLdapRegisterWorkflow
}
@Override
public void setScriptingEnv(ScriptingEnv env) {
public void setScriptingEnv(ScriptingEnv scriptingEnv) {
this.scriptingEnv = scriptingEnv;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment