@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(Components.objectName(this)) .append(" ["); if (request().method() != null) { builder.append("method=") .append(request().method()) .append(", "); } if (request().id().isPresent()) { builder.append("id=") .append(request().id().get()); } if (channels() != null) { builder.append("channels=") .append(Channel.toString(channels())); } builder.append(']'); return builder.toString(); } }
/** * Creates a JSON notification from the given data. * Closes the `writer`. * * @param writer the writer * @throws IOException */ protected void toJson(Writer writer, String method, Object... params) throws IOException { JsonRpc rpc = JsonRpc.create(); rpc.setMethod(method); if (params.length > 0) { for (Object obj : params) { rpc.addParam(obj); } } JsonBeanEncoder.create(writer).writeObject(rpc).flush(); } }
/** * Handle JSON input. * * @param event the event * @param channel the channel * @throws InterruptedException the interrupted exception * @throws IOException Signals that an I/O exception has occurred. */ @SuppressWarnings("PMD.DataflowAnomalyAnalysis") @Handler(channels = PortalChannel.class) public void onJsonInput(JsonInput event, PortalSession channel) throws InterruptedException, IOException { // Send events to portlets on portal's channel JsonArray params = event.request().params(); switch (event.request().method()) { // NOPMD case "setTheme": { fire(new SetTheme(params.asString(0)), channel); break; } default: // Ignore unknown break; } }
/** * Creates a JSON notification from the given data. * Closes the `writer`. * * @param writer the writer * @throws IOException */ protected void toJson(Writer writer, String method, Object... params) throws IOException { JsonRpc rpc = JsonRpc.create(); rpc.setMethod(method); if (params.length > 0) { for (Object obj : params) { rpc.addParam(obj); } } JsonBeanEncoder.create(writer).writeObject(rpc).flush(); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(Components.objectName(this)) .append(" ["); if (request().method() != null) { builder.append("method=") .append(request().method()) .append(", "); } if (request().id().isPresent()) { builder.append("id=") .append(request().id().get()); } if (channels() != null) { builder.append("channels=") .append(Channel.toString(channels())); } builder.append(']'); return builder.toString(); } }
public void onJsonInput(JsonInput event, PortalSession channel) throws InterruptedException, IOException { if (!event.request().method().equals("retrievedLocalData")) { return; JsonArray params = (JsonArray) event.request().params(); params.asArray(0).arrayStream().forEach(item -> { String key = item.asString(0);
public void onJsonInput(JsonInput event, PortalSession channel) throws InterruptedException, IOException { if (!event.request().method().equals("retrievedLocalData")) { return; @SuppressWarnings("PMD.DataflowAnomalyAnalysis") Store data = getStore(channel); JsonArray params = (JsonArray) event.request().params(); params.asArray(0).arrayStream().forEach(item -> { String key = item.asString(0);