List of usage examples for com.fasterxml.jackson.databind.node JsonNodeFactory instance
JsonNodeFactory instance
To view the source code for com.fasterxml.jackson.databind.node JsonNodeFactory instance.
Click Source Link
From source file:org.apache.usergrid.java.client.model.UsergridEntity.java
public void putProperty(@NotNull final String name, final int value) { this.putProperty(name, JsonNodeFactory.instance.numberNode(value)); }
From source file:org.apache.usergrid.java.client.model.UsergridEntity.java
public void putProperty(@NotNull final String name, final long value) { this.putProperty(name, JsonNodeFactory.instance.numberNode(value)); }
From source file:org.jetbrains.webdemo.sessions.MyHttpSession.java
private void sendAddProjectResult() { try {/*w w w . j a v a2 s.c o m*/ String content = request.getParameter("content"); if (content != null) { try { currentProject = objectMapper.readValue(content, Project.class); currentProject.name = request.getParameter("args"); //when user calls save as we must change project name ExamplesUtils.addHiddenFilesToProject(currentProject); String publicId = MySqlConnector.getInstance().addProject(sessionInfo.getUserInfo(), currentProject, "USER_PROJECT"); ObjectNode result = new ObjectNode(JsonNodeFactory.instance); result.put("publicId", publicId); Project project = MySqlConnector.getInstance().getProjectContent(publicId); result.put("content", objectMapper.writeValueAsString(project)); writeResponse(result.toString(), HttpServletResponse.SC_OK); } catch (IOException e) { writeResponse("Can't parse file", HttpServletResponse.SC_BAD_REQUEST); } } else { String name = request.getParameter("name"); String publicIds = MySqlConnector.getInstance().addProject(sessionInfo.getUserInfo(), name, "USER_PROJECT"); writeResponse(publicIds, HttpServletResponse.SC_OK); } } catch (NullPointerException e) { writeResponse("Can't get parameters", HttpServletResponse.SC_BAD_REQUEST); } catch (DatabaseOperationException e) { writeResponse(e.getMessage(), HttpServletResponse.SC_FORBIDDEN); } }
From source file:org.attribyte.api.pubsub.impl.server.BroadcastServlet.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { long startNanos = System.nanoTime(); byte[] broadcastContent = ByteStreams.toByteArray(request.getInputStream()); long endNanos = System.nanoTime(); String topicURL = request.getPathInfo(); if (maxBodyBytes > 0 && broadcastContent.length > maxBodyBytes) { logNotification(request, topicURL, NOTIFICATION_TOO_LARGE.statusCode, null); Bridge.sendServletResponse(NOTIFICATION_TOO_LARGE, response); return;/* ww w . j a v a 2s.c o m*/ } Response endpointResponse; if (topicURL != null) { if (filters.size() > 0) { String checkHeader = request.getHeader(BasicAuthScheme.AUTH_HEADER); for (BasicAuthFilter filter : filters) { if (filter.reject(topicURL, checkHeader)) { logNotification(request, topicURL, Response.Code.UNAUTHORIZED, broadcastContent); response.sendError(Response.Code.UNAUTHORIZED, "Unauthorized"); return; } } } try { Topic topic = topicCache != null ? topicCache.getIfPresent(topicURL) : null; if (topic == null) { topic = datastore.getTopic(topicURL, autocreateTopics); if (topicCache != null && topic != null) { topicCache.put(topicURL, topic); } } if (topic != null) { NotificationMetrics globalMetrics = endpoint.getGlobalNotificationMetrics(); NotificationMetrics metrics = endpoint.getNotificationMetrics(topic.getId()); metrics.notificationSize.update(broadcastContent.length); globalMetrics.notificationSize.update(broadcastContent.length); long acceptTimeNanos = endNanos - startNanos; metrics.notifications.update(acceptTimeNanos, TimeUnit.NANOSECONDS); globalMetrics.notifications.update(acceptTimeNanos, TimeUnit.NANOSECONDS); Notification notification = new Notification(topic, null, broadcastContent); //No custom headers... final boolean queued = endpoint.enqueueNotification(notification); if (queued) { if (replicationTopic != null) { final boolean replicationQueued = endpoint .enqueueNotification(new Notification(replicationTopic, Collections.singleton( new Header(REPLICATION_TOPIC_HEADER, topic.getURL())), broadcastContent)); if (!replicationQueued) { //What to do? logger.error("Replication failure due to notification capacity limits!"); } } if (!jsonEnabled) { endpointResponse = ACCEPTED_RESPONSE; } else { ResponseBuilder builder = new ResponseBuilder(); builder.setStatusCode(ACCEPTED_RESPONSE.statusCode); builder.addHeader("Content-Type", ServerUtil.JSON_CONTENT_TYPE); ObjectNode responseNode = JsonNodeFactory.instance.objectNode(); ArrayNode idsNode = responseNode.putArray("messageIds"); idsNode.add(Long.toString(notification.getCreateTimestampMicros())); builder.setBody(responseNode.toString().getBytes(Charsets.UTF_8)); endpointResponse = builder.create(); } } else { endpointResponse = CAPACITY_ERROR_RESPONSE; } } else { endpointResponse = UNKNOWN_TOPIC_RESPONSE; } } catch (DatastoreException de) { logger.error("Problem selecting topic", de); endpointResponse = INTERNAL_ERROR_RESPONSE; } } else { endpointResponse = NO_TOPIC_RESPONSE; } logNotification(request, topicURL, endpointResponse.statusCode, broadcastContent); Bridge.sendServletResponse(endpointResponse, response); }
From source file:org.apache.usergrid.java.client.model.UsergridEntity.java
public void putProperty(@NotNull final String name, final float value) { this.putProperty(name, JsonNodeFactory.instance.numberNode(value)); }
From source file:nextflow.fs.dx.api.DxApi.java
/** * Creater the {@code JsonNode} input object required to delete one, or more, files * * <p>//w w w . j a v a2 s . c om * Example JSON object format: * <pre> * '{"objects":["file-B86Q5B80j58B67zVXG3Q01K8"]}' * </pre> * </p> * * * * <p> * http://wiki.dnanexus.com/API-Specification-v1.0.0/Folders-and-Deletion#API-method:-/class-xxxx/removeObjects * </p> * * @param fileIds an array of strings representing IDs of the objects to be removed from the data * @return @return The entity ID of the manipulated data container */ public String fileDelete(String contextId, String... fileIds) throws IOException { ArrayNode container = new ArrayNode(JsonNodeFactory.instance); for (String item : fileIds) { container.add(item); } JsonNode input = DxJson.getObjectBuilder().put("objects", container).build(); JsonNode result = api(String.format("/%s/removeObjects", contextId), input).call(); return result.get("id").textValue(); }
From source file:com.ikanow.aleph2.data_import_manager.harvest.modules.LocalHarvestTestModule.java
private static JsonNode safeJsonGet(String fieldname, JsonNode src) { final JsonNode j = Optional.ofNullable(src.get(fieldname)).orElse(JsonNodeFactory.instance.objectNode()); //DEBUG//from w ww. j a va 2 s . co m //System.out.println(j); return j; }
From source file:io.gs2.stamina.Gs2StaminaClient.java
/** * ???<br>// w w w .j av a2 s .c o m * <br> * - : 5<br> * <br> * * @param request * @return ? */ public ChangeStaminaResult changeStamina(ChangeStaminaRequest request) { ObjectNode body = JsonNodeFactory.instance.objectNode().put("variation", request.getVariation()) .put("maxValue", request.getMaxValue()); if (request.getOverflow() != null) body.put("overflow", request.getOverflow()); HttpPost post = createHttpPost( Gs2Constant.ENDPOINT_HOST + "/staminaPool/" + (request.getStaminaPoolName() == null || request.getStaminaPoolName().equals("") ? "null" : request.getStaminaPoolName()) + "/stamina", credential, ENDPOINT, ChangeStaminaRequest.Constant.MODULE, ChangeStaminaRequest.Constant.FUNCTION, body.toString()); if (request.getRequestId() != null) { post.setHeader("X-GS2-REQUEST-ID", request.getRequestId()); } post.setHeader("X-GS2-ACCESS-TOKEN", request.getAccessToken()); return doRequest(post, ChangeStaminaResult.class); }
From source file:io.gs2.matchmaking.Gs2MatchmakingClient.java
/** * ????<br>//from w ww .jav a 2 s .c o m * <br> * ??5????????<br> * ?????5??????????????????????<br> * <br> * ????????? done ? true ???<br> * done ? true ???????? item ????????????<br> * <br> * done ? false ???????????????????<br> * ????searchContext ????????<br> * ??????????API??????????????????<br> * <br> * ???????????????????????? done ? true ???<br> * <br> * - : 10<br> * <br> * * @param request * @return ? */ public CustomAutoDoMatchmakingResult customAutoDoMatchmaking(CustomAutoDoMatchmakingRequest request) { ObjectNode body = JsonNodeFactory.instance.objectNode(); if (request.getAttribute1() != null) body.put("attribute1", request.getAttribute1()); if (request.getAttribute2() != null) body.put("attribute2", request.getAttribute2()); if (request.getAttribute3() != null) body.put("attribute3", request.getAttribute3()); if (request.getAttribute4() != null) body.put("attribute4", request.getAttribute4()); if (request.getAttribute5() != null) body.put("attribute5", request.getAttribute5()); if (request.getSearchAttribute1Min() != null) body.put("searchAttribute1Min", request.getSearchAttribute1Min()); if (request.getSearchAttribute2Min() != null) body.put("searchAttribute2Min", request.getSearchAttribute2Min()); if (request.getSearchAttribute3Min() != null) body.put("searchAttribute3Min", request.getSearchAttribute3Min()); if (request.getSearchAttribute4Min() != null) body.put("searchAttribute4Min", request.getSearchAttribute4Min()); if (request.getSearchAttribute5Min() != null) body.put("searchAttribute5Min", request.getSearchAttribute5Min()); if (request.getSearchAttribute1Max() != null) body.put("searchAttribute1Max", request.getSearchAttribute1Max()); if (request.getSearchAttribute2Max() != null) body.put("searchAttribute2Max", request.getSearchAttribute2Max()); if (request.getSearchAttribute3Max() != null) body.put("searchAttribute3Max", request.getSearchAttribute3Max()); if (request.getSearchAttribute4Max() != null) body.put("searchAttribute4Max", request.getSearchAttribute4Max()); if (request.getSearchAttribute5Max() != null) body.put("searchAttribute5Max", request.getSearchAttribute5Max()); if (request.getSearchContext() != null) body.put("searchContext", request.getSearchContext()); HttpPost post = createHttpPost( Gs2Constant.ENDPOINT_HOST + "/matchmaking/" + (request.getMatchmakingName() == null || request.getMatchmakingName().equals("") ? "null" : request.getMatchmakingName()) + "/customauto", credential, ENDPOINT, CustomAutoDoMatchmakingRequest.Constant.MODULE, CustomAutoDoMatchmakingRequest.Constant.FUNCTION, body.toString()); if (request.getRequestId() != null) { post.setHeader("X-GS2-REQUEST-ID", request.getRequestId()); } post.setHeader("X-GS2-ACCESS-TOKEN", request.getAccessToken()); return doRequest(post, CustomAutoDoMatchmakingResult.class); }
From source file:com.yahoo.elide.extensions.JsonApiPatch.java
private ObjectNode getErrorContainer() { ObjectNode container = JsonNodeFactory.instance.objectNode(); container.set("errors", JsonNodeFactory.instance.arrayNode()); return container; }