Example usage for com.fasterxml.jackson.databind.node JsonNodeType ARRAY

List of usage examples for com.fasterxml.jackson.databind.node JsonNodeType ARRAY

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node JsonNodeType ARRAY.

Prototype

JsonNodeType ARRAY

To view the source code for com.fasterxml.jackson.databind.node JsonNodeType ARRAY.

Click Source Link

Usage

From source file:com.spotify.hamcrest.jackson.IsJsonArray.java

private IsJsonArray(Matcher<? super Collection<JsonNode>> elementsMatcher) {
    super(JsonNodeType.ARRAY);
    this.elementsMatcher = Objects.requireNonNull(elementsMatcher);
}

From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.api.LiveEndpointsControllerTest.java

@Test
public void testLiveNodes() throws Exception {
    Tuple2<Integer, JsonNode> tup = fetchJson("/live-nodes?limit=2", false);

    // must return HTTP/500 if no nodes are present
    assertEquals(400, tup._1.intValue());

    // add one live node
    addNode("exec1", "1.2.3.4");

    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    JsonNode json = tup._2;//from w w w  .j  a v a2 s.  c  o  m
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    JsonNode nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(1).contains(TextNode.valueOf("1.2.3.4"));

    // test more output formats

    Tuple2<Integer, String> str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("1.2.3.4 9042", str._2);

    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);

    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 1.2.3.4 -p 7199", str._2);

    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);

    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("1.2.3.4 9042", str._2);

    str = fetchText("/live-nodes/stress", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);

    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 1.2.3.4 -p 7199", str._2);

    str = fetchText("/live-nodes/text", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);

    //
    // mark node as dead
    //

    cluster.recordHealthCheck("exec1", healthCheckDetailsFailed());
    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(400, tup._1.intValue());

    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(400, str._1.intValue());

    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(400, str._1.intValue());

    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(400, str._1.intValue());

    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(400, str._1.intValue());

    // add a live nodes

    addNode("exec2", "2.2.2.2");

    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(1).contains(TextNode.valueOf("2.2.2.2"));

    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());
    assertEquals("2.2.2.2 9042", str._2);

    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());
    assertEquals("-node 2.2.2.2 -port native=9042 thrift=9160 jmx=7199", str._2);

    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());
    assertEquals("-h 2.2.2.2 -p 7199", str._2);

    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
    assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 2.2.2.2\n", str._2);

    // mark 1st node as live

    cluster.recordHealthCheck("exec1", healthCheckDetailsSuccess("NORMAL", true));

    tup = fetchJson("/live-nodes?limit=2", false);
    assertEquals(200, tup._1.intValue());
    json = tup._2;
    assertEquals(9042, json.get("nativePort").asInt());
    assertEquals(9160, json.get("rpcPort").asInt());
    assertEquals(7199, json.get("jmxPort").asInt());
    nodes = json.get("liveNodes");
    assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
    assertThat(nodes).hasSize(2).contains(TextNode.valueOf("1.2.3.4")).contains(TextNode.valueOf("2.2.2.2"));

    str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
    assertEquals(200, str._1.intValue());

    str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
    assertEquals(200, str._1.intValue());

    str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
    assertEquals(200, str._1.intValue());

    str = fetchText("/live-nodes/text?limit=2", "text/plain");
    assertEquals(200, str._1.intValue());
}

From source file:com.hp.autonomy.hod.client.api.textindex.query.parametric.GetParametricValuesServiceImpl.java

