org.codehaus.jackson.node.JsonNodeFactory Java Examples
The following examples show how to use
org.codehaus.jackson.node.JsonNodeFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpMetricsIndexHandler.java From blueflood with Apache License 2.0 | 7 votes |
public static String getSerializedJSON(List<SearchResult> searchResults) { ArrayNode resultArray = JsonNodeFactory.instance.arrayNode(); for (SearchResult result : searchResults) { ObjectNode resultNode = JsonNodeFactory.instance.objectNode(); resultNode.put("metric", result.getMetricName()); String unit = result.getUnit(); if (unit != null) { //Preaggreated metrics do not have units. Do not want to return null units in query results. resultNode.put("unit", unit); } resultArray.add(resultNode); } return resultArray.toString(); }
Example #2
Source File: ClusterResource.java From exhibitor with Apache License 2.0 | 6 votes |
@Path("list") @GET @Produces(MediaType.APPLICATION_JSON) public String getClusterAsJson() throws Exception { InstanceConfig config = context.getExhibitor().getConfigManager().getConfig(); ObjectNode node = JsonNodeFactory.instance.objectNode(); ArrayNode serversNode = JsonNodeFactory.instance.arrayNode(); ServerList serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC)); for ( ServerSpec spec : serverList.getSpecs() ) { serversNode.add(spec.getHostname()); } node.put("servers", serversNode); node.put("port", config.getInt(IntConfigs.CLIENT_PORT)); return JsonUtil.writeValueAsString(node); }
Example #3
Source File: RollupEventSerializer.java From blueflood with Apache License 2.0 | 6 votes |
public static ObjectNode serializeRollupEvent(RollupEvent rollupPayload) throws IOException { //Metadata Node ObjectNode metaNode = JsonNodeFactory.instance.objectNode(); metaNode.put("type", rollupPayload.getRollup().getRollupType().toString()); metaNode.put("unit", rollupPayload.getUnit()); //Create and fill up root node ObjectNode rootNode = JsonNodeFactory.instance.objectNode(); rootNode.put("tenantId", rollupPayload.getLocator().getTenantId()); rootNode.put("metricName", rollupPayload.getLocator().getMetricName()); rootNode.put("gran", rollupPayload.getGranularityName()); rootNode.put("rollup", RollupSerializationHelper.rollupToJson(rollupPayload.getRollup())); rootNode.put("timestamp", rollupPayload.getTimestamp()); rootNode.put("metadata", metaNode); return rootNode; }
Example #4
Source File: RollupSerializationHelper.java From blueflood with Apache License 2.0 | 6 votes |
public static ObjectNode rollupToJson(Rollup rollup) { if (rollup instanceof BluefloodCounterRollup) return handleCounterRollup((BluefloodCounterRollup)rollup); else if (rollup instanceof BluefloodTimerRollup) return handleTimerRollup((BluefloodTimerRollup)rollup); else if (rollup instanceof BluefloodSetRollup) return handleSetRollup((BluefloodSetRollup)rollup); else if (rollup instanceof BluefloodGaugeRollup) return handleGaugeRollup((BluefloodGaugeRollup)rollup); else if (rollup instanceof BasicRollup) return handleBasicRollup((BasicRollup)rollup, JsonNodeFactory.instance.objectNode()); else { log.error("Error encountered while serializing the rollup "+rollup); throw new IOError(new IOException("Cannot serialize the Rollup : "+rollup)); } }
Example #5
Source File: HipChatApiVersion2RoomNotifier.java From rundeck-hipchat-plugin with Apache License 2.0 | 6 votes |
@Override public void sendRoomNotification( final String baseURL, final String room, final String message, final String color, final String authToken, final boolean sendUserNotification) { final ObjectNode requestBody = JsonNodeFactory.instance.objectNode(); requestBody.put("message", message); requestBody.put("color", color); requestBody.put("message_format", "html"); requestBody.put("notify", sendUserNotification); final String urlPath = String.format(HIPCHAT_API_ROOM_NOTIFICATION_URL_PATH, urlEncode(room)); final String urlQueryString = String.format(HIPCHAT_API_ROOM_NOTIFICATION_URL_QUERY, urlEncode(authToken)); final HttpResponse httpResponse = httpRequestExecutor.execute(baseURL + "/" + HIPCHAT_API_VERSION + "/" + urlPath + urlQueryString, requestBody.toString()); if (httpResponse.getResponseCode() != HttpResponse.STATUS__NO_CONTENT) { throw toHipChatNotificationPluginException(httpResponse); } }
Example #6
Source File: JobAccessor.java From helix with Apache License 2.0 | 6 votes |
@GET public Response getJobs(@PathParam("clusterId") String clusterId, @PathParam("workflowName") String workflowName) { TaskDriver driver = getTaskDriver(clusterId); WorkflowConfig workflowConfig = driver.getWorkflowConfig(workflowName); ObjectNode root = JsonNodeFactory.instance.objectNode(); if (workflowConfig == null) { return badRequest(String.format("Workflow %s is not found!", workflowName)); } Set<String> jobs = workflowConfig.getJobDag().getAllNodes(); root.put(Properties.id.name(), JobProperties.Jobs.name()); ArrayNode jobsNode = root.putArray(JobProperties.Jobs.name()); if (jobs != null) { jobsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(jobs)); } return JSONRepresentation(root); }
Example #7
Source File: PerInstanceAccessor.java From helix with Apache License 2.0 | 6 votes |
@GET @Path("healthreports") public Response getHealthReportsOnInstance(@PathParam("clusterId") String clusterId, @PathParam("instanceName") String instanceName) throws IOException { HelixDataAccessor accessor = getDataAccssor(clusterId); ObjectNode root = JsonNodeFactory.instance.objectNode(); root.put(Properties.id.name(), instanceName); ArrayNode healthReportsNode = root.putArray(PerInstanceProperties.healthreports.name()); List<String> healthReports = accessor.getChildNames(accessor.keyBuilder().healthReports(instanceName)); if (healthReports != null && healthReports.size() > 0) { healthReportsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(healthReports)); } return JSONRepresentation(root); }
Example #8
Source File: DependencyGraph.java From Cubert with Apache License 2.0 | 6 votes |
public static void main(String[] args) { DependencyGraph g = new DependencyGraph(); JsonNodeFactory nc = JsonNodeFactory.instance; JsonNode a = nc.numberNode(1); JsonNode b = nc.numberNode(2); JsonNode c = nc.numberNode(3); JsonNode d = nc.numberNode(4); JsonNode e = nc.numberNode(5); JsonNode f = nc.numberNode(6); JsonNode h = nc.numberNode(7); JsonNode i = nc.numberNode(8); g.addNode("input", null, a); g.addNode("loaddict", null, b); g.addNode("second", null, c); g.addNode("encode", Arrays.asList(new String[] { "input", "loaddict" }), d); g.addNode("groupby", Arrays.asList(new String[] { "encode" }), e); g.addNode("filter", Arrays.asList(new String[] { "groupby" }), f); g.addNode("join", Arrays.asList(new String[] { "filter", "second" }), h); g.addNode("shuffle", Arrays.asList(new String[] { "join" }), i); System.out.println(g.getSerialPlan()); }
Example #9
Source File: MetadataResource.java From Eagle with Apache License 2.0 | 6 votes |
@GET @Path(PATH_SERVICE) @Produces(MediaType.APPLICATION_JSON) public Response listAllEntities(@Context Application application, @Context HttpServletRequest request) throws Exception { Map<String,EntityDefinition> entities = EntityDefinitionManager.entities(); ObjectNode root = JsonNodeFactory.instance.objectNode(); ArrayNode services = JsonNodeFactory.instance.arrayNode(); for(Map.Entry<String,EntityDefinition> entry : entities.entrySet()){ // ObjectNode serviceNode = JsonNodeFactory.instance.objectNode(); // serviceNode.put(entry.getKey(),entityDefationitionAsJson(entry.getValue())); services.add(entityDefationitionAsJson(entry.getValue())); } root.put("count",entities.keySet().size()); root.put("services",services); return Response.ok().entity(root).build(); }
Example #10
Source File: ClusterResource.java From exhibitor with Apache License 2.0 | 6 votes |
@Path("state") @GET @Produces(MediaType.APPLICATION_JSON) public String getStatus() throws Exception { ObjectNode mainNode = JsonNodeFactory.instance.objectNode(); ObjectNode switchesNode = JsonNodeFactory.instance.objectNode(); for ( ControlPanelTypes type : ControlPanelTypes.values() ) { switchesNode.put(UIResource.fixName(type), context.getExhibitor().getControlPanelValues().isSet(type)); } mainNode.put("switches", switchesNode); MonitorRunningInstance monitorRunningInstance = context.getExhibitor().getMonitorRunningInstance(); InstanceStateTypes state = monitorRunningInstance.getCurrentInstanceState(); mainNode.put("state", state.getCode()); mainNode.put("description", state.getDescription()); mainNode.put("isLeader", monitorRunningInstance.isCurrentlyLeader()); return JsonUtil.writeValueAsString(mainNode); }
Example #11
Source File: WorkflowAccessor.java From helix with Apache License 2.0 | 5 votes |
@GET @Path("{workflowId}/configs") public Response getWorkflowConfig(@PathParam("clusterId") String clusterId, @PathParam("workflowId") String workflowId) { TaskDriver taskDriver = getTaskDriver(clusterId); WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId); ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode(); if (workflowConfig != null) { getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord()); } return JSONRepresentation(workflowConfigNode); }
Example #12
Source File: RollupSerializationHelper.java From blueflood with Apache License 2.0 | 5 votes |
private static ObjectNode handleCounterRollup(BluefloodCounterRollup rollup) { ObjectNode rollupNode = JsonNodeFactory.instance.objectNode(); rollupNode.put("count", (rollup.getCount() instanceof Float || rollup.getCount() instanceof Double) ? rollup.getCount().doubleValue() : rollup.getCount().longValue()); rollupNode.put("sampleCount", rollup.getSampleCount()); rollupNode.put("rate", rollup.getRate()); return rollupNode; }
Example #13
Source File: RollupSerializationHelper.java From blueflood with Apache License 2.0 | 5 votes |
private static ObjectNode handleTimerRollup(BluefloodTimerRollup rollup) { ObjectNode rollupNode = JsonNodeFactory.instance.objectNode(); rollupNode.put("sum", rollup.getSum()); rollupNode.put("rate", rollup.getRate()); rollupNode.put("sampleCount", rollup.getSampleCount()); return handleBaseRollup(rollup, rollupNode); }
Example #14
Source File: IndexerDefinitionsMessageBodyWriter.java From hbase-indexer with Apache License 2.0 | 5 votes |
@Override public void writeTo(Collection<IndexerDefinition> indices, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream outputStream) throws IOException, WebApplicationException { ArrayNode array = JsonNodeFactory.instance.arrayNode(); IndexerDefinitionJsonSerDeser converter = IndexerDefinitionJsonSerDeser.INSTANCE; for (IndexerDefinition index : indices) { array.add(converter.toJson(index)); } ObjectMapper objectMapper = new ObjectMapper(); IOUtils.write(objectMapper.writeValueAsBytes(array), outputStream); }
Example #15
Source File: UIResource.java From exhibitor with Apache License 2.0 | 5 votes |
@Path("backup-config") @GET @Produces(MediaType.APPLICATION_JSON) public String getBackupConfig() throws Exception { ArrayNode node = JsonNodeFactory.instance.arrayNode(); if ( context.getExhibitor().getBackupManager().isActive() ) { EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser(); List<BackupConfigSpec> configs = context.getExhibitor().getBackupManager().getConfigSpecs(); for ( BackupConfigSpec c : configs ) { ObjectNode n = JsonNodeFactory.instance.objectNode(); String value = parser.getValue(c.getKey()); n.put("key", c.getKey()); n.put("name", c.getDisplayName()); n.put("help", c.getHelpText()); n.put("value", (value != null) ? value : ""); n.put("type", c.getType().name().toLowerCase().substring(0, 1)); node.add(n); } } return JsonUtil.writeValueAsString(node); }
Example #16
Source File: WorkflowAccessor.java From helix with Apache License 2.0 | 5 votes |
private void getWorkflowContextNode(ObjectNode workflowContextNode, ZNRecord record) { if (record.getMapFields() != null) { for (String fieldName : record.getMapFields().keySet()) { JsonNode node = OBJECT_MAPPER.valueToTree(record.getMapField(fieldName)); workflowContextNode.put(fieldName, node); } } if (record.getSimpleFields() != null) { for (Map.Entry<String, String> entry : record.getSimpleFields().entrySet()) { workflowContextNode .put(entry.getKey(), JsonNodeFactory.instance.textNode(entry.getValue())); } } }
Example #17
Source File: WorkflowAccessor.java From helix with Apache License 2.0 | 5 votes |
private void getWorkflowConfigNode(ObjectNode workflowConfigNode, ZNRecord record) { for (Map.Entry<String, String> entry : record.getSimpleFields().entrySet()) { if (!entry.getKey().equals(WorkflowConfig.WorkflowConfigProperty.Dag)) { workflowConfigNode.put(entry.getKey(), JsonNodeFactory.instance.textNode(entry.getValue())); } } }
Example #18
Source File: WorkflowAccessor.java From helix with Apache License 2.0 | 5 votes |
@GET @Path("{workflowId}/context") public Response getWorkflowContext(@PathParam("clusterId") String clusterId, @PathParam("workflowId") String workflowId) { TaskDriver taskDriver = getTaskDriver(clusterId); WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId); ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode(); if (workflowContext != null) { getWorkflowContextNode(workflowContextNode, workflowContext.getRecord()); } return JSONRepresentation(workflowContextNode); }
Example #19
Source File: MetadataResource.java From Eagle with Apache License 2.0 | 5 votes |
private void addTo( ObjectNode resourceNode, String uriPrefix, AbstractResourceMethod srm, String path ){ if(resourceNode.get( uriPrefix ) == null){ ObjectNode inner = JsonNodeFactory.instance.objectNode(); inner.put("path", path); inner.put("methods", JsonNodeFactory.instance.arrayNode()); resourceNode.put( uriPrefix, inner ); } ((ArrayNode) resourceNode.get( uriPrefix ).get("methods")).add( srm.getHttpMethod() ); }
Example #20
Source File: WorkflowAccessor.java From helix with Apache License 2.0 | 5 votes |
@GET @Path("{workflowId}") public Response getWorkflow(@PathParam("clusterId") String clusterId, @PathParam("workflowId") String workflowId) { TaskDriver taskDriver = getTaskDriver(clusterId); WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId); WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId); ObjectNode root = JsonNodeFactory.instance.objectNode(); TextNode id = JsonNodeFactory.instance.textNode(workflowId); root.put(Properties.id.name(), id); ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode(); ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode(); if (workflowConfig != null) { getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord()); } if (workflowContext != null) { getWorkflowContextNode(workflowContextNode, workflowContext.getRecord()); } root.put(WorkflowProperties.WorkflowConfig.name(), workflowConfigNode); root.put(WorkflowProperties.WorkflowContext.name(), workflowContextNode); JobDag jobDag = workflowConfig.getJobDag(); ArrayNode jobs = OBJECT_MAPPER.valueToTree(jobDag.getAllNodes()); ObjectNode parentJobs = OBJECT_MAPPER.valueToTree(jobDag.getChildrenToParents()); root.put(WorkflowProperties.Jobs.name(), jobs); root.put(WorkflowProperties.ParentJobs.name(), parentJobs); root.put(WorkflowProperties.LastScheduledTask.name(), OBJECT_MAPPER.valueToTree(taskDriver.getLastScheduledTaskExecutionInfo(workflowId))); return JSONRepresentation(root); }
Example #21
Source File: ExplorerResource.java From exhibitor with Apache License 2.0 | 5 votes |
@GET @Path("node-data") @Produces("application/json") public String getNodeData(@QueryParam("key") String key) throws Exception { ObjectNode node = JsonNodeFactory.instance.objectNode(); try { Stat stat = context.getExhibitor().getLocalConnection().checkExists().forPath(key); byte[] bytes = context.getExhibitor().getLocalConnection().getData().storingStatIn(stat).forPath(key); if (bytes != null) { node.put("bytes", bytesToString(bytes)); node.put("str", new String(bytes, "UTF-8")); } else { node.put("bytes", ""); node.put("str", ""); } node.put("stat", reflectToString(stat)); } catch ( KeeperException.NoNodeException dummy ) { node.put("bytes", ""); node.put("str", ""); node.put("stat", "* not found * "); } catch ( Throwable e ) { node.put("bytes", ""); node.put("str", "Exception"); node.put("stat", e.getMessage()); } return node.toString(); }
Example #22
Source File: BaseTO.java From big-data-lite with MIT License | 5 votes |
public BaseTO() { super(); if (factory == null) { factory = JsonNodeFactory.instance; jsonMapper = new ObjectMapper(); }// EOF if }
Example #23
Source File: PerInstanceAccessor.java From helix with Apache License 2.0 | 5 votes |
@GET @Path("errors") public Response getErrorsOnInstance(@PathParam("clusterId") String clusterId, @PathParam("instanceName") String instanceName) throws IOException { HelixDataAccessor accessor = getDataAccssor(clusterId); ObjectNode root = JsonNodeFactory.instance.objectNode(); root.put(Properties.id.name(), instanceName); ObjectNode errorsNode = JsonNodeFactory.instance.objectNode(); List<String> sessionIds = accessor.getChildNames(accessor.keyBuilder().errors(instanceName)); if (sessionIds == null || sessionIds.size() == 0) { return notFound(); } for (String sessionId : sessionIds) { List<String> resources = accessor.getChildNames(accessor.keyBuilder().errors(instanceName, sessionId)); if (resources != null) { ObjectNode resourcesNode = JsonNodeFactory.instance.objectNode(); for (String resourceName : resources) { List<String> partitions = accessor .getChildNames(accessor.keyBuilder().errors(instanceName, sessionId, resourceName)); if (partitions != null) { ArrayNode partitionsNode = resourcesNode.putArray(resourceName); partitionsNode.addAll((ArrayNode) OBJECT_MAPPER.valueToTree(partitions)); } } errorsNode.put(sessionId, resourcesNode); } } root.put(PerInstanceProperties.errors.name(), errorsNode); return JSONRepresentation(root); }
Example #24
Source File: JsonElementConversionFactory.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private Schema buildRecordSchema(JsonSchema schema, WorkUnitState workUnit, String name, String namespace) { List<Schema.Field> fields = new ArrayList<>(); for (int i = 0; i < schema.fieldsCount(); i++) { JsonSchema map = schema.getFieldSchemaAt(i); String childNamespace = buildNamespace(namespace, name); JsonElementConverter converter; String sourceType; Schema fldSchema; try { sourceType = map.isType(UNION) ? UNION.toString().toLowerCase() : map.getType().toString().toLowerCase(); converter = getConvertor(map, childNamespace, workUnit); this.converters.put(map.getColumnName(), converter); fldSchema = converter.schema(); } catch (UnsupportedDateTypeException e) { throw new UnsupportedOperationException(e); } Schema.Field fld = new Schema.Field(map.getColumnName(), fldSchema, map.getComment(), map.isNullable() ? JsonNodeFactory.instance.nullNode() : null); fld.addProp(SOURCE_TYPE, sourceType); fields.add(fld); } Schema avroSchema = Schema.createRecord(name.isEmpty() ? null : name, "", namespace, false); avroSchema.setFields(fields); return avroSchema; }
Example #25
Source File: TestHashJoinOperator.java From Cubert with Apache License 2.0 | 5 votes |
public HashJoinOperator createHashJoinOperator(BlockSchema lSchema, BlockSchema rSchema, BlockSchema operatorSchema, TupleStore lStore, TupleStore rStore) throws IOException, InterruptedException { /* Create Blocks */ final Block lBlock = new TupleStoreBlock(lStore, new BlockProperties(lBlockName, lSchema, (BlockProperties) null)); final Block rBlock = new TupleStoreBlock(rStore, new BlockProperties(rBlockName, rSchema, (BlockProperties) null)); /* Perform the Hash Join */ Map<String, Block> input = new HashMap<String, Block>(); input.put(lBlockName, lBlock); input.put(rBlockName, rBlock); ObjectNode root = new ObjectNode(JsonNodeFactory.instance); root.put("leftBlock", lBlockName); root.put("rightBlock", rBlockName); final ArrayNode joinKeys = new ArrayNode(JsonNodeFactory.instance); joinKeys.add("Integer"); root.put("leftJoinKeys", joinKeys); root.put("rightJoinKeys", joinKeys); BlockProperties props = new BlockProperties("Joined", operatorSchema, (BlockProperties) null); HashJoinOperator operator = new HashJoinOperator(); operator.setInput(input, root, props); return operator; }
Example #26
Source File: MetadataResource.java From Eagle with Apache License 2.0 | 5 votes |
@GET @Produces(MediaType.APPLICATION_JSON) public Response index(@Context Application application, @Context HttpServletRequest request){ String basePath = request.getRequestURL().toString(); ObjectNode root = JsonNodeFactory.instance.objectNode(); root.put(PATH_RESOURCE,joinUri(basePath,PATH_RESOURCE)); root.put(PATH_SERVICE,joinUri(basePath,PATH_SERVICE)); return Response.ok().entity(root).build(); }
Example #27
Source File: MetadataResource.java From Eagle with Apache License 2.0 | 5 votes |
private ArrayNode arrayNode(String[] values){ ArrayNode an = JsonNodeFactory.instance.arrayNode(); for(String v:values){ an.add(v); } return an; }
Example #28
Source File: MetadataResource.java From Eagle with Apache License 2.0 | 5 votes |
private JsonNode entityDefationitionAsJson(EntityDefinition def) { ObjectNode node = JsonNodeFactory.instance.objectNode(); node.put("service",def.getService()); node.put("entityClass",def.getEntityClass().getName()); node.put("table",def.getTable()); node.put("columnFamily",def.getColumnFamily()); node.put("prefix",def.getPrefix()); if(def.getPartitions()!=null){ node.put("partitions",arrayNode(def.getPartitions())); } node.put("isTimeSeries",def.isTimeSeries()); MetricDefinition mdf = def.getMetricDefinition(); if(mdf!=null){ node.put("interval", mdf.getInterval()); } IndexDefinition[] indexDef = def.getIndexes(); if(indexDef!=null){ ArrayNode indexDefArray = JsonNodeFactory.instance.arrayNode(); for(IndexDefinition idef : indexDef){ ObjectNode idn = JsonNodeFactory.instance.objectNode(); idn.put("indexPrefix",idef.getIndexPrefix()); if(idef.getIndex()!=null){ ObjectNode index = JsonNodeFactory.instance.objectNode(); index.put("name",idef.getIndex().name()); index.put("columns",arrayNode(idef.getIndex().columns())); idn.put("index",index); } indexDefArray.add(idn); } node.put("indexs",indexDefArray); } return node; }
Example #29
Source File: PerInstanceAccessor.java From helix with Apache License 2.0 | 4 votes |
@GET @Path("messages") public Response getMessagesOnInstance(@PathParam("clusterId") String clusterId, @PathParam("instanceName") String instanceName, @QueryParam("stateModelDef") String stateModelDef) { HelixDataAccessor accessor = getDataAccssor(clusterId); ObjectNode root = JsonNodeFactory.instance.objectNode(); root.put(Properties.id.name(), instanceName); ArrayNode newMessages = root.putArray(PerInstanceProperties.new_messages.name()); ArrayNode readMessages = root.putArray(PerInstanceProperties.read_messages.name()); List<String> messageNames = accessor.getChildNames(accessor.keyBuilder().messages(instanceName)); if (messageNames == null || messageNames.size() == 0) { LOG.warn("Unable to get any messages on instance: " + instanceName); return notFound(); } for (String messageName : messageNames) { Message message = accessor.getProperty(accessor.keyBuilder().message(instanceName, messageName)); if (message == null) { LOG.warn("Message is deleted given message name: ", messageName); continue; } // if stateModelDef is valid, keep messages with StateModelDef equals to the parameter if (StringUtil.isNotBlank(stateModelDef) && !stateModelDef.equals(message.getStateModelDef())) { continue; } if (Message.MessageState.NEW.equals(message.getMsgState())) { newMessages.add(messageName); } else if (Message.MessageState.READ.equals(message.getMsgState())) { readMessages.add(messageName); } } root.put(PerInstanceProperties.total_message_count.name(), newMessages.size() + readMessages.size()); root.put(PerInstanceProperties.read_message_count.name(), readMessages.size()); return JSONRepresentation(root); }
Example #30
Source File: RewriteUtils.java From Cubert with Apache License 2.0 | 4 votes |
public static ObjectNode createDoubleConstant(Double value) { return createFunctionNode("CONSTANT", JsonNodeFactory.instance.numberNode(value.doubleValue())); }