Package com.fasterxml.jackson.databind

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


                throw new BadRequestException("Invalid blueprint: 'Blueprints' node is missing from JSON.");
            }
            if (root.path("Blueprints").path("blueprint_name").isMissingNode()) {
                throw new BadRequestException("Invalid blueprint: 'blueprint_name' under 'Blueprints' is missing from JSON.");
            }
            if (root.path("host_groups").isMissingNode() || !root.path("host_groups").isArray()) {
                throw new BadRequestException("Invalid blueprint: 'host_groups' node is missing from JSON or is not an array.");
            }
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
View Full Code Here


                throw new BadRequestException("Invalid blueprint: 'Blueprints' node is missing from JSON.");
            }
            if (root.path("Blueprints").path("blueprint_name").isMissingNode()) {
                throw new BadRequestException("Invalid blueprint: 'blueprint_name' under 'Blueprints' is missing from JSON.");
            }
            if (root.path("host_groups").isMissingNode() || !root.path("host_groups").isArray()) {
                throw new BadRequestException("Invalid blueprint: 'host_groups' node is missing from JSON or is not an array.");
            }
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
View Full Code Here

                throw new BadRequestException("Invalid blueprint: 'blueprint_name' under 'Blueprints' is missing from JSON.");
            }
            if (root.path("host_groups").isMissingNode() || !root.path("host_groups").isArray()) {
                throw new BadRequestException("Invalid blueprint: 'host_groups' node is missing from JSON or is not an array.");
            }
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
                if (hostGroup.path("name").isMissingNode()) {
                    throw new BadRequestException("Invalid blueprint: every 'host_group' must have a 'name' attribute.");
                }
View Full Code Here

                throw new BadRequestException("Invalid blueprint: 'host_groups' node is missing from JSON or is not an array.");
            }
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
                if (hostGroup.path("name").isMissingNode()) {
                    throw new BadRequestException("Invalid blueprint: every 'host_group' must have a 'name' attribute.");
                }
            }
            new AmbariClient().validateBlueprint(blueprintText);
        } catch (InvalidBlueprintException e) {
View Full Code Here

    private Boolean assignableHostgroup(Cluster cluster, String hostgroup) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode root;
            root = mapper.readTree(cluster.getBlueprint().getBlueprintText());
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
                if (hostGroup.path("name").asText().equals(hostgroup)) {
                    return true;
                }
View Full Code Here

            JsonNode root;
            root = mapper.readTree(cluster.getBlueprint().getBlueprintText());
            Iterator<JsonNode> hostGroupsIterator = root.path("host_groups").elements();
            while (hostGroupsIterator.hasNext()) {
                JsonNode hostGroup = hostGroupsIterator.next();
                if (hostGroup.path("name").asText().equals(hostgroup)) {
                    return true;
                }
            }
        } catch (IOException e) {
            throw new InternalServerException("Unhandled exception occured while reading blueprint: " + e.getMessage(), e);
View Full Code Here

  public static JsonNode read(JsonNode json,PartsParser pp){
    JsonNode root = json;
    for (Part p : pp.parts()) {
      if(p instanceof PartsLexer.ArrayField){
        int index = ((PartsLexer.ArrayField)p).arrayIndex;
        root = root.path(p.getName()).path(index);
      else if(p instanceof PartsLexer.Field){
        root = root.path(p.getName());
      }
    }
    return root;
View Full Code Here

    for (Part p : pp.parts()) {
      if(p instanceof PartsLexer.ArrayField){
        int index = ((PartsLexer.ArrayField)p).arrayIndex;
        root = root.path(p.getName()).path(index);
      else if(p instanceof PartsLexer.Field){
        root = root.path(p.getName());
      }
    }
    return root;
  }
 
View Full Code Here

      if(p.equals(pp.last())){
        break;
      }
      if(p instanceof PartsLexer.ArrayField){
        int index = ((PartsLexer.ArrayField)p).arrayIndex;
        root = root.path(p.getName()).path(index);
      else if(p instanceof PartsLexer.Field){
        root = root.path(p.getName());
      }
    }
    if(root.isMissingNode()){
View Full Code Here

      }
      if(p instanceof PartsLexer.ArrayField){
        int index = ((PartsLexer.ArrayField)p).arrayIndex;
        root = root.path(p.getName()).path(index);
      else if(p instanceof PartsLexer.Field){
        root = root.path(p.getName());
      }
    }
    if(root.isMissingNode()){
      throw new MissingNodeException(pp.treeFields());
    }
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.