Example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace

List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonProcessingException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.snowplowanalytics.snowplow.tracker.core.payload.SchemaPayload.java

public SchemaPayload setData(Object data) {
    try {//from  w  w w. ja  v a  2s  . co m
        objectNode.putPOJO(Parameter.DATA, objectMapper.writeValueAsString(data));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return this;
}

From source file:com.flipkart.ranger.model.SimpleServiceProviderTest.java

private void registerService(String host, int port, int shardId) throws Exception {
    ServiceProvider<UnshardedClusterInfo> serviceProvider = ServiceProviderBuilders
            .unshardedServiceProviderBuilder().withConnectionString(testingCluster.getConnectString())
            .withNamespace("test").withServiceName("test-service")
            .withSerializer(new Serializer<UnshardedClusterInfo>() {
                @Override/*from  w  w  w  .  ja v a  2s  .c  o m*/
                public byte[] serialize(ServiceNode<UnshardedClusterInfo> data) {
                    try {
                        return objectMapper.writeValueAsBytes(data);
                    } catch (JsonProcessingException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            }).withHostname(host).withPort(port).withHealthcheck(new Healthcheck() {
                @Override
                public HealthcheckStatus check() {
                    return HealthcheckStatus.healthy;
                }
            }).buildServiceDiscovery();
    serviceProvider.start();
}

From source file:org.o3project.ocnrm.odenos.linklayerizer.LinkLayerizerBoundarySet.java

public String changeBoundariestoJSON() {
    logger.info("changeBoundariestoJSON Start");

    String jsonBoundaries = "";
    try {/* ww w  . j  a  va 2 s  .co  m*/
        ObjectMapper mapper = new ObjectMapper();
        jsonBoundaries = mapper.writeValueAsString(linklayerizerBoundaryMap);
        logger.debug("jsonBoundaries:" + jsonBoundaries);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    logger.info("changeBoundariestoJSON Endt");
    return jsonBoundaries;
}

From source file:de.elanev.studip.android.app.backend.datamodel.Settings.java

public String toJson() {
    ObjectMapper mapper = new ObjectMapper();
    String json = "";
    try {/*from  w  ww. jav  a2s  . c o  m*/
        json = mapper.writeValueAsString(this);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return json;
}

From source file:ch.icclab.cyclops.resource.impl.ChargeResource.java

/**
 *  Construct the JSON response consisting of the meter and the usage values
 *
 *  Pseudo Code/*from  w ww  .  ja  va  2 s  .c o  m*/
 *  1. Create the HasMap consisting of time range
 *  2. Create the response POJO
 *  3. Convert the POJO to JSON
 *  4. Return the JSON string
 *
 * @param rateArr An arraylist consisting of metername and corresponding usage
 * @param fromDate DateTime from usage data needs to be calculated
 * @param toDate DateTime upto which the usage data needs to be calculated
 * @return responseJson The response object in the JSON format
 */
public Representation constructResponse(HashMap rateArr, String userid, String fromDate, String toDate) {

    String jsonStr;
    JsonRepresentation responseJson = null;

    ChargeResponse responseObj = new ChargeResponse();
    HashMap time = new HashMap();
    ObjectMapper mapper = new ObjectMapper();

    time.put("from", fromDate);
    time.put("to", toDate);

    //Build the response POJO
    responseObj.setUserid(userid);
    responseObj.setTime(time);
    responseObj.setCharge(rateArr);

    //Convert the POJO to a JSON string
    try {
        jsonStr = mapper.writeValueAsString(responseObj);
        responseJson = new JsonRepresentation(jsonStr);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    return responseJson;
}

From source file:org.oncoblocks.centromere.web.util.FilteringJackson2HttpMessageConverter.java

@Override
protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage)
        throws IOException, HttpMessageNotWritableException {

    ObjectMapper objectMapper = getObjectMapper();
    JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(outputMessage.getBody());

    try {/*from ww w.  j ava2s .com*/

        if (this.prefixJson) {
            jsonGenerator.writeRaw(")]}', ");
        }

        if (object instanceof ResponseEnvelope) {

            ResponseEnvelope envelope = (ResponseEnvelope) object;
            Object entity = envelope.getEntity();
            Set<String> fieldSet = envelope.getFieldSet();
            Set<String> exclude = envelope.getExclude();
            FilterProvider filters = null;

            if (fieldSet != null && !fieldSet.isEmpty()) {
                if (entity instanceof ResourceSupport) {
                    fieldSet.add("content"); // Don't filter out the wrapped content.
                }
                filters = new SimpleFilterProvider()
                        .addFilter("fieldFilter", SimpleBeanPropertyFilter.filterOutAllExcept(fieldSet))
                        .setFailOnUnknownId(false);
            } else if (exclude != null && !exclude.isEmpty()) {
                filters = new SimpleFilterProvider()
                        .addFilter("fieldFilter", SimpleBeanPropertyFilter.serializeAllExcept(exclude))
                        .setFailOnUnknownId(false);
            } else {
                filters = new SimpleFilterProvider()
                        .addFilter("fieldFilter", SimpleBeanPropertyFilter.serializeAllExcept())
                        .setFailOnUnknownId(false);
            }

            objectMapper.setFilterProvider(filters);
            objectMapper.writeValue(jsonGenerator, entity);

        } else if (object == null) {
            jsonGenerator.writeNull();
        } else {
            FilterProvider filters = new SimpleFilterProvider().setFailOnUnknownId(false);
            objectMapper.setFilterProvider(filters);
            objectMapper.writeValue(jsonGenerator, object);
        }

    } catch (JsonProcessingException e) {
        e.printStackTrace();
        throw new HttpMessageNotWritableException("Could not write JSON: " + e.getMessage());
    }

}

From source file:ru.jts.authserver.network.clientpackets.CM_AUTH_BY_PASS.java

@Override
public void runImpl() {
    //Account account = AccountsDAO.getInstance().restoreByLogin(jsonMap.get(JSON_LOGIN));

    getClient().setBlowFishKey(blowFishKey);
    getClient().setRandomKey(Rnd.nextInt());

    ByteBuf buf = Unpooled.buffer().order(ByteOrder.LITTLE_ENDIAN);

    buf.writeBytes(new byte[] { (byte) 192, (byte) 168, (byte) 1, (byte) 100 });
    buf.writeInt(20015);/*from   w  w w  .  j a v a 2 s  . co  m*/

    buf.writeInt(getClient().getRandomKey());

    Map<String, String> jsonMapp = new HashMap<>();
    //jsonMap.put("security_msg", "old_pass");
    jsonMapp.put("token2", getClient().generateToken2());

    ObjectMapper mapper = new ObjectMapper();
    String json = null;
    try {
        json = mapper.writeValueAsString(jsonMapp);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return;
    }
    buf.writeByte(json.length());
    buf.writeBytes(json.getBytes());

    byte[] cryptedData = CryptEngine.getInstance().encrypt(buf.copy().array(), getClient().getBlowFishKey(),
            CryptEngine.ZERO_TRAILING_MODE);

    State state = AccountController.getInstance().accountLogin(jsonMap, password);
    switch (state) {
    case AUTHED: {
        getClient().sendPacket(new SM_AUTH_RESPONSE(sessionId, SM_AUTH_RESPONSE.LOGIN_OK, cryptedData));
        break;
    }
    case ALREADY_AUTHED: {
        getClient().sendPacket(new SM_AUTH_RESPONSE(sessionId,
                SM_AUTH_RESPONSE.LOGIN_REJECTED_ALREADY_LOGGED_IN, cryptedData));
        break;
    }
    default: {
    }
    }
}

From source file:com.kenlin.awsec2offering.Offering.java

@Override
public String toString() {
    try {/*w  w w . ja va 2s. c  o m*/
        JsonNode json = toJsonNode();
        return json.toString();
    } catch (JsonProcessingException e1) {
        e1.printStackTrace();
        return null;
    } catch (IOException e1) {
        e1.printStackTrace();
        return null;
    }
}

From source file:com.example.gcm.api.PushNotificationResource.java

/**
 * Sends downstream notification to registered devices.
 *
 * @param dryRun  Specifies whether downstream message will actually be sent to devices
 * @param request Downstream message details
 * @return Information about sent message.
 *//*from  w  w  w.j a  v a  2  s . c  o m*/
@ApiOperation(value = "Send notification downstream message", response = NotificationSendResponse.class)
@POST
@Path("/notification")
@UnitOfWork
public NotificationSendResponse sendPushNotification(
        @QueryParam("dryRun") @ApiParam(required = true) boolean dryRun,
        @ApiParam(required = true) @Valid NotificationRequest request) {

    List<AppId> ids = dao.findAll();
    List<String> registrationIds = new LinkedList<>();
    for (AppId id : ids) {
        registrationIds.add(id.getAppId());
    }

    NotificationDownstreamMessage message = new NotificationDownstreamMessage(registrationIds,
            request.getTimeToLive(), dryRun, new Notification(request));

    WebTarget target = client.target("https://gcm-http.googleapis.com").path("gcm/send");

    try {
        GCMResponse response = target.request(MediaType.APPLICATION_JSON_TYPE)
                .header("Authorization", "key=" + gcmKey)
                .post(Entity.entity(message, MediaType.APPLICATION_JSON_TYPE), GCMResponse.class);

        int nSent = response.getSuccess();
        int nErrors = response.getFailure();

        try {
            LOG.info("GCM response: {}", mapper.writeValueAsString(response));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        return new NotificationSendResponse(nSent, nErrors);
    } catch (WebApplicationException ex) {
        return new NotificationSendError(0, ids.size(), ex.getResponse().getStatus());
    }
}

From source file:org.apache.drill.exec.store.mpjdbc.MPJdbcFormatConfig.java

@Override
public int hashCode() {
    ObjectMapper mapper = new ObjectMapper();
    try {//from  w w  w .java2  s .  c o m
        String outval = mapper.writeValueAsString(this);
        logger.info("FormatConfigHashCode:" + outval);

        return outval.hashCode();
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return uri.hashCode();
    }
}