List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:com.github.fge.jsonschema.core.load.RefResolverTest.java
@Test public void refLoopsAreReported() { final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); node.put("$ref", "#"); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), node); final ValueHolder<SchemaTree> holder = ValueHolder.hold("schema", tree); try {//from w ww. j a va 2s.c om processor.process(report, holder); fail("No exception thrown!"); } catch (ProcessingException e) { assertMessage(e.getProcessingMessage()).hasMessage(BUNDLE.printf("refProcessing.refLoop", "#")); } }
From source file:com.github.fge.jsonschema.core.load.RefResolverTest.java
@Test public void danglingRefsAreReported() { final ObjectNode node = JacksonUtils.nodeFactory().objectNode(); node.put("$ref", "#/a"); final SchemaTree tree = new CanonicalSchemaTree(SchemaKey.anonymousKey(), node); final ValueHolder<SchemaTree> holder = ValueHolder.hold("schema", tree); try {// www. j a va 2s . c o m processor.process(report, holder); fail("No exception thrown!"); } catch (ProcessingException e) { assertMessage(e.getProcessingMessage()).hasMessage(BUNDLE.printf("refProcessing.danglingRef", "#/a")); } }
From source file:org.lendingclub.mercator.aws.KinesisScanner.java
private void project(StreamDescription description) { ObjectNode n = mapper.createObjectNode(); n.put("aws_account", getAccountId()); n.put("aws_region", getRegion().getName()); n.put("aws_arn", description.getStreamARN()); n.put("name", description.getStreamName()); n.put("aws_name", description.getStreamName()); n.put("aws_status", description.getStreamStatus()); n.put("aws_streamCreationTimestamp", description.getStreamCreationTimestamp().getTime()); n.put("aws_retentionPeriodHours", description.getRetentionPeriodHours()); n.put("aws_shardCount", description.getShards().size()); incrementEntityCount();/*w w w. j av a 2 s .c o m*/ String cypher = "merge (k:AwsKinesisStream {aws_arn:{aws_arn}}) set k+={props}, k.updateTs=timestamp() return k"; getNeoRxClient().execCypher(cypher, "aws_arn", n.path("aws_arn").asText(), "props", n); cypher = "match (a:AwsAccount {aws_account:{account}}), (k:AwsKinesisStream {aws_account:{account}}) MERGE (a)-[r:OWNS]->(k) set r.updateTs=timestamp()"; getNeoRxClient().execCypher(cypher, "account", getAccountId()); }
From source file:org.modeshape.web.jcr.rest.model.RestPropertyType.java
@Override public ObjectNode toJSON(Json json) { ObjectNode content = json.newObject(); content.put("requiredType", this.requiredType); if (!StringUtil.isBlank(declaringNodeTypeName)) { content.put("declaringNodeTypeName", this.declaringNodeTypeName); }/*from w ww . j a v a 2 s. co m*/ content.put("mandatory", isMandatory); content.put("multiple", isMultiple); content.put("autocreated", isAutoCreated); content.put("protected", isProtected); content.put("fullTextSearchable", isFullTextSearchable); content.put("onParentVersion", onParentVersion); ObjectNode object = json.newObject(); object.put(name, content); return object; }
From source file:yadarts.server.json.GameFinishedEntityEncoder.java
@Override public ObjectNode encode(GameFinishedEntity t, MediaType mt) { ObjectNode result = new ObjectNode(createJSONNodeFactory()); result.put("time", t.time); result.put("event", t.event); result.put("scores", encodeScores(t.scores)); result.put("winners", encodeWinners(t.winners)); return result; }
From source file:edu.nwpu.gemfire.monitor.service.ClusterWANInfoService.java
public ObjectNode execute(final HttpServletRequest request) throws Exception { // get cluster object Cluster cluster = Repository.get().getCluster(); // json object to be sent as response ObjectNode responseJSON = mapper.createObjectNode(); // members list ArrayNode connectedClusterListJson = mapper.createArrayNode(); for (Map.Entry<String, Boolean> entry : cluster.getWanInformation().entrySet()) { ObjectNode clusterJSON = mapper.createObjectNode(); clusterJSON.put("clusterId", entry.getKey()); clusterJSON.put("name", entry.getKey()); clusterJSON.put("status", entry.getValue()); connectedClusterListJson.add(clusterJSON); }// www . j a va 2s . c o m // Response JSON responseJSON.put("connectedClusters", connectedClusterListJson); // Send json response return responseJSON; }
From source file:edu.nwpu.gemfire.monitor.service.PulseVersionService.java
public ObjectNode execute(final HttpServletRequest request) throws Exception { // json object to be sent as response ObjectNode responseJSON = mapper.createObjectNode(); // Response/*from w w w . ja v a 2 s .c om*/ responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion()); responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId()); responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate()); responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate()); responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision()); responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository()); // Send json response return responseJSON; }
From source file:eu.europa.ec.fisheries.uvms.rest.FeatureToGeoJsonJacksonMapper.java
@SuppressWarnings("unchecked") private ObjectNode buildFeature(SimpleFeature simpleFeature) throws IOException { ObjectNode node = mapper.createObjectNode(); node.put(TYPE, FEATURE); node.set(GEOMETRY, buildGeometry((Geometry) simpleFeature.getDefaultGeometry())); node.set(PROPERTIES, buildProperties(simpleFeature)); return node;/*from w ww. jav a2s . c om*/ }
From source file:controllers.api.v1.Dataset.java
public static Result watchDataset(int id) { ObjectNode result = Json.newObject(); String username = session("user"); Map<String, String[]> params = request().body().asFormUrlEncoded(); if (StringUtils.isNotBlank(username)) { String message = DatasetsDAO.watchDataset(id, params, username); if (StringUtils.isBlank(message)) { result.put("status", "success"); } else {/* ww w . ja va2s.c om*/ result.put("status", "failed"); result.put("message", message); } } else { result.put("status", "failed"); result.put("message", "User is not authenticated"); } return ok(result); }
From source file:com.almende.eve.rpc.jsonrpc.JSONRPC.java
/** * Create a JSONRequest from a java method and arguments. * /*from w w w. j ava 2 s. c om*/ * @param method * the method * @param args * the args * @return the jSON request */ public static JSONRequest createRequest(final Method method, final Object[] args) { AnnotatedMethod annotatedMethod = null; try { annotatedMethod = new AnnotationUtil.AnnotatedMethod(method); } catch (final Exception e) { LOG.log(Level.WARNING, "Method can't be used as annotated method", e); throw new IllegalArgumentException( "Method '" + method.getName() + "' can't be used as annotated method.", e); } final List<AnnotatedParam> annotatedParams = annotatedMethod.getParams(); final ObjectNode params = JOM.createObjectNode(); for (int i = 0; i < annotatedParams.size(); i++) { final AnnotatedParam annotatedParam = annotatedParams.get(i); if (i < args.length && args[i] != null) { final String name = getName(annotatedParam); if (name != null) { final JsonNode paramValue = JOM.getInstance().valueToTree(args[i]); params.put(name, paramValue); } else { throw new IllegalArgumentException("Parameter " + i + " in method '" + method.getName() + "' is missing the @Name annotation."); } } else if (isRequired(annotatedParam)) { throw new IllegalArgumentException( "Required parameter " + i + " in method '" + method.getName() + "' is null."); } } JsonNode id = null; try { id = JOM.getInstance().valueToTree(new UUID().toString()); } catch (final Exception e) { LOG.log(Level.SEVERE, "Failed to generate UUID for request", e); } return new JSONRequest(id, method.getName(), params); }