01: package fr.aliacom.dbmjui;
02:
03: import java.util.Properties;
04:
05: import org.apache.log4j.Logger;
06:
07: import com.sap.dbtech.powertoys.DBM;
08: import com.sap.dbtech.powertoys.DBMException;
09: import com.sap.dbtech.rte.comm.RTEException;
10:
11: /**
12: * This subclass of DBM connection forward errors
13: * to the log table in the UI.
14: *
15: * Instances of this class forbid execution of commands that close
16: * the connection : bye, release, quit, exit.
17: *
18: * @author tom
19: *
20: * (C) 2001, 2002 Thomas Cataldo
21: */
22: public class JuiDbmConnection extends DBM {
23:
24: private String dbName;
25: private static final Logger log = Logger
26: .getLogger(JuiDbmConnection.class);
27:
28: /**
29: * Constructor for JuiDbmConnection.
30: * @param arg0
31: * @throws RTEException
32: */
33: public JuiDbmConnection(Properties arg0) throws RTEException {
34: super (arg0);
35: this .dbName = arg0.getProperty("dbname");
36: }
37:
38: /**
39: * @see com.sap.dbtech.powertoys.DBM#cmd(String)
40: */
41: public String cmd(String command) throws DBMException, RTEException {
42: String ret;
43: try {
44: if (!isForbidden(command)) {
45: ret = super .cmd(command);
46: } else {
47: throw new RTEException("Command forbidden in dbmjui ");
48: }
49: } catch (DBMException dbme) {
50: log.fatal("Failed command", dbme);
51: UILogger.log(dbName, dbme);
52: throw dbme;
53: } catch (RTEException rtee) {
54: log.fatal("Failed command", rtee);
55: UILogger.log(dbName, rtee);
56: throw rtee;
57: }
58: return ret;
59: }
60:
61: private boolean isForbidden(String cmd) {
62: return cmd.equals("bye") || cmd.equals("release")
63: || cmd.equals("quit") || cmd.equals("exit");
64: }
65:
66: }
|