本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
});
}
示例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));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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()));
}