Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode.findPath()


  public static Result createRole(String name){
    String inheritedRole=DefaultRoles.REGISTERED_USER.toString();
    String description="";
    JsonNode json = request().body().asJson();
    if(json != null) {
      description = Objects.firstNonNull(json.findPath("description").textValue(),"");
    }
    try {
      RoleService.createRole(name, inheritedRole, description);
    } catch (RoleNotFoundException e) {
      return badRequest("Role " + inheritedRole + " does not exist. Hint: check the 'inheritedRole' in your payload");
View Full Code Here


  public static Result editRole(String name){
    String description="";
    String newName="";
    JsonNode json = request().body().asJson();
    if(json != null) {
      description = json.findPath("description").textValue();
      newName = json.findPath("new_name").textValue();
    }
    try {
      RoleService.editRole(name, null, description,newName);
    } catch (RoleNotModifiableException e) {
View Full Code Here

    String description="";
    String newName="";
    JsonNode json = request().body().asJson();
    if(json != null) {
      description = json.findPath("description").textValue();
      newName = json.findPath("new_name").textValue();
    }
    try {
      RoleService.editRole(name, null, description,newName);
    } catch (RoleNotModifiableException e) {
      return badRequest("Role " + name + " is not modifiable");
View Full Code Here

    @BodyParser.Of(BodyParser.Json.class)
    public static Result post() {
      JsonNode json = request().body().asJson();
      ObjectNode result = Json.newObject();
      String name = json.findPath("name").textValue();
      result.put("result", "Body of proof that " + name + " exists!");
      return ok(result);
    }
}
View Full Code Here

        public Result sayHello() {
            JsonNode json = request().body().asJson();
            if(json == null) {
                return badRequest("Expecting Json data");
            } else {
                String name = json.findPath("name").textValue();
                if(name == null) {
                    return badRequest("Missing parameter [name]");
                } else {
                    return ok("Hello " + name);
                }
View Full Code Here

    static class JsonRequestAsJsonAction extends MockJavaAction {
        //#json-request-as-json
        @BodyParser.Of(BodyParser.Json.class)
        public Result sayHello() {
            JsonNode json = request().body().asJson();
            String name = json.findPath("name").textValue();
            if(name == null) {
                return badRequest("Missing parameter [name]");
            } else {
                return ok("Hello " + name);
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.