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


Java BodyParser类代码示例

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


BodyParser类属于play.mvc包,在下文中一共展示了BodyParser类的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 {

    LineageDaoLite.insertLineage(lineage);

    resultJson.put("return_code", 200);
    resultJson.put("message", "Lineage inserted!");
    Logger.info("lineage inserted");
  } catch (Exception e) {
    
    ContrUtil.failure(resultJson, e.getMessage());

    Logger.error("caught exception", e);
    Logger.info("Post JSON for insertion failure: " + lineage.toString());
  }
  return ok(resultJson);
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:22,代码来源:LineageController.java

示例2: addDataset

import play.mvc.BodyParser; //导入依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
public static Result addDataset() {
  JsonNode dataset = request().body().asJson();
  ObjectNode resultJson = Json.newObject();
  try {
    DatasetDao.setDatasetRecord(dataset);
    resultJson.put("return_code", 200);
    resultJson.put("message", "Dataset 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,代码来源:DatasetController.java

示例3: 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

示例4: 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

示例5: updateQuestion

import play.mvc.BodyParser; //导入依赖的package包/类
@BodyParser.Of(BodyParser.Json.class)
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result updateQuestion(Long id) {
    User user = getLoggedUser();
    ExpressionList<Question> query = Ebean.find(Question.class).where().idEq(id);
    if (user.hasRole("TEACHER", getSession())) {
        query = query.disjunction()
                .eq("shared", true)
                .eq("questionOwners", user)
                .eq("examSectionQuestions.examSection.exam.examOwners", user)
                .endJunction();
    }
    Question question = query.findUnique();
    if (question == null) {
        return forbidden("sitnet_error_access_forbidden");
    }
    JsonNode body = request().body().asJson();
    Question updatedQuestion = parseFromBody(body, user, question);
    return question.getValidationResult(body).orElseGet(() -> {
        if (updatedQuestion.getType() != Question.Type.EssayQuestion) {
            processOptions(updatedQuestion, (ArrayNode) body.get("options"));
        }
        updatedQuestion.update();
        return ok(Json.toJson(updatedQuestion));
    });
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:27,代码来源:QuestionController.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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