@Override public String serialize(List<Session> sessions) { Collection<Session> withoutDuplicates = sessions.stream().collect(Collectors.toMap(Session::getName, Function.identity())).values(); List<JSONObject> objects = withoutDuplicates.stream().map(s -> { final HashMap<String, Object> map = new HashMap<>(); map.put("name", s.getName()); final List<JSONObject> files = s.getFilesToOpen().stream().map(f -> { final HashMap<String, String> map1 = new HashMap<>(); map1.put("uri", f.getUri()); map1.put("level", f.getLevel().getName()); map1.put("openMode", f.getOpenMode().name()); f.getLogImporter().ifPresent(l -> { map1.put("logImporter", l); }); return new JSONObject(map1); }).collect(Collectors.toList()); final JSONObject jsonObject = new JSONObject(map); try { return jsonObject.accumulate("filesToOpen", new JSONArray(files)); } catch (JSONException e) { LOGGER.error("Can't serialize: ", e); } return jsonObject; }).collect(toList()); final String result = new JSONArray(objects).toString(); LOGGER.info("Serialized session: {}", result); return result; } }
private JSONObject getJSONResults(Command cmd, SlingHttpServletRequest request, final Collection<Result> results) throws JSONException { final JSONObject json = new JSONObject(); json.put(KEY_RESULTS, new JSONArray()); final ValueMap requestConfig = new ValueMapDecorator(new HashMap<String, Object>()); // Collect all items collected from OSGi Properties requestConfig.putAll(this.config); // Add Request specific configurations requestConfig.put(AuthoringUIMode.class.getName(), authoringUIModeService.getAuthoringUIMode(request)); for (final Result result : results) { final JSONObject tmp = resultBuilder.toJSON(cmd, result, requestConfig); if (tmp != null) { json.accumulate(KEY_RESULTS, tmp); } } return json; }
json.accumulate("runnerTypes", new JSONObject().put("label", "AEM Workflow").put("value", AEMWorkflowRunnerImpl.class.getName())); json.accumulate("runnerTypes", new JSONObject().put("label", "Synthetic Workflow (Single-threaded)").put("value", SyntheticWorkflowRunnerImpl.class.getName())); json.accumulate("runnerTypes", new JSONObject().put("label", "Synthetic Workflow (Multi-threaded)").put("value", FastActionManagerRunnerImpl.class.getName())); } catch (JSONException e) { json.accumulate("queryTypes", new JSONObject().put("label", "QueryBuilder").put("value", "queryBuilder")); json.accumulate("queryTypes", new JSONObject().put("label", "List").put("value", "list")); json.accumulate("queryTypes", new JSONObject().put("label", "xPath").put("value", "xpath")); json.accumulate("queryTypes", new JSONObject().put("label", "JCR-SQL2").put("value", "JCR-SQL2")); json.accumulate("queryTypes", new JSONObject().put("label", "JCR-SQL").put("value", "JCR-SQL")); } catch (JSONException e) { log.error("Could not create JSON for QueryType options", e); jsonWorkflow.put("value", workflowModel.getId()); jsonWorkflow.put("transient", transientWorkflow); json.accumulate("workflowModels", jsonWorkflow); } catch (JSONException e) { log.error("Could not add workflow [ {} - {} ] to Workflow Models drop-down JSON object",
s = x.nextCDATA(); if (s.length() > 0) { context.accumulate("content", s); throw x.syntaxError("Missing value"); o.accumulate(s, t); t = null; } else { o.accumulate(s, ""); throw x.syntaxError("Misshaped tag"); context.accumulate(n, o); return false; s = (String)t; if (s.length() > 0) { o.accumulate("content", s); if (parse(x, o, n)) { if (o.length() == 0) { context.accumulate(n, ""); } else if (o.length() == 1 && o.opt("content") != null) { context.accumulate(n, o.opt("content")); } else { context.accumulate(n, o);
json.accumulate("workflowModels", jsonWorkflow);
/** * {@inheritDoc} */ public String getPathFilterSetPreviewJSON(final Collection<PathFilterSet> pathFilterSets) throws JSONException { final JSONObject json = new JSONObject(); json.put("status", "preview"); json.put("path", "Not applicable (Preview)"); json.put("filterSets", new JSONArray()); for (final PathFilterSet pathFilterSet : pathFilterSets) { final JSONObject tmp = new JSONObject(); tmp.put("importMode", "Not applicable (Preview)"); tmp.put("rootPath", pathFilterSet.getRoot()); json.accumulate("filterSets", tmp); } return json.toString(); }
failureJSON.put(Failure.PN_PAYLOAD_PATH, failure.getNodePath()); failureJSON.put(Failure.PN_FAILED_AT, sdf.format(failure.getTime().getTime())); json.accumulate("failures", failureJSON); json.accumulate("failures", failure.toJSON()); json.accumulate("activePayloads", payload.toJSON());
/** * {@inheritDoc} */ public String getSuccessJSON(final JcrPackage jcrPackage) throws JSONException, RepositoryException { final JSONObject json = new JSONObject(); json.put("status", "success"); json.put("path", jcrPackage.getNode().getPath()); json.put("filterSets", new JSONArray()); final List<PathFilterSet> filterSets = jcrPackage.getDefinition().getMetaInf().getFilter().getFilterSets(); for (final PathFilterSet filterSet : filterSets) { final JSONObject jsonFilterSet = new JSONObject(); jsonFilterSet.put("importMode", filterSet.getImportMode().name()); jsonFilterSet.put("rootPath", filterSet.getRoot()); json.accumulate("filterSets", jsonFilterSet); } return json.toString(); }
parent.put("padding", 0); parent.put("style", "padding: 0px"); parent.accumulate("items", widget); parent.write(response.getWriter());
parent.put("border", false); parent.put("padding", 0); parent.accumulate("items", widget); parent.write(response.getWriter());