private List<FieldValues> parseResponse(final JsonNode response) {
    if (response == null || response.get("fields") == null) {
        throw new RuntimeException("Failed to parse JSON");
    }//www .ja va 2s  .c  o  m

    final JsonNode fieldsNode = response.get("fields");

    if (fieldsNode.getNodeType() == JsonNodeType.OBJECT || fieldsNode.getNodeType() == JsonNodeType.ARRAY) {
        final List<FieldValues> output = new ArrayList<>();

        for (final JsonNode node : fieldsNode) {
            try {
                final FieldValues fieldValues = objectMapper.treeToValue(node, FieldValues.class);
                output.add(fieldValues);
            } catch (final JsonProcessingException e) {
                throw new RuntimeException("Failed to parse JSON", e);
            }
        }

        return output;
    } else {
        throw new RuntimeException("Failed to parse JSON");
    }
}

From source file:de.thingweb.thing.Thing.java

public URI getUri(int index) {
    JsonNode uris = getMetadata().get("uris");
    if (uris != null) {
        try {//from  w  w w.ja  v  a2s  .co m
            if (uris.getNodeType() == JsonNodeType.STRING) {
                return new URI(uris.asText());
            } else if (uris.getNodeType() == JsonNodeType.ARRAY) {
                ArrayNode an = (ArrayNode) uris;
                return new URI(an.get(index).asText());
            }
        } catch (URISyntaxException e) {
            throw new RuntimeException("TD with malformed base uris");
        }
    } else {
        throw new RuntimeException("TD without base uris field");
    }
    // should never be reached
    throw new RuntimeException("Unexpected error while retrieving uri at index " + index);
}

From source file:de.thingweb.client.ClientFactory.java

protected Client pickClient() throws UnsupportedException, URISyntaxException {
    // check for right protocol&encoding
    List<Client> clients = new ArrayList<>(); // it is assumed URIs are ordered by priority

    JsonNode uris = thing.getMetadata().get("uris");
    if (uris != null) {
        if (uris.getNodeType() == JsonNodeType.STRING) {
            checkUri(uris.asText(), clients);
        } else if (uris.getNodeType() == JsonNodeType.ARRAY) {
            ArrayNode an = (ArrayNode) uris;
            for (int i = 0; i < an.size(); i++) {
                checkUri(an.get(i).asText(), i, clients);
            }//from  www .j av  a  2  s  . co m
        }

        // int prio = 1;
        //      for (JsonNode juri : uris) {
        //       String suri = juri.asText();
        //        URI uri = new URI(suri);
        //        if(isCoapScheme(uri.getScheme())) {
        //          clients.add(new CoapClientImpl(suri, thing));
        //          log.info("Found matching client '" + CoapClientImpl.class.getName() + "' with priority " + prio++);
        //        } else if(isHttpScheme(uri.getScheme())) {
        //          clients.add(new HttpClientImpl(suri, thing));
        //          log.info("Found matching client '" + HttpClientImpl.class.getName() + "' with priority " + prio++);
        //        } 
        //      }
    }

    // take priority into account
    if (clients.isEmpty()) {
        log.warn("No fitting client implementation found!");
        throw new UnsupportedException("No fitting client implementation found!");
        // return null;
    } else {
        // pick first one with highest priority
        Client c = clients.get(0);
        log.info("Use '" + c.getClass().getName() + "' according to priority");
        return c;
    }

}

From source file:com.spotify.ffwd.json.JsonObjectMapperDecoder.java

private Set<String> decodeTags(JsonNode tree, String name) {
    final JsonNode n = tree.get(name);

    if (n == null)
        return EMPTY_TAGS;

    if (n.getNodeType() != JsonNodeType.ARRAY)
        return EMPTY_TAGS;

    final List<String> tags = Lists.newArrayList();

    final Iterator<JsonNode> iter = n.elements();

    while (iter.hasNext())
        tags.add(iter.next().asText());//from www  . j av a  2s  . c  o  m

    return Sets.newHashSet(tags);
}

From source file:de.thingweb.typesystem.jsonschema.JsonSchemaType.java

public static JsonType getJsonType(JsonNode jsonSchemaNode) throws JsonSchemaException {
    JsonType jtype = null;//from w  ww  .j  a va  2 s  . c o  m

    if (jsonSchemaNode != null) {
        JsonNode typeNode = jsonSchemaNode.findValue("type");
        if (typeNode != null) {
            switch (typeNode.asText()) {
            case "boolean":
                jtype = new JsonBoolean();
                break;
            case "integer":
            case "number":
                boolean exclusiveMinimum = false;
                JsonNode exclusiveMinimumNode = jsonSchemaNode.findValue("exclusiveMinimum");
                if (exclusiveMinimumNode != null
                        && exclusiveMinimumNode.getNodeType() == JsonNodeType.BOOLEAN) {
                    exclusiveMinimum = exclusiveMinimumNode.asBoolean();
                }
                boolean exclusiveMaximum = false;
                JsonNode exclusiveMaximumNode = jsonSchemaNode.findValue("exclusiveMaximum");
                if (exclusiveMaximumNode != null
                        && exclusiveMaximumNode.getNodeType() == JsonNodeType.BOOLEAN) {
                    exclusiveMaximum = exclusiveMaximumNode.asBoolean();
                }

                if ("integer".equals(typeNode.asText())) {
                    jtype = new JsonInteger();
                    JsonNode minimumNode = jsonSchemaNode.findValue("minimum");
                    if (minimumNode != null && minimumNode.getNodeType() == JsonNodeType.NUMBER) {
                        ((JsonInteger) jtype).setMinimum(minimumNode.asLong());
                    }
                    JsonNode maximumNode = jsonSchemaNode.findValue("maximum");
                    if (maximumNode != null && maximumNode.getNodeType() == JsonNodeType.NUMBER) {
                        ((JsonInteger) jtype).setMaximum(maximumNode.asLong());
                    }
                } else {
                    assert ("number".equals(typeNode.asText()));

                    jtype = new JsonNumber();
                    JsonNode minimumNode = jsonSchemaNode.findValue("minimum");
                    if (minimumNode != null && minimumNode.getNodeType() == JsonNodeType.NUMBER) {
                        ((JsonNumber) jtype).setMinimum(minimumNode.asDouble());
                    }
                    JsonNode maximumNode = jsonSchemaNode.findValue("maximum");
                    if (maximumNode != null && maximumNode.getNodeType() == JsonNodeType.NUMBER) {
                        ((JsonNumber) jtype).setMaximum(maximumNode.asDouble());
                    }
                }

                ((AbstractJsonNumeric) jtype).setExclusiveMinimum(exclusiveMinimum);
                ((AbstractJsonNumeric) jtype).setExclusiveMaximum(exclusiveMaximum);

                break;
            case "null":
                jtype = new JsonNull();
                break;
            case "string":
                jtype = new JsonString();
                break;
            case "array":
                JsonNode itemsNode = jsonSchemaNode.findValue("items");
                if (itemsNode != null && JsonNodeType.OBJECT == itemsNode.getNodeType()) {
                    jtype = new JsonArray(getJsonType(itemsNode));
                } else {
                    throw new JsonSchemaException("items not object");
                }

                break;
            case "object":
                JsonNode propertiesNode = jsonSchemaNode.findValue("properties");
                if (propertiesNode != null && JsonNodeType.OBJECT == propertiesNode.getNodeType()) {
                    Iterator<Entry<String, JsonNode>> iter = propertiesNode.fields();
                    Map<String, JsonType> properties = new HashMap<String, JsonType>();
                    while (iter.hasNext()) {
                        Entry<String, JsonNode> e = iter.next();
                        JsonNode nodeProp = e.getValue();
                        properties.put(e.getKey(), getJsonType(nodeProp));
                    }
                    jtype = new JsonObject(properties);
                } else {
                    throw new JsonSchemaException("Properties not object");
                }
                // required
                JsonNode requiredNode = jsonSchemaNode.findValue("required");
                if (requiredNode != null && JsonNodeType.ARRAY == requiredNode.getNodeType()) {
                    ArrayNode an = (ArrayNode) requiredNode;
                    Iterator<JsonNode> iterReq = an.elements();
                    while (iterReq.hasNext()) {
                        JsonNode nreq = iterReq.next();
                        if (JsonNodeType.STRING == nreq.getNodeType()) {
                            ((JsonObject) jtype).addRequired(nreq.asText());
                        } else {
                            throw new JsonSchemaException("Unexpected required node: " + nreq);
                        }
                    }
                }
                break;
            }
        }
    }

    return jtype;
}

From source file:controllers.EntryController.java

@Transactional
@BodyParser.Of(BodyParser.Json.class)
public Result enter() {
    Entry entry = new Entry();
    ArrayList<String> missing = new ArrayList<String>();
    JsonNode json = request().body().asJson();
    Logger.debug("GOT: " + json.toString());
    boolean retServerId = false;
    JsonNode value;/*w w  w .  j  a v a2  s .co m*/
    value = json.findValue("tech_id");
    if (value == null) {
        missing.add("tech_id");
    } else {
        entry.tech_id = value.intValue();
    }
    value = json.findValue("date");
    if (value == null) {
        missing.add("date");
    } else {
        entry.entry_time = new Date(value.longValue());
    }
    value = json.findValue("server_id");
    if (value != null) {
        entry.id = value.longValue();
        retServerId = true;
        Entry existing;
        if (entry.id > 0) {
            existing = Entry.find.byId(entry.id);
            existing.entry_time = entry.entry_time;
            existing.tech_id = entry.tech_id;
        } else {
            existing = Entry.findByDate(entry.tech_id, entry.entry_time);
        }
        if (existing != null) {
            entry = existing;
        }
    }
    int truck_number;
    String license_plate;
    value = json.findValue("truck_number");
    if (value != null) {
        truck_number = value.intValue();
    } else {
        truck_number = 0;
    }
    value = json.findValue("license_plate");
    if (value != null) {
        license_plate = value.textValue();
    } else {
        license_plate = null;
    }
    if (truck_number == 0 && license_plate == null) {
        missing.add("truck_number");
        missing.add("license_plate");
    } else {
        // Note: I don't call Version.inc(Version.VERSION_TRUCK) intentionally.
        // The reason is that other techs don't need to know about a local techs truck updates.
        Truck truck = Truck.add(truck_number, license_plate, entry.tech_id);
        entry.truck_id = truck.id;
    }
    value = json.findValue("project_id");
    if (value == null) {
        missing.add("project_id");
    } else {
        entry.project_id = value.longValue();
    }
    value = json.findValue("status");
    if (value != null) {
        entry.status = Entry.Status.from(value.textValue());
    }
    value = json.findValue("address_id");
    if (value == null) {
        value = json.findValue("address");
        if (value == null) {
            missing.add("address_id");
        } else {
            String address = value.textValue().trim();
            if (address.length() > 0) {
                try {
                    Company company = Company.parse(address);
                    Company existing = Company.has(company);
                    if (existing != null) {
                        company = existing;
                    } else {
                        company.created_by = entry.tech_id;
                        company.save();
                        Version.inc(Version.VERSION_COMPANY);
                    }
                    entry.company_id = company.id;
                } catch (Exception ex) {
                    return badRequest2("address: " + ex.getMessage());
                }
            } else {
                return badRequest2("address");
            }
        }
    } else {
        entry.company_id = value.longValue();
    }
    value = json.findValue("equipment");
    if (value != null) {
        if (value.getNodeType() != JsonNodeType.ARRAY) {
            Logger.error("Expected array for element 'equipment'");
        } else {
            int collection_id;
            if (entry.equipment_collection_id > 0) {
                collection_id = (int) entry.equipment_collection_id;
                EntryEquipmentCollection.deleteByCollectionId(entry.equipment_collection_id);
            } else {
                collection_id = Version.inc(Version.NEXT_EQUIPMENT_COLLECTION_ID);
            }
            boolean newEquipmentCreated = false;
            Iterator<JsonNode> iterator = value.elements();
            while (iterator.hasNext()) {
                JsonNode ele = iterator.next();
                EntryEquipmentCollection collection = new EntryEquipmentCollection();
                collection.collection_id = (long) collection_id;
                JsonNode subvalue = ele.findValue("equipment_id");
                if (subvalue == null) {
                    subvalue = ele.findValue("equipment_name");
                    if (subvalue == null) {
                        missing.add("equipment_id");
                        missing.add("equipment_name");
                    } else {
                        String name = subvalue.textValue();
                        List<Equipment> equipments = Equipment.findByName(name);
                        Equipment equipment;
                        if (equipments.size() == 0) {
                            equipment = new Equipment();
                            equipment.name = name;
                            equipment.created_by = entry.tech_id;
                            equipment.save();
                        } else {
                            if (equipments.size() > 1) {
                                Logger.error("Too many equipments found with name: " + name);
                            }
                            equipment = equipments.get(0);
                        }
                        collection.equipment_id = equipment.id;
                        newEquipmentCreated = true;
                    }
                } else {
                    collection.equipment_id = subvalue.longValue();
                }
                collection.save();
            }
            entry.equipment_collection_id = collection_id;
            if (newEquipmentCreated) {
                Version.inc(Version.VERSION_EQUIPMENT);
            }
        }
    }
    value = json.findValue("picture");
    if (value != null) {
        if (value.getNodeType() != JsonNodeType.ARRAY) {
            Logger.error("Expected array for element 'picture'");
        } else {
            int collection_id;
            if (entry.picture_collection_id > 0) {
                collection_id = (int) entry.picture_collection_id;
                PictureCollection.deleteByCollectionId(entry.picture_collection_id, null);
            } else {
                collection_id = Version.inc(Version.NEXT_PICTURE_COLLECTION_ID);
            }
            Iterator<JsonNode> iterator = value.elements();
            while (iterator.hasNext()) {
                JsonNode ele = iterator.next();
                PictureCollection collection = new PictureCollection();
                collection.collection_id = (long) collection_id;
                JsonNode subvalue = ele.findValue("note");
                if (subvalue != null) {
                    collection.note = subvalue.textValue();
                }
                subvalue = ele.findValue("filename");
                if (subvalue == null) {
                    missing.add("filename");
                } else {
                    collection.picture = subvalue.textValue();
                    collection.save();
                }
            }
            entry.picture_collection_id = collection_id;
        }
    }
    value = json.findValue("notes");
    if (value != null) {
        if (value.getNodeType() != JsonNodeType.ARRAY) {
            Logger.error("Expected array for element 'notes'");
        } else {
            int collection_id;
            if (entry.note_collection_id > 0) {
                collection_id = (int) entry.note_collection_id;
                EntryNoteCollection.deleteByCollectionId(entry.note_collection_id);
            } else {
                collection_id = Version.inc(Version.NEXT_NOTE_COLLECTION_ID);
            }
            Iterator<JsonNode> iterator = value.elements();
            while (iterator.hasNext()) {
                JsonNode ele = iterator.next();
                EntryNoteCollection collection = new EntryNoteCollection();
                collection.collection_id = (long) collection_id;
                JsonNode subvalue = ele.findValue("id");
                if (subvalue == null) {
                    subvalue = ele.findValue("name");
                    if (subvalue == null) {
                        missing.add("note:id, note:name");
                    } else {
                        String name = subvalue.textValue();
                        List<Note> notes = Note.findByName(name);
                        if (notes == null || notes.size() == 0) {
                            missing.add("note:" + name);
                        } else if (notes.size() > 1) {
                            Logger.error("Too many notes with name: " + name);
                            missing.add("note:" + name);
                        } else {
                            collection.note_id = notes.get(0).id;
                        }
                    }
                } else {
                    collection.note_id = subvalue.longValue();
                }
                subvalue = ele.findValue("value");
                if (value == null) {
                    missing.add("note:value");
                } else {
                    collection.note_value = subvalue.textValue();
                }
                collection.save();
            }
            entry.note_collection_id = collection_id;
        }
    }
    if (missing.size() > 0) {
        return missingRequest(missing);
    }
    if (entry.id != null && entry.id > 0) {
        entry.update();
        Logger.debug("Updated entry " + entry.id);
    } else {
        entry.save();
        Logger.debug("Created new entry " + entry.id);
    }
    long ret_id;
    if (retServerId) {
        ret_id = entry.id;
    } else {
        ret_id = 0;
    }
    return ok(Long.toString(ret_id));
}

