Пример #1
0
  @GET
  @Path("deletep")
  public Map<String, String> deletePartitionStorage(
      @QueryParam("ds") String datasource, @QueryParam("table") String table) {
    checkDSAndTable(datasource, table);

    Map<String, String> result = new HashMap<>();
    boolean isSuccess = false;
    try {
      service.delPartitionStorage(datasource, table);
      isSuccess = true;
    } catch (StorageHandleErrorException e) {
      result.put("error", e.getMessage());
    }
    result.put("result", isSuccess ? "success" : "fail");

    return result;
  }
Пример #2
0
  /**
   * Why wrapper primitive value into map? or Why not just return Integer or String on these REST
   * API?
   *
   * <p>Answer: front-end use ng-resource to request these API, And $resource want them to return
   * object. $resource can't parse primitive type. (ref to:
   * https://github.com/angular/angular.js/issues/4314) By Jacob, 6.23.2015.
   */
  @GET
  @Path("size")
  public Map<String, Object> getSize(
      @QueryParam("ds") String datasource, @QueryParam("table") String table) {
    checkDatasourceNotNull(datasource);

    Map<String, Object> result = new HashMap<>();
    try {
      if (null == table) {
        result.put("size", service.queryStorageSize(datasource));
      } else {
        result.put("size", service.queryStorageSize(datasource, table));
      }
    } catch (StorageHandleErrorException e) {
      result.put("error", e.getMessage());
    }
    return result;
  }