@Override public void save(StageStatus status) { Preferences node = Preferences.userRoot().node(STAGE_PATH); try { node.put(STAGE_STATUS_KEY, JSON.std.asString(status)); LOG.trace("Stage status saved {}", status); } catch (IOException e) { LOG.error("Unable to increment modules usage statistics", e); } }
public void incrementUsageFor(String moduleId) { Preferences node = Preferences.userRoot().node(USAGE_PATH).node(moduleId); String json = node.get(MODULE_USAGE_KEY, ""); try { if (isNotBlank(json)) { node.put(MODULE_USAGE_KEY, JSON.std.asString(JSON.std.beanFrom(ModuleUsage.class, json).inc())); } else { node.put(MODULE_USAGE_KEY, JSON.std.asString(ModuleUsage.fistUsage(moduleId))); } LOG.trace("Usage incremented for module {}", moduleId); } catch (IOException e) { LOG.error("Unable to increment modules usage statistics", e); } finally { incrementTotalUsage(); } }
@Override public String _writeAsString(MeasurementPOJO items) throws Exception { return json.asString(items); } }
public static String formatGraphQLRequest(String definition, Map<String, Object> variables) { String json = null; Map<String, Object> map = new TreeMap<String, Object>(); map.put("query", definition); map.put("variables", variables); try { json = JSON.std.asString(map); } catch (IOException e) { throw new AssertionError("An IOException occurred when writing JSON object."); } return json; }
public static String formatGraphQLRequest(String definition, Map<String, Object> variables) { String json = null; Map<String, Object> map = new TreeMap<String, Object>(); map.put("query", definition); map.put("variables", variables); try { json = JSON.std.asString(map); } catch (IOException e) { throw new AssertionError("An IOException occurred when writing JSON object."); } return json; }
public static String formatGraphQLRequest(String definition, Map<String, Object> variables) { String json = null; Map<String, Object> map = new TreeMap<String, Object>(); map.put("query", definition); map.put("variables", variables); try { json = JSON.std.asString(map); } catch (IOException e) { throw new AssertionError("An IOException occurred when writing JSON object."); } return json; }
public void convert(String message, StringBuilder appendTo) { if (message != null) { String result; if (flatten) { result = flattenMsg(message); } else { result = message; } if (escape) { try { appendTo.append(JSON.std.asString(result)); } catch (Exception ex) { /* -- avoids substitute logger warnings on startup -- */ LoggerFactory.getLogger(DefaultMessageConverter.class).error("Conversion failed ", ex); appendTo.append(result); } } else { appendTo.append(result); } } else { appendTo.append("null"); } }
public void convert(String message, StringBuilder appendTo) { if (message != null) { String result; if (flatten) { result = flattenMsg(message); } else { result = message; } if (escape) { try { appendTo.append(JSON.std.asString(result)); } catch (Exception ex) { /* -- avoids substitute logger warnings on startup -- */ LoggerFactory.getLogger(DefaultMessageConverter.class).error("Conversion failed ", ex); appendTo.append(result); } } else { appendTo.append(result); } } else { appendTo.append("null"); } }
public void convert(Object[] arguments, StringBuilder appendTo) { List<CustomField> customFields = getCustomFields(arguments); if (!customFields.isEmpty()) { try { if (!embed) { appendTo.append(JSON.std.asString(fieldName)).append(":"); } /* * -- no matter whether we embed or not, it seems easier to * compose -- a JSON object from the key/value pairs. -- if we * embed that object, we simply chop off the outermost curly * braces. */ ObjectComposer<JSONComposer<String>> oc = JSON.std.composeString().startObject(); for (CustomField cf: customFields) { oc.putObject(cf.getKey(), cf.getValue()); } String result = oc.end().finish().trim(); if (embed) { /* -- chop off curly braces -- */ appendTo.append(result.substring(1, result.length() - 1)); } else { appendTo.append(result); } } catch (Exception ex) { /* -- avoids substitute logger warnings on startup -- */ LoggerFactory.getLogger(DefaultArgsConverter.class).error("Conversion failed ", ex); } } }
public void convert(Object[] arguments, StringBuilder appendTo) { List<CustomField> customFields = getCustomFields(arguments); if (!customFields.isEmpty()) { try { if (!embed) { appendTo.append(JSON.std.asString(fieldName)).append(":"); } /* * -- no matter whether we embed or not, it seems easier to * compose -- a JSON object from the key/value pairs. -- if we * embed that object, we simply chop off the outermost curly * braces. */ ObjectComposer<JSONComposer<String>> oc = JSON.std.composeString().startObject(); for (CustomField cf: customFields) { oc.putObject(cf.getKey(), cf.getValue()); } String result = oc.end().finish().trim(); if (embed) { /* -- chop off curly braces -- */ appendTo.append(result.substring(1, result.length() - 1)); } else { appendTo.append(result); } } catch (Exception ex) { /* -- avoids substitute logger warnings on startup -- */ LoggerFactory.getLogger(DefaultArgsConverter.class).error("Conversion failed ", ex); } } }