package com.c2kernel.process.module; import com.c2kernel.entity.proxy.AgentProxy; import com.c2kernel.process.Gateway; import com.c2kernel.scripting.Script; import com.c2kernel.scripting.ScriptingEngineException; public class ModuleScript { public String target; public String event; public String lang; public String script; public ModuleScript() { } public ModuleScript(String target, String event, String lang, String script) { super(); this.target = target; this.event = event; this.lang = lang; this.script = script; } public Script getScript(String ns) throws ScriptingEngineException { AgentProxy user = Gateway.getCurrentUser(); try { if (user == null) user = (AgentProxy)Gateway.getProxyManager().getProxy( Gateway.getLDAPLookup().getRoleManager().getAgentPath("system")); } catch (Exception ex) { throw new ScriptingEngineException("System agent unavailable"); } return new Script(lang, ns+" "+target+" "+event, script, user); } public boolean shouldRun(String event, boolean isServer) { return ((this.target == null || this.target.length() == 0 || isServer == target.equals("server")) && (this.event == null || this.event.length() == 0 || event.equals(this.event))); } }