当前位置: 首页>>代码示例>>Java>>正文


Java BodyParser.Json方法代码示例

本文整理汇总了Java中play.mvc.BodyParser.Json方法的典型用法代码示例。如果您正苦于以下问题:Java BodyParser.Json方法的具体用法?Java BodyParser.Json怎么用?Java BodyParser.Json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在play.mvc.BodyParser的用法示例。


在下文中一共展示了BodyParser.Json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJobLineage

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public static Result addJobLineage() {
  JsonNode lineage = request().body().asJson();
  ObjectNode resultJson = Json.newObject();
  try {
    LineageDao.insertLineage(lineage);
    resultJson.put("return_code", 200);
    resultJson.put("message", "Lineage inserted!");
  } catch (Exception e) {
    e.printStackTrace();
    resultJson.put("return_code", 404);
    resultJson.put("error_message", e.getMessage());
  }

  return ok(resultJson);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:17,代码来源:LineageController.java

示例2: getDatasetDependency

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public static Result getDatasetDependency() {
  String queryString = request().getQueryString("query");
  JsonNode input = Json.parse(queryString);
  ObjectNode resultJson = Json.newObject();

  try {
    resultJson = DatasetDao.getDatasetDependency(input);
  } catch (Exception e) {
    Logger.error(e.getMessage());
    resultJson.put("return_code", 404);
    resultJson.put("error_message", e.getMessage());
  }

  return ok(resultJson);
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:17,代码来源:DatasetController.java

示例3: save

import play.mvc.BodyParser; //导入方法依赖的package包/类
@Transactional
  @BodyParser.Of(BodyParser.Json.class)
  public Result save() {
  	
  	Cidadao cidadao = daoCidadao
		.find(UUID.fromString(request().username()));
if (!cidadao.isFuncionario()) {
	return unauthorized("Cidadão não autorizado");
}
  	
      Form<Mensagem> form = formFactory.form(Mensagem.class).bindFromRequest();
      if (form.hasErrors()) {
          String recebido = Controller.request().body().asJson().toString();
          if (recebido.length() > 30) {
              recebido = recebido.substring(0, 30) + "...";
          }
          Logger.debug("Submissão com erros: " + recebido + "; Erros: " + form.errorsAsJson());
          return badRequest(form.errorsAsJson());
      }
      
      Mensagem mensagem = daoMensagem.create(form.get());
      mensagem.setAutor(cidadao.getMinisterioDeAfiliacao());
      
      return created(toJson(mensagem));
  }
 
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:26,代码来源:MensagemController.java

示例4: addStructure

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addStructure() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      Structure structure = Json.fromJson(json, Structure.class);

      try {
        structure = this.postgresStructureDao.create(structure);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(structure);
    },

    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:20,代码来源:StructureController.java

示例5: addStructureVersion

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addStructureVersion() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();

      List<Long> parentIds = GroundUtils.getListFromJson(json, "parentIds");
      ((ObjectNode) json).remove("parentIds");

      StructureVersion structureVersion = Json.fromJson(json, StructureVersion.class);

      try {
        structureVersion = this.postgresStructureVersionDao.create(structureVersion, parentIds);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(structureVersion);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:23,代码来源:StructureController.java

示例6: createLineageEdge

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> createLineageEdge() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      LineageEdge lineageEdge = Json.fromJson(json, LineageEdge.class);
      try {
        lineageEdge = this.postgresLineageEdgeDao.create(lineageEdge);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(lineageEdge);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:18,代码来源:LineageEdgeController.java

示例7: createLineageGraph

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> createLineageGraph() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      LineageGraph lineageGraph = Json.fromJson(json, LineageGraph.class);
      try {
        lineageGraph = this.postgresLineageGraphDao.create(lineageGraph);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(lineageGraph);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:18,代码来源:LineageGraphController.java

示例8: addGraph

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addGraph() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      Graph graph = Json.fromJson(json, Graph.class);

      try {
        graph = this.postgresGraphDao.create(graph);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }

      return Json.toJson(graph);
    },
    PostgresUtils.getDbSourceHttpContext(actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:20,代码来源:GraphController.java

示例9: addGraphVersion

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addGraphVersion() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      List<Long> parentIds = GroundUtils.getListFromJson(json, "parentIds");
      ((ObjectNode) json).remove("parentIds");
      GraphVersion graphVersion = Json.fromJson(json, GraphVersion.class);

      try {
        graphVersion = this.postgresGraphVersionDao.create(graphVersion, parentIds);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(graphVersion);
    },
    PostgresUtils.getDbSourceHttpContext(actorSystem))
           .thenApply(Results::ok)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:21,代码来源:GraphController.java

示例10: addEdge

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addEdge() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      Edge edge = Json.fromJson(json, Edge.class);

      try {
        edge = this.postgresEdgeDao.create(edge);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }

      return Json.toJson(edge);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:20,代码来源:EdgeController.java

示例11: addEdgeVersion

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addEdgeVersion() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      List<Long> parentIds = GroundUtils.getListFromJson(json, "parentIds");

      ((ObjectNode) json).remove("parentIds");
      EdgeVersion edgeVersion = Json.fromJson(json, EdgeVersion.class);

      try {
        edgeVersion = this.postgresEdgeVersionDao.create(edgeVersion, parentIds);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }

      return Json.toJson(edgeVersion);
    },
    PostgresUtils.getDbSourceHttpContext(actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:23,代码来源:EdgeController.java

示例12: addNode

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addNode() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();
      Node node = Json.fromJson(json, Node.class);
      try {
        node = this.postgresNodeDao.create(node);
      } catch (GroundException e) {
        throw new CompletionException(e);
      }
      return Json.toJson(node);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:18,代码来源:NodeController.java

示例13: addNodeVersion

import play.mvc.BodyParser; //导入方法依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public final CompletionStage<Result> addNodeVersion() {
  return CompletableFuture.supplyAsync(
    () -> {
      JsonNode json = request().body().asJson();

      List<Long> parentIds = GroundUtils.getListFromJson(json, "parentIds");
      ((ObjectNode) json).remove("parentIds");
      NodeVersion nodeVersion = Json.fromJson(json, NodeVersion.class);

      try {
        nodeVersion = this.postgresNodeVersionDao.create(nodeVersion, parentIds);
      } catch (GroundException e) {
        e.printStackTrace();
        throw new CompletionException(e);
      }
      return Json.toJson(nodeVersion);
    },
    PostgresUtils.getDbSourceHttpContext(this.actorSystem))
           .thenApply(Results::created)
           .exceptionally(e -> GroundUtils.handleException(e, request()));
}
 
开发者ID:ground-context,项目名称:ground,代码行数:23,代码来源:NodeController.java

示例14: updateDashboardPage

import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
 * Update the dashboard page configuration.<br/>
 * This method expects a POST with a JSON structure.
 * 
 * @param dashboardPageId
 *            the unique id of a dashboard page
 * @return
 */
@BodyParser.Of(BodyParser.Json.class)
public Promise<Result> updateDashboardPage(Long dashboardPageId) {
    return Promise.promise(new Function0<Result>() {
        @Override
        public Result apply() throws Throwable {
            try {
                JsonNode json = request().body().asJson();
                List<DashboardRowConfiguration> dashboardPageConfiguration = getObjectMapper().readValue(json.toString(),
                        new TypeReference<List<DashboardRowConfiguration>>() {
                });
                getDashboardService().updateDashboardPageConfiguration(dashboardPageId, null, dashboardPageConfiguration);
                return ok();
            } catch (Exception e) {
                log.error("Unable to update the dashboard page", e);
                return badRequest();
            }
        }
    });
}
 
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:28,代码来源:DashboardController.java

示例15: createNewWidget

import play.mvc.BodyParser; //导入方法依赖的package包/类
/**
 * Create a new widget from the specified widget identifier and return the
 * widget id as a JSON structure.
 * 
 * <pre>
 * {@code
 *  {widgetId : 1}
 * }
 * </pre>
 * 
 * A POST parameter (as JSON is expected) : a widget entry.
 * 
 * @param dashboardPageId
 *            the unique Id for the dashboard page which is to be associated
 *            with this widget
 * @return JSON structure
 */
@BodyParser.Of(BodyParser.Json.class)
public Promise<Result> createNewWidget(Long dashboardPageId) {
    return Promise.promise(new Function0<Result>() {
        @Override
        public Result apply() throws Throwable {
            try {
                JsonNode json = request().body().asJson();
                WidgetCatalogEntry widgetCatalogEntry = getObjectMapper().readValue(json.toString(), WidgetCatalogEntry.class);
                Pair<Long, String> widgetConfig = getDashboardService().createNewWidget(dashboardPageId, null, widgetCatalogEntry, "A title");
                JsonNode node = getObjectMapper().readTree("{\"id\" : " + widgetConfig.getLeft() + ",\"url\" : \"" + widgetConfig.getRight()
                        + "\",\"identifier\" : \"" + widgetCatalogEntry.getIdentifier() + "\"}");
                return ok(node);
            } catch (Exception e) {
                log.error("Unable to create a new widget", e);
                return badRequest();
            }
        }
    });
}
 
开发者ID:theAgileFactory,项目名称:maf-desktop-app,代码行数:37,代码来源:DashboardController.java


注:本文中的play.mvc.BodyParser.Json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。