Package co.cask.cdap.common.http

Examples of co.cask.cdap.common.http.HttpResponse


  public QueryHandle getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
    throws ExploreException, SQLException {
    String body = GSON.toJson(new ColumnsArgs(catalog, schemaPattern,
                                                                tableNamePattern, columnNamePattern));
    HttpResponse response = doPost("data/explore/jdbc/columns", body, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the columns. Reason: " + getDetails(response));
  }
View Full Code Here


    throw new ExploreException("Cannot get the columns. Reason: " + getDetails(response));
  }

  @Override
  public QueryHandle getCatalogs() throws ExploreException, SQLException {
    HttpResponse response = doPost("data/explore/jdbc/catalogs", null, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the catalogs. Reason: " + getDetails(response));
  }
View Full Code Here

  }

  @Override
  public QueryHandle getSchemas(String catalog, String schemaPattern) throws ExploreException, SQLException {
    String body = GSON.toJson(new SchemasArgs(catalog, schemaPattern));
    HttpResponse response = doPost("data/explore/jdbc/schemas", body, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the schemas. Reason: " + getDetails(response));
  }
View Full Code Here

  @Override
  public QueryHandle getFunctions(String catalog, String schemaPattern, String functionNamePattern)
    throws ExploreException, SQLException {
    String body = GSON.toJson(new FunctionsArgs(catalog, schemaPattern, functionNamePattern));
    HttpResponse response = doPost("data/explore/jdbc/functions", body, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the functions. Reason: " + getDetails(response));
  }
View Full Code Here

    throw new ExploreException("Cannot get the functions. Reason: " + getDetails(response));
  }

  @Override
  public MetaDataInfo getInfo(MetaDataInfo.InfoType infoType) throws ExploreException, SQLException {
    HttpResponse response = doGet(String.format("data/explore/jdbc/info/%s", infoType.name()));
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return parseJson(response, MetaDataInfo.class);
    }
    throw new ExploreException("Cannot get information " + infoType.name() + ". Reason: " + getDetails(response));
  }
View Full Code Here

  @Override
  public QueryHandle getTables(String catalog, String schemaPattern,
                               String tableNamePattern, List<String> tableTypes) throws ExploreException, SQLException {
    String body = GSON.toJson(new TablesArgs(catalog, schemaPattern, tableNamePattern, tableTypes));
    HttpResponse response = doPost("data/explore/jdbc/tables", body, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }
View Full Code Here

    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }

  @Override
  public List<TableNameInfo> getTables(@Nullable String database) throws ExploreException {
    HttpResponse response = doGet(String.format("data/explore/tables%s", (database != null) ? "?db=" + database : ""));
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return parseJson(response, TABLES_TYPE);
    }
    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }
View Full Code Here

  @Override
  public TableInfo getTableInfo(@Nullable String database, String table)
    throws ExploreException, TableNotFoundException {
    String tableNamePrefix = (database != null) ? database + "." : "";
    HttpResponse response = doGet(String.format("data/explore/tables/%s/info", tableNamePrefix + table));
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return parseJson(response, TableInfo.class);
    } else if (HttpResponseStatus.NOT_FOUND.getCode() == response.getResponseCode()) {
      throw new TableNotFoundException("Table " + tableNamePrefix + table + " not found.");
    }
    throw new ExploreException("Cannot get the schema of table " + tableNamePrefix + table +
                               ". Reason: " + getDetails(response));
  }
View Full Code Here

                               ". Reason: " + getDetails(response));
  }

  @Override
  public QueryHandle getTableTypes() throws ExploreException, SQLException {
    HttpResponse response = doPost("data/explore/jdbc/tableTypes", null, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }
View Full Code Here

    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }

  @Override
  public QueryHandle getTypeInfo() throws ExploreException, SQLException {
    HttpResponse response = doPost("data/explore/jdbc/types", null, null);
    if (HttpResponseStatus.OK.getCode() == response.getResponseCode()) {
      return QueryHandle.fromId(parseResponseAsMap(response, "handle"));
    }
    throw new ExploreException("Cannot get the tables. Reason: " + getDetails(response));
  }
View Full Code Here

TOP

Related Classes of co.cask.cdap.common.http.HttpResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.