コード例 #1
0
  @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());
    }
  }
コード例 #2
0
  @Override
  public String renameItemObject(
      String connectionToken,
      int item,
      ITEM_TYPE type,
      String objectName,
      ITEM_OBJECT_TYPE objType,
      String newObjectName)
      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.rename(item, q.addQuote(objectName), q.addQuote(newObjectName));
        case CONSTRAINT:
          Constraints constraints =
              new Constraints(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return constraints.rename(item, q.addQuote(objectName), q.addQuote(newObjectName));
        case INDEX:
          Indexes indexes =
              new Indexes(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return indexes.rename(item, q.addQuote(objectName), q.addQuote(newObjectName));
        case RULE:
          // A RULE can not be renamed so just return a blank string if if get
          // here for some reason
          return "";
        case TRIGGER:
          Triggers triggers =
              new Triggers(connMgr.getConnection(connectionToken, clientIP, userAgent));
          return triggers.rename(item, q.addQuote(objectName), q.addQuote(newObjectName));

        default:
          return "";
      }
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }
コード例 #3
0
  @Override
  public String createIndex(
      String connectionToken,
      int item,
      String indexName,
      INDEX_TYPE indexType,
      boolean isUnique,
      boolean isConcurrently,
      ArrayList<String> columnList)
      throws DatabaseConnectionException, PostgreSQLException {
    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

    String clientIP = ConnectionInfo.remoteAddr(request);
    String userAgent = request.getHeader("User-Agent");

    Indexes indexes = new Indexes(connMgr.getConnection(connectionToken, clientIP, userAgent));

    try {
      return indexes.create(item, indexName, indexType, isUnique, isConcurrently, columnList);
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }