Example usage for com.fasterxml.jackson.databind.node ObjectNode get

List of usage examples for com.fasterxml.jackson.databind.node ObjectNode get

Introduction

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

Prototype

public JsonNode get(String paramString) 

Source Link

Usage

From source file:org.jboss.pnc.auth.keycloakutil.util.HttpUtil.java

public static String getAttrForType(String rootUrl, String realm, String auth, String resourceEndpoint,
        String attrName, String attrValue, String returnAttrName) {

    String resourceUrl = composeResourceUrl(rootUrl, realm, resourceEndpoint);
    resourceUrl = HttpUtil.addQueryParamsToUri(resourceUrl, attrName, attrValue, "first", "0", "max", "2");

    List<ObjectNode> users = doGetJSON(RoleOperations.LIST_OF_NODES.class, resourceUrl, auth);

    ObjectNode user;
    try {//  www  . jav  a 2  s.  com
        user = new LocalSearch(users).exactMatchOne(attrValue, attrName);
    } catch (Exception e) {
        throw new RuntimeException("Multiple " + resourceEndpoint + " found for " + attrName + ": " + attrValue,
                e);
    }

    String typeName = singularize(resourceEndpoint);
    if (user == null) {
        throw new RuntimeException(capitalize(typeName) + " not found for " + attrName + ": " + attrValue);
    }

    JsonNode attr = user.get(returnAttrName);
    if (attr == null) {
        throw new RuntimeException("Returned " + typeName + " info has no '" + returnAttrName + "' attribute");
    }
    return attr.asText();
}

From source file:com.ikanow.aleph2.graph.titan.utils.TitanGraphBuildingUtils.java

/** Checks a Gremlin vertex or edge label against a GraphSON one
 * @param user_key//  ww w .  java 2  s.c o m
 * @param candidate
 * @return
 */
protected static boolean labelMatches(final ObjectNode user_key, final Element candidate) {
    return candidate.label().equals(user_key.get(GraphAnnotationBean.label).asText()); // (exists by construction)
}

From source file:de.petendi.ethereum.secure.proxy.JsonRpcRequestListener.java

@Override
public void onBeforeRequestSent(JsonRpcClient jsonRpcClient, ObjectNode objectNode) {
    int id = Integer.valueOf(objectNode.get(ID).asText());
    objectNode.remove(ID);/*from  w  ww  .  j  a  v a2  s . com*/
    objectNode.put(ID, id);
}

From source file:com.syncedsynapse.kore2.jsonrpc.ApiNotification.java

/**
 * Constructor from a notification node (starting on "params" node)
 * @param node node//www .  ja  v a  2s  .co m
 */
public ApiNotification(ObjectNode node) {
    sender = node.get("sender").textValue();
}

From source file:org.forgerock.openig.migrate.action.HeapObjectsSimplificationAction.java

@Override
public ObjectNode migrate(final ObjectNode configuration) {
    JsonNode heap = configuration.get("heap");
    if (heap != null) {
        JsonNode objects = heap.get("objects");
        if ((objects != null) && objects.isArray()) {
            ArrayNode objectsNode = (ArrayNode) objects;
            configuration.replace("heap", objectsNode);
        }/* ww w .  j  ava 2 s  .  c o m*/
    }
    return configuration;
}

From source file:org.forgerock.openig.migrate.action.model.ModelBuilder.java

public ObjectModel buildObject(ObjectNode node, final int index) {
    String name = node.get("name").asText();
    String typeName = node.get("type").asText();
    ObjectType type = registry.findType(typeName);
    return new ObjectModel(node, index, name, type);
}

From source file:org.forgerock.openig.migrate.action.EmptyConfigRemovalAction.java

@Override
public ObjectNode migrate(final ObjectNode configuration) {
    ArrayNode heap = (ArrayNode) configuration.get("heap");
    for (JsonNode node : heap) {
        ObjectNode object = (ObjectNode) node;
        JsonNode config = object.get("config");
        if ((config != null) && config.isContainerNode() && !config.iterator().hasNext()) {
            object.remove("config");
        }/*  ww w.  ja  v a 2 s .  c o m*/
    }
    return configuration;
}

From source file:org.apache.unomi.persistence.spi.ItemDeserializer.java

@Override
public Item deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectCodec codec = jp.getCodec();/*from ww w .  j  a  va  2  s .  c o  m*/
    ObjectNode treeNode = codec.readTree(jp);
    String type = treeNode.get("itemType").textValue();
    Class<? extends Item> objectClass = classes.get(type);
    if (objectClass == null) {
        objectClass = CustomItem.class;
    } else {
        treeNode.remove("itemType");
    }
    Item item = codec.treeToValue(treeNode, objectClass);
    item.setItemId(treeNode.get("itemId").asText());
    return item;
}

From source file:snow.console.Stdin.java

@Override
public void execute(JsonNode params, StreamResults stream) {
    //        System.out.println(params.toString());
    if (params instanceof ObjectNode) {
        ObjectNode node = (ObjectNode) params;
        JsonNode id = node.get("id");
        if (id != null) {
            JsonNode data = node.get("data");
            if (data != null) {
                Terminal terminal = Terminal.get(id.asText());
                if (terminal != null)
                    terminal.in(data.asText());
            }//from  w  w  w.j  av a2 s  .  c om
        }
    }
}

From source file:com.evrythng.java.wrapper.mapping.ActionDeserializerImpl.java

@Override
public Action deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {

    ObjectCodec codec = jp.getCodec();//from  w w w .j  a v  a 2  s . com
    ObjectMapper mapper = (ObjectMapper) codec;
    ObjectNode root = mapper.readTree(jp);
    JsonNode type = root.get(getTypeFieldName());
    if (type == null) {
        throw new IllegalArgumentException(this.getValueClass().getSimpleName() + " type cannot be empty.");
    }
    String sType = type.textValue();
    if (sType == null || sType.isEmpty()) {
        throw new IllegalArgumentException(this.getValueClass().getSimpleName() + " type cannot be empty.");
    }

    return codec.treeToValue(root, resolveClass(sType));
}