List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:com.github.lynxdb.server.api.http.ErrorResponse.java
public ResponseEntity response() { ObjectNode error = mapper.createObjectNode(); error.put("code", status.value()); error.put("message", status.getReasonPhrase()); if (message != null) { error.put("details", message); }//from ww w .j a va 2s . c om if (ex != null) { StringBuilder trace = new StringBuilder(); parseException(ex, trace); error.put("trace", trace.toString()); } return ResponseEntity.status(status).body(error); }
From source file:com.activiti.web.rest.client.modelinfo.AbstractInfoMapper.java
protected void createPropertyNode(String name, String value) { if (StringUtils.isNotEmpty(value)) { ObjectNode propertyNode = objectMapper.createObjectNode(); propertyNode.put("name", name); propertyNode.put("value", value); propertiesNode.add(propertyNode); }/*from w ww . j ava2 s.c o m*/ }
From source file:com.almende.eve.test.TestDebug.java
/** * Test agents./* w w w. j av a 2 s . c om*/ * * @throws IOException * Signals that an I/O exception has occurred. * @throws URISyntaxException * the URI syntax exception * @throws InterruptedException * the interrupted exception */ @Test public void testDebug() throws IOException, URISyntaxException, InterruptedException { final HttpTransportConfig transportConfig = new HttpTransportConfig(); transportConfig.setServletUrl("http://localhost:8080/agents/"); transportConfig.setServletClass("com.almende.eve.transport.http.DebugServlet"); transportConfig.setDoAuthentication(false); transportConfig.setServletLauncher("JettyLauncher"); final ObjectNode jettyParms = JOM.createObjectNode(); jettyParms.put("port", 8080); transportConfig.set("jetty", jettyParms); final AgentConfig config = new AgentConfig("example"); config.addTransport(transportConfig); final ExampleAgent agent = new ExampleAgent(); agent.setConfig(config); final AgentConfig config2 = new AgentConfig("calc"); config2.addTransport(transportConfig); final CalcAgent agent2 = new CalcAgent(); agent2.setConfig(config2); Thread.sleep(10000); }
From source file:com.github.lynxdb.server.api.http.handlers.EpError.java
@RequestMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity error(HttpServletRequest request, HttpServletResponse response) { HttpStatus status = HttpStatus.valueOf((int) request.getAttribute("javax.servlet.error.status_code")); ObjectMapper mapper = new ObjectMapper(); ObjectNode error = mapper.createObjectNode(); error.put("code", status.value()); error.put("message", status.getReasonPhrase()); error.put("details", getErrorAttributes(request, true).get("message").toString()); if (getErrorAttributes(request, true).get("exception") != null) { error.put("trace", getErrorAttributes(request, true).get("exception").toString() + "\n" + getErrorAttributes(request, true).get("trace").toString()); }/*from ww w. j a va2 s . c o m*/ return ResponseEntity.status(status).body(error.toString()); }
From source file:com.redhat.lightblue.ExecutionOptions.java
/** * Returns a json representation of this *///from w w w . j a v a2 s . c o m @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); node.put("timeLimit", timeLimit); node.put("asynchronous", asynchronous); return node; }
From source file:com.chenchengzhi.windtalkers.core.Issue.java
public ObjectNode translate() { ObjectNode errorsNode = new ObjectNode(JsonNodeFactory.instance); errorsNode.put("statusCode", statusCode.getDescription()); if (className != null) { errorsNode.put("className", className); errorsNode.put("methodName", methodName); errorsNode.put("reason", reason); }//from ww w. jav a2 s . c o m return errorsNode; }
From source file:edu.nwpu.gemfire.monitor.service.ClusterKeyStatisticsService.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(); responseJSON.put("writePerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_WRITES_PER_SECOND))); responseJSON.put("readPerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_READ_PER_SECOND))); responseJSON.put("queriesPerSecTrend", mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_QUERIES_PER_SECOND))); // Send json response return responseJSON; }
From source file:org.apache.taverna.activities.interaction.velocity.NotifyChecker.java
@Override public Object visit(final ASTDirective node, final Object data) { ObjectNode json = (ObjectNode) data; if (node.getDirectiveName().equals("notify")) { json.put("progressNotification", true); }/*from w w w. java 2s . c o m*/ return null; }
From source file:org.fcrepo.camel.indexing.solr.SolrDeleteProcessor.java
/** * Format a message so that a record can be deleted in Solr. * * The output format should be:/*from w w w . jav a 2 s .c om*/ * * { * "delete" : { * "id" : "/foo" * }, * "commitWithin" : 500 * } * * @param exchange The incoming message exchange. */ public void process(final Exchange exchange) throws Exception { final Message in = exchange.getIn(); final ObjectMapper mapper = new ObjectMapper(); if (isBlank(in.getHeader(FcrepoHeaders.FCREPO_IDENTIFIER, String.class))) { in.setHeader(FcrepoHeaders.FCREPO_IDENTIFIER, in.getHeader(JmsHeaders.IDENTIFIER, String.class)); } if (isBlank(in.getHeader(FcrepoHeaders.FCREPO_BASE_URL, String.class))) { in.setHeader(FcrepoHeaders.FCREPO_BASE_URL, in.getHeader(JmsHeaders.BASE_URL, String.class)); } final ObjectNode root = mapper.createObjectNode(); root.putObject("delete").put("id", in.getHeader(FcrepoHeaders.FCREPO_BASE_URL, String.class) + in.getHeader(FcrepoHeaders.FCREPO_IDENTIFIER, String.class)); in.setBody(mapper.writeValueAsString(root)); in.setHeader(Exchange.CONTENT_TYPE, "application/json"); in.setHeader(Exchange.HTTP_METHOD, "POST"); }
From source file:com.almende.eve.test.TestProxy.java
/** * Test me.//from w w w .j av a2 s . com */ @Test public void testProxy() { final HttpTransportConfig transportConfig = new HttpTransportConfig(); transportConfig.setServletUrl("http://localhost:8081/agents/"); transportConfig.setServletLauncher("JettyLauncher"); final ObjectNode jettyParms = JOM.createObjectNode(); jettyParms.put("port", 8081); transportConfig.set("jetty", jettyParms); final AgentConfig config = new AgentConfig("example"); config.addTransport(transportConfig); final ExampleAgent agent = new ExampleAgent(); agent.setConfig(config); final ExampleAgentInterface proxy = AgentProxyFactory.genProxy(agent, URIUtil.create("http://localhost:8081/agents/example"), ExampleAgentInterface.class); LOG.warning("Proxy got reply:" + proxy.helloWorld("Hi there")); assertEquals(proxy.helloWorld("Hi there"), "You said:Hi there"); proxy.doSomething(); assertNull(proxy.doMore()); try { Thread.sleep(1000); } catch (InterruptedException e) { } }