Example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance

List of usage examples for com.fasterxml.jackson.databind.node JsonNodeFactory instance

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Prototype

JsonNodeFactory instance

To view the source code for com.fasterxml.jackson.databind.node JsonNodeFactory instance.

Click Source Link

Usage

From source file:io.apicurio.hub.api.rest.impl.DesignsResource.java

/**
 * Creates the JSON data to be stored in the data row representing a "publish API" event
 * (also known as an API publication).//from www .  j  a va  2s. co m
 * @param info
 */
private String createPublicationData(NewApiPublication info) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode data = JsonNodeFactory.instance.objectNode();
        data.set("type", JsonNodeFactory.instance.textNode(info.getType().name()));
        data.set("org", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("repo", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("team", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("group", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("project", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("branch", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("resource", JsonNodeFactory.instance.textNode(info.getOrg()));
        data.set("format", JsonNodeFactory.instance.textNode(info.getFormat().name()));
        data.set("commitMessage", JsonNodeFactory.instance.textNode(info.getCommitMessage()));
        return mapper.writeValueAsString(data);
    } catch (JsonProcessingException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.ikanow.aleph2.management_db.mongodb.services.IkanowV1SyncService_Buckets.java

/** Gets a JSON field that may not be present (justs an empty JsonNode if no)
 * @param fieldname/*from  w w  w  .  j  a  v a  2s . c om*/
 * @param src
 * @return
 */
protected static JsonNode safeJsonGet(String fieldname, JsonNode src) {
    final JsonNode j = Optional.ofNullable(src.get(fieldname)).orElse(JsonNodeFactory.instance.objectNode());
    //DEBUG
    //System.out.println(j);
    return j;
}

From source file:io.gs2.matchmaking.Gs2MatchmakingClient.java

/**
 * ???????<br>//w  w  w  . j av a 2  s  . c om
 * <br>
 * - : 10<br>
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public PasscodeJoinGatheringResult passcodeJoinGathering(PasscodeJoinGatheringRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode();

    HttpPost post = createHttpPost(
            Gs2Constant.ENDPOINT_HOST + "/matchmaking/"
                    + (request.getMatchmakingName() == null || request.getMatchmakingName().equals("") ? "null"
                            : request.getMatchmakingName())
                    + "/passcode/join/"
                    + (request.getPasscode() == null || request.getPasscode().equals("") ? "null"
                            : request.getPasscode())
                    + "",
            credential, ENDPOINT, PasscodeJoinGatheringRequest.Constant.MODULE,
            PasscodeJoinGatheringRequest.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, PasscodeJoinGatheringResult.class);

}

From source file:io.gs2.matchmaking.Gs2MatchmakingClient.java

/**
 * ?????<br>/*from w  ww.ja v a2 s .c om*/
 * <br>
 * - : 10<br>
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public RoomCreateGatheringResult roomCreateGathering(RoomCreateGatheringRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode();
    if (request.getMeta() != null)
        body.put("meta", request.getMeta());

    HttpPost post = createHttpPost(
            Gs2Constant.ENDPOINT_HOST + "/matchmaking/"
                    + (request.getMatchmakingName() == null || request.getMatchmakingName().equals("") ? "null"
                            : request.getMatchmakingName())
                    + "/room",
            credential, ENDPOINT, RoomCreateGatheringRequest.Constant.MODULE,
            RoomCreateGatheringRequest.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, RoomCreateGatheringResult.class);

}

From source file:io.gs2.matchmaking.Gs2MatchmakingClient.java

/**
 * ????<br>/*from ww  w .  j av  a2 s  .c o  m*/
 * <br>
 *     - : 10<br>
 * <br>
 *
 * @param request 
        
 */

public void roomEarlyCompleteGathering(RoomEarlyCompleteGatheringRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode();

    HttpPost post = createHttpPost(
            Gs2Constant.ENDPOINT_HOST + "/matchmaking/"
                    + (request.getMatchmakingName() == null || request.getMatchmakingName().equals("") ? "null"
                            : request.getMatchmakingName())
                    + "/room/"
                    + (request.getGatheringId() == null || request.getGatheringId().equals("") ? "null"
                            : request.getGatheringId())
                    + "/complete",
            credential, ENDPOINT, RoomEarlyCompleteGatheringRequest.Constant.MODULE,
            RoomEarlyCompleteGatheringRequest.Constant.FUNCTION, body.toString());
    if (request.getRequestId() != null) {
        post.setHeader("X-GS2-REQUEST-ID", request.getRequestId());
    }

    post.setHeader("X-GS2-ACCESS-TOKEN", request.getAccessToken());

    doRequest(post, null);

}

From source file:io.gs2.matchmaking.Gs2MatchmakingClient.java

/**
 * ?????<br>/*www  . j  a v a  2s  . c  o m*/
 * <br>
 * - : 10<br>
 * <br>
 *
 * @param request 
        
 * @return ?
        
 */

public RoomJoinGatheringResult roomJoinGathering(RoomJoinGatheringRequest request) {

    ObjectNode body = JsonNodeFactory.instance.objectNode();

    HttpPost post = createHttpPost(
            Gs2Constant.ENDPOINT_HOST + "/matchmaking/"
                    + (request.getMatchmakingName() == null || request.getMatchmakingName().equals("") ? "null"
                            : request.getMatchmakingName())
                    + "/room/"
                    + (request.getGatheringId() == null || request.getGatheringId().equals("") ? "null"
                            : request.getGatheringId())
                    + "",
            credential, ENDPOINT, RoomJoinGatheringRequest.Constant.MODULE,
            RoomJoinGatheringRequest.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, RoomJoinGatheringResult.class);

}

From source file:org.apache.taverna.databundle.TestDataBundles.java

@Test
public void setWorkflowReport() throws Exception {
    ObjectNode report = JsonNodeFactory.instance.objectNode();
    report.put("number", 1337);
    DataBundles.setWorkflowRunReport(dataBundle, report);
    Path runReport = DataBundles.getWorkflowRunReport(dataBundle);
    String json = DataBundles.getStringValue(runReport);
    assertTrue(json.contains("number"));
    assertTrue(json.contains("1337"));
}