private StringBuffer dumpAllToString() { StringBuffer buffer = new StringBuffer(); for(String k : allNotifications.keySet()) { JsonObject o = allNotifications.get(k); String json = JsonUtils.toString(o); buffer.append(json); buffer.append("\n"); } return buffer; } }
/** * @return */ public String toJson() { if (entry == null) { return null; } return JsonUtils.toString(entry.get()); } }
@Override public void doOperation(JsonObject params, Consumer<IOperationResult> resultHandler, Consumer<Throwable> exHandler) { final SingleResult sr = new SingleResult(); final Serializable sessionId = UUID.randomUUID().toString(); sr.addMetaData("session_id", sessionId); final OperationData operationData = new OperationData(); sr.setData(operationData); JsonObject account = new JsonObject(); account.addProperty("login", "lorenzo@nexitia.com"); account.addProperty("nickName", "lorenzo"); final JsonObject user = new JsonObject(); user.addProperty("nickName", "lorenzo"); account.addProperty("mail", "lorenzo@nexitia.com"); final JsonObject container = new JsonObject(); container.addProperty("fullId", "1:people"); container.addProperty("path", "/"); operationData.getLinks().put("container", JsonUtils.toString(container)); operationData.getLinks().put("account", JsonUtils.toString(account)); operationData.getLinks().put("user", JsonUtils.toString(user)); resultHandler.accept(sr); } }
/** * @{inheritedDoc} */ @Override public void create(INotification notification, OperationCallback callback) { // can only create local notifications if (notification.getType() == NotificationType.LOCAL) { if (offlineSaveOperation == null) { String message = "can.not.find.service"; callback.onError(new NullPointerException(message)); return; } try { String notif = JsonUtils.toString(notification); JsonObject query = new JsonObject(); query.addProperty("notification", notif); query.addProperty("date", DateUtils.dateString(notification.getCreationDate(), DateUtils.FILE_SAVE_FORMAT)); offlineSaveOperation.doOperation(query, callback.getOnSuccess(), callback.getOnError()); } catch (Exception e) { e.printStackTrace(); callback.onError(e); } } else { String message = "unsupported.notification.type"; callback.onError(new IllegalArgumentException(message)); } }
RequestBody body = RequestBody.create(JSON, JsonUtils.toString(query)); Request request = new Request.Builder() .url(url)
RequestBody body = RequestBody.create(JSON, JsonUtils.toString(query)); Request request = null;