@Override public String createRule( String connectionToken, int item, ITEM_TYPE type, String ruleName, String event, String ruleType, String definition) throws DatabaseConnectionException, PostgreSQLException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); Rules rules; rules = new Rules(connMgr.getConnection(connectionToken, clientIP, userAgent)); try { return rules.createRule(item, type, ruleName, event, ruleType, definition); } catch (SQLException e) { throw new PostgreSQLException(e.getMessage()); } }
@Override public String getItemObjectList( String connectionToken, int item, ITEM_TYPE type, ITEM_OBJECT_TYPE object) throws IllegalArgumentException, DatabaseConnectionException, PostgreSQLException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); try { switch (object) { case TRIGGER: Triggers triggers = new Triggers(connMgr.getConnection(connectionToken, clientIP, userAgent)); return triggers.getList(item); case COLUMN: Columns columns = new Columns(connMgr.getConnection(connectionToken, clientIP, userAgent)); return columns.getList(item); case CONSTRAINT: Constraints constraints = new Constraints(connMgr.getConnection(connectionToken, clientIP, userAgent)); return constraints.getList(item); case GRANT: Privileges priv = new Privileges(connMgr.getConnection(connectionToken, clientIP, userAgent)); return priv.getPrivileges(item, type); case INDEX: Indexes indexes = new Indexes(connMgr.getConnection(connectionToken, clientIP, userAgent)); return indexes.getList(item); case RULE: Rules rules = new Rules(connMgr.getConnection(connectionToken, clientIP, userAgent)); return rules.getList(item); case SOURCE: SourceCode sc = new SourceCode(connMgr.getConnection(connectionToken, clientIP, userAgent)); return sc.getSourceCode(item, type); case STATS: Stats stats = new Stats(connMgr.getConnection(connectionToken, clientIP, userAgent)); return stats.getList(item); default: return ""; } } catch (SQLException e) { throw new PostgreSQLException(e.getMessage()); } }
@Override public String dropItemObject( String connectionToken, int item, ITEM_TYPE type, String objectName, ITEM_OBJECT_TYPE objType) throws DatabaseConnectionException, PostgreSQLException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); try { switch (objType) { case COLUMN: Columns columns = new Columns(connMgr.getConnection(connectionToken, clientIP, userAgent)); return columns.drop(item, q.addQuote(objectName)); case CONSTRAINT: Constraints constraints = new Constraints(connMgr.getConnection(connectionToken, clientIP, userAgent)); return constraints.drop(item, q.addQuote(objectName)); case INDEX: Indexes indexes = new Indexes(connMgr.getConnection(connectionToken, clientIP, userAgent)); return indexes.drop(item, q.addQuote(objectName)); case RULE: Rules rules = new Rules(connMgr.getConnection(connectionToken, clientIP, userAgent)); return rules.drop(item, q.addQuote(objectName)); case TRIGGER: Triggers triggers = new Triggers(connMgr.getConnection(connectionToken, clientIP, userAgent)); return triggers.drop(item, q.addQuote(objectName)); default: return ""; } } catch (SQLException e) { throw new PostgreSQLException(e.getMessage()); } }