112 lines
3.5 KiB
Java
112 lines
3.5 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.tridium.util.ThrowableUtil
|
|
* javax.baja.security.PermissionException
|
|
* javax.baja.sys.Action
|
|
* javax.baja.sys.BComponent
|
|
* javax.baja.sys.BIService
|
|
* javax.baja.sys.BIcon
|
|
* javax.baja.sys.BValue
|
|
* javax.baja.sys.Context
|
|
* javax.baja.sys.Sys
|
|
* javax.baja.sys.Type
|
|
*/
|
|
package com.tridium.program;
|
|
|
|
import com.tridium.program.BRobotCode;
|
|
import com.tridium.program.BRobotResult;
|
|
import com.tridium.program.BatchRobot;
|
|
import com.tridium.program.Robot;
|
|
import com.tridium.util.ThrowableUtil;
|
|
import javax.baja.security.PermissionException;
|
|
import javax.baja.sys.Action;
|
|
import javax.baja.sys.BComponent;
|
|
import javax.baja.sys.BIService;
|
|
import javax.baja.sys.BIcon;
|
|
import javax.baja.sys.BValue;
|
|
import javax.baja.sys.Context;
|
|
import javax.baja.sys.Sys;
|
|
import javax.baja.sys.Type;
|
|
|
|
/*
|
|
* Illegal identifiers - consider using --renameillegalidents true
|
|
*/
|
|
public class BProgramService
|
|
extends BComponent
|
|
implements BIService {
|
|
public static final Action runRobot = BProgramService.newAction((int)0, (BValue)new BRobotCode(), null);
|
|
public static final Type TYPE;
|
|
private static final BIcon icon;
|
|
public static final boolean REQUIRE_SUPER_USER_PERMISSION;
|
|
static /* synthetic */ Class class$com$tridium$program$BProgramService;
|
|
|
|
public BRobotResult runRobot(BRobotCode bRobotCode) {
|
|
return (BRobotResult)this.invoke(runRobot, (BValue)bRobotCode, null);
|
|
}
|
|
|
|
public Type getType() {
|
|
return TYPE;
|
|
}
|
|
|
|
public Type[] getServiceTypes() {
|
|
return new Type[]{TYPE};
|
|
}
|
|
|
|
public void serviceStarted() {
|
|
}
|
|
|
|
public void serviceStopped() {
|
|
}
|
|
|
|
public BRobotResult doRunRobot(BRobotCode bRobotCode, Context context) throws Exception {
|
|
try {
|
|
Robot robot = (Robot)bRobotCode.newInstance();
|
|
if (REQUIRE_SUPER_USER_PERMISSION && context != null && context.getUser() != null && !(robot instanceof BatchRobot) && !context.getUser().getPermissions().isSuperUser()) {
|
|
throw new PermissionException("Run Robot not allowed by this user.");
|
|
}
|
|
try {
|
|
robot.context = context;
|
|
robot.run();
|
|
}
|
|
catch (Exception exception) {
|
|
exception.printStackTrace(robot.log);
|
|
}
|
|
return robot.toResult();
|
|
}
|
|
catch (Throwable throwable) {
|
|
String string = "Failed: runRobot\n" + ThrowableUtil.dumpToString((Throwable)throwable);
|
|
return new BRobotResult(string);
|
|
}
|
|
}
|
|
|
|
public BIcon getIcon() {
|
|
return icon;
|
|
}
|
|
|
|
static /* synthetic */ Class class(String string, boolean bl) {
|
|
try {
|
|
Class<?> clazz = Class.forName(string);
|
|
if (!bl) {
|
|
clazz = clazz.getComponentType();
|
|
}
|
|
return clazz;
|
|
}
|
|
catch (ClassNotFoundException classNotFoundException) {
|
|
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
|
}
|
|
}
|
|
|
|
static {
|
|
Class clazz = class$com$tridium$program$BProgramService;
|
|
if (clazz == null) {
|
|
clazz = class$com$tridium$program$BProgramService = BProgramService.class("[Lcom.tridium.program.BProgramService;", false);
|
|
}
|
|
TYPE = Sys.loadType((Class)clazz);
|
|
icon = BIcon.std((String)"script.png");
|
|
REQUIRE_SUPER_USER_PERMISSION = Boolean.valueOf(System.getProperty("niagara.program.requireSuperUser", "true"));
|
|
}
|
|
}
|
|
|