blob: beed6f964908d09d38e43c42a47d1309376e71c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
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)));
}
}
|