Ejemplo n.º 1
0
  @Override
  public String createForeignKeyConstraint(
      String connectionToken,
      int item,
      String constraintName,
      ArrayList<String> columnList,
      String referenceTable,
      ArrayList<String> referenceList)
      throws DatabaseConnectionException, PostgreSQLException {
    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

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

    Constraints constraints;

    constraints = new Constraints(connMgr.getConnection(connectionToken, clientIP, userAgent));

    try {
      return constraints.createForeignKeyConstraint(
          item, constraintName, columnList, referenceTable, referenceList);
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }
Ejemplo n.º 2
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());
    }
  }
Ejemplo n.º 3
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());
    }
  }
Ejemplo n.º 4
0
  @Override
  public String createCheckConstraint(
      String connectionToken, int item, String constraintName, String definition)
      throws DatabaseConnectionException, PostgreSQLException {
    ConnectionManager connMgr = new ConnectionManager();
    HttpServletRequest request = this.getThreadLocalRequest();

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

    Constraints constraints;

    constraints = new Constraints(connMgr.getConnection(connectionToken, clientIP, userAgent));

    try {
      return constraints.createCheckConstraint(item, constraintName, definition);
    } catch (SQLException e) {
      throw new PostgreSQLException(e.getMessage());
    }
  }