From source file:org.agatom.springatom.cmp.action.DefaultActionsModelReader.java

private ActionRole resolveSecurityRoles(final JsonNode roles, final ActionRoleMap.Connector[] connectors) {
    if (JsonNodeType.STRING.equals(roles.getNodeType())) {
        return new DefaultActionRole().appendRole(roles.asText());
    }/*w  w  w . ja  v a  2  s .  c  om*/
    final Iterator<JsonNode> iterator = roles.iterator();
    ActionRole actionRole = null;

    while (iterator.hasNext()) {
        final JsonNode node = iterator.next();
        final JsonNodeType type = node.getNodeType();
        if (JsonNodeType.STRING.equals(type)) {
            actionRole = new DefaultActionRole().appendRole(node.asText());
        } else if (JsonNodeType.ARRAY.equals(type)) {

            final ArrayNode arrayNode = (ArrayNode) node;
            final DefaultActionRole role = new DefaultActionRole();
            for (JsonNode textRoleNode : arrayNode) {
                role.appendRole(textRoleNode.asText());
            }
            actionRole = role;

        } else if (JsonNodeType.OBJECT.equals(type)) {

            final ActionRoleMap actionRoleMap = new ActionRoleMap();
            final Map<ActionRoleMap.Connector, DefaultActionRole> map = Maps
                    .newHashMapWithExpectedSize(node.size());
            String strConnector;
            for (final ActionRoleMap.Connector connector : connectors) {
                strConnector = connector.toString().toLowerCase();
                if (node.has(strConnector)) {
                    final DefaultActionRole role = new DefaultActionRole();
                    for (JsonNode textRoleNode : node.get(strConnector)) {
                        role.appendRole(textRoleNode.asText());
                    }
                    map.put(connector, role);
                }
            }
            actionRoleMap.setRoles(map);
            actionRole = actionRoleMap;

        }
    }

    return actionRole;
}

From source file:org.agatom.springatom.cmp.action.DefaultActionsModelReader.java

private void parseActionModels() throws Exception {
    Assert.notNull(this.actionModel);
    LOGGER.trace("Starting parsing actionModel");
    try {//w ww  .j  ava 2 s .  c om
        final long startTime = System.nanoTime();
        {
            final JsonNode actionModelsNode = this.actionModel.get(ACTION_MODELS_KEY);
            Assert.isTrue(actionModelsNode.getNodeType().equals(JsonNodeType.ARRAY));

            final ArrayNode actionModels = (ArrayNode) actionModelsNode;
            final int length = actionModels.size();
            LOGGER.trace(String.format("%d actionModels found", length));

            final Map<String, ActionModelReferenceMap> referenceMap = Maps.newHashMap();
            for (final JsonNode node : actionModels) {
                referenceMap.put(node.get("name").textValue(), this.flattenActionModels((ObjectNode) node));
            }
            this.flattenActionModel = referenceMap;
        }
        LOGGER.info(String.format("Loaded actionModel in %dms",
                TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)));
    } catch (Exception exp) {
        LOGGER.error("Error in parsing actionModel", exp);
        throw exp;
    }
}