List of usage examples for com.fasterxml.jackson.databind.node ObjectNode toString
public String toString()
From source file:io.confluent.connect.elasticsearch.Mapping.java
/** * Create an explicit mapping./* w w w . j a va2 s .com*/ * @param client The client to connect to Elasticsearch. * @param index The index to write to Elasticsearch. * @param type The type to create mapping for. * @param schema The schema used to infer mapping. * @throws IOException */ public static void createMapping(JestClient client, String index, String type, Schema schema) throws IOException { ObjectNode obj = JsonNodeFactory.instance.objectNode(); obj.set(type, inferMapping(schema)); PutMapping putMapping = new PutMapping.Builder(index, type, obj.toString()).build(); JestResult result = client.execute(putMapping); if (!result.isSucceeded()) { throw new ConnectException("Cannot create mapping " + obj + " -- " + result.getErrorMessage()); } }
From source file:api.Status.java
public static Result getMeta() { ObjectNode meta = Json.newObject(); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); meta.put("osName", os.getName()); meta.put("osVersion", os.getVersion()); meta.put("arch", os.getArch()); meta.put("cpus", os.getAvailableProcessors()); return ok(meta.toString()); }
From source file:com.github.khazrak.jdocker.utils.Filters.java
public static String encodeFilters(Map<String, String> filters) { ObjectMapper mapper = new ObjectMapper(); String result = null;/* w w w . j av a 2 s. c om*/ ObjectNode objectNode = mapper.createObjectNode(); if (!filters.keySet().isEmpty()) { for (Map.Entry<String, String> s : filters.entrySet()) { objectNode.putObject(s.getKey()).put(s.getValue(), true); } } try { result = URLEncoder.encode(objectNode.toString(), StandardCharsets.UTF_8.toString()); } catch (UnsupportedEncodingException e) { logger.error("Error encoding filtersMap", e); } return result; }
From source file:com.redhat.lightblue.query.PrimitiveUpdateExpression.java
/** * Parses a primitive expression using the given json object *//* w ww . j a va 2s. c om*/ public static PrimitiveUpdateExpression fromJson(ObjectNode node) { if (node.has(UpdateOperator._add.toString()) || node.has(UpdateOperator._set.toString())) { return SetExpression.fromJson(node); } else if (node.has(UpdateOperator._unset.toString())) { return UnsetExpression.fromJson(node); } else { throw Error.get(QueryConstants.ERR_INVALID_UPDATE_EXPRESSION, node.toString()); } }
From source file:com.redhat.lightblue.query.ArrayComparisonExpression.java
/** * Parses an array contains or array match expression from the given object * node//from w w w .j a va 2 s.c om */ public static ArrayComparisonExpression fromJson(ObjectNode node) { JsonNode x = node.get("contains"); if (x != null) { return ArrayContainsExpression.fromJson(node); } else { x = node.get("elemMatch"); if (x != null) { return ArrayMatchExpression.fromJson(node); } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); }
From source file:com.redhat.lightblue.query.ArrayUpdateExpression.java
/** * Parses an array update expression using the given json object *///from w ww . j a va 2s . c o m public static ArrayUpdateExpression fromJson(ObjectNode node) { if (node.has(UpdateOperator._append.toString()) || node.has(UpdateOperator._insert.toString())) { return ArrayAddExpression.fromJson(node); } else if (node.has(UpdateOperator._foreach.toString())) { return ForEachExpression.fromJson(node); } else { throw Error.get(QueryConstants.ERR_INVALID_ARRAY_UPDATE_EXPRESSION, node.toString()); } }
From source file:com.redhat.lightblue.query.NaryRelationalExpression.java
/** * Parses an n-ary relational expression from the given json object *///from ww w . j a v a 2s .c o m public static NaryRelationalExpression fromJson(ObjectNode node) { if (node.size() == 3) { if (node.get("rfield") != null) { return NaryFieldRelationalExpression.fromJson(node); } else if (node.get("values") != null) { return NaryValueRelationalExpression.fromJson(node); } } throw Error.get(QueryConstants.ERR_INVALID_COMPARISON_EXPRESSION, node.toString()); }
From source file:com.redhat.lightblue.query.ArrayMatchExpression.java
/** * Parses an array match expression from the given json object *//*from ww w . j av a 2 s. c o m*/ public static ArrayMatchExpression fromJson(ObjectNode node) { JsonNode x = node.get("array"); if (x != null) { Path field = new Path(x.asText()); x = node.get("elemMatch"); if (x != null) { return new ArrayMatchExpression(field, QueryExpression.fromJson(x)); } } throw Error.get(QueryConstants.ERR_INVALID_ARRAY_COMPARISON_EXPRESSION, node.toString()); }
From source file:org.apache.asterix.api.http.server.ResultUtil.java
public static void apiErrorHandler(PrintWriter out, Exception e) { int errorCode = 99; if (e instanceof ParseException) { errorCode = 2;//from ww w . ja v a 2 s . c o m } else if (e instanceof AlgebricksException) { errorCode = 3; } else if (e instanceof HyracksDataException) { errorCode = 4; } ObjectNode errorResp = ResultUtil.getErrorResponse(errorCode, extractErrorMessage(e), extractErrorSummary(e), extractFullStackTrace(e)); out.write(errorResp.toString()); }
From source file:org.flowable.cmmn.engine.impl.task.TaskHelper.java
public static void logUserTaskCompleted(TaskEntity taskEntity) { TaskServiceConfiguration taskServiceConfiguration = CommandContextUtil.getTaskServiceConfiguration(); if (taskServiceConfiguration.isEnableHistoricTaskLogging()) { BaseHistoricTaskLogEntryBuilderImpl taskLogEntryBuilder = new BaseHistoricTaskLogEntryBuilderImpl( taskEntity);//from w ww . j a va 2 s . c om ObjectNode data = taskServiceConfiguration.getObjectMapper().createObjectNode(); taskLogEntryBuilder.timeStamp(taskServiceConfiguration.getClock().getCurrentTime()); taskLogEntryBuilder.userId(Authentication.getAuthenticatedUserId()); taskLogEntryBuilder.data(data.toString()); taskLogEntryBuilder.type(HistoricTaskLogEntryType.USER_TASK_COMPLETED.name()); taskServiceConfiguration.getInternalHistoryTaskManager().recordHistoryUserTaskLog(taskLogEntryBuilder); } }