@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 grant( String connectionToken, int item, ITEM_TYPE type, ArrayList<String> privileges, String grantee) throws DatabaseConnectionException, PostgreSQLException { ConnectionManager connMgr = new ConnectionManager(); HttpServletRequest request = this.getThreadLocalRequest(); String clientIP = ConnectionInfo.remoteAddr(request); String userAgent = request.getHeader("User-Agent"); Privileges priv = new Privileges(connMgr.getConnection(connectionToken, clientIP, userAgent)); try { return priv.grant(item, type, privileges, grantee); } catch (SQLException e) { throw new PostgreSQLException(e.getMessage()); } }