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:org.apache.streams.twitter.serializer.TwitterJsonUserstreameventActivitySerializer.java

public Activity convert(ObjectNode item) throws ActivitySerializerException {

    ObjectMapper mapper = StreamsTwitterMapper.getInstance();
    UserstreamEvent event = null;//from ww w.ja v a 2s . co  m
    try {
        event = mapper.treeToValue(item, UserstreamEvent.class);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    Activity activity = new Activity();
    activity.setActor(buildActor(event));
    activity.setVerb(detectVerb(event));
    activity.setObject(buildActivityObject(event));
    activity.setId(formatId(activity.getVerb()));
    if (Strings.isNullOrEmpty(activity.getId()))
        throw new ActivitySerializerException("Unable to determine activity id");
    activity.setProvider(getProvider());
    return activity;
}

From source file:org.apache.streams.datasift.example.DatasiftPushApplication.java

private StreamsApiConfiguration reconfigure(StreamsApiConfiguration streamsApiConfiguration) {

    // config from typesafe
    Config configTypesafe = StreamsConfigurator.config;

    // config from dropwizard
    Config configDropwizard = null;//from w  w w . j a v  a 2s .  c  o m
    try {
        configDropwizard = ConfigFactory.parseString(mapper.writeValueAsString(streamsApiConfiguration));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        LOGGER.error("Invalid Configuration: " + streamsApiConfiguration);
    }

    Config combinedConfig = configTypesafe.withFallback(configDropwizard);
    String combinedConfigJson = combinedConfig.root().render(ConfigRenderOptions.concise());

    StreamsApiConfiguration combinedDropwizardConfig = null;
    try {
        combinedDropwizardConfig = mapper.readValue(combinedConfigJson, StreamsApiConfiguration.class);
    } catch (IOException e) {
        e.printStackTrace();
        LOGGER.error("Invalid Configuration after merge: " + streamsApiConfiguration);
    }

    return combinedDropwizardConfig;

}

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

@Get
public Representation getResourceUsage(Entity entity) {
    String query = null;/*  ww w . j a  va  2s  .  c  o m*/
    String jsonStr;
    JsonRepresentation responseJson = null;
    TSDBData tsdbData;
    InfluxDBClient dbClient = new InfluxDBClient();
    ResourceUsageResponse resourceUsageResponse = new ResourceUsageResponse();
    HashMap time = new HashMap();
    ObjectMapper mapper = new ObjectMapper();

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

    if (Load.openStackCumulativeMeterList.contains(resourceId)) {
        query = "SELECT SUM(usage) FROM " + resourceId + " WHERE time > '" + fromDate + "' AND time < '"
                + toDate + "' GROUP BY userid";
    } else if (Load.openStackGaugeMeterList.contains(resourceId)) {
        query = "SELECT MEAN(avg) FROM " + resourceId + " WHERE time > '" + fromDate + "' AND time < '" + toDate
                + "' GROUP BY userid";
    } else if (Load.externalMeterList.contains(resourceId)) {
        query = "SELECT SUM(usage) FROM " + resourceId + " WHERE time > '" + fromDate + "' AND time < '"
                + toDate + "' GROUP BY userid";
    } else {
        // Fall back response TODO
    }
    tsdbData = dbClient.getData(query);
    resourceUsageResponse.setResourceid(resourceId);
    resourceUsageResponse.setTime(time);
    if (tsdbData != null) {
        resourceUsageResponse.setColumn(tsdbData.getColumns());
        resourceUsageResponse.setUsage(tsdbData.getPoints());
    } else {
        resourceUsageResponse.setColumn(null);
        resourceUsageResponse.setUsage(null);
    }

    try {
        jsonStr = mapper.writeValueAsString(resourceUsageResponse);
        responseJson = new JsonRepresentation(jsonStr);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return responseJson;
}

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

@Override
public void add(String key, Object value) {
    if (value == null) {
        logger.debug("kv-value is empty. Returning out without adding key..");
        return;//from   w  w w.  j  a v  a2  s .  c o m
    }

    logger.debug("Adding new key: {} with object value: {}", key, value);
    try {
        objectNode.putPOJO(key, objectMapper.writeValueAsString(value));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}

From source file:org.gameontext.regsvc.db.RatingDocuments.java

/**
 * Rate a room for an event// w  w  w  .j  a v a2  s .  co  m
 */
public void rateRoom(Rating rating) {
    Log.mapOperations(Level.FINE, this, "Add new rating: {0}", rating);

    try {
        System.out.println("Rating room : " + mapper.writeValueAsString(rating));
    } catch (JsonProcessingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        db.create(rating);
    } catch (UpdateConflictException ex) {
        // If there is a conflict, update with the new rating
        db.update(rating);
    }
}

From source file:org.jimsey.projects.turbine.fuel.domain.Entity.java

@Override
public String toString() {
    String result = null;/*from www .  j  av a 2 s  . co m*/
    try {
        // result = String.format("{\"%s\":%s}", this.getClass().getSimpleName(), json.writeValueAsString(this));
        result = json.writeValueAsString(this);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return result;
    // return ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE);
    // return String.format("{\"%s\":%s}",
    // this.getClass().getSimpleName(),
    // ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE));
}

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

@Override
public void addMap(Map map, Boolean base64_encoded, String type_encoded, String type_no_encoded) {
    // Return if we don't have a map
    if (map == null) {
        logger.debug("Map passed in is null. Returning nothing..");
        return;/*from  ww w .ja  v a 2s.  co m*/
    }

    String mapString;
    try {
        mapString = objectMapper.writeValueAsString(map);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return; // Return because we can't continue
    }

    if (base64_encoded) { // base64 encoded data
        objectNode.put(type_encoded, Util.base64Encode(mapString));
    } else { // add it as a child node
        add(type_no_encoded, mapString);
    }
}

From source file:org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient.java

@Override
public SchemaRegistrationResponse register(String subject, String format, String schema) {
    Assert.isTrue("avro".equals(format), "Only Avro is supported");
    String path = String.format("/subjects/%s", subject);
    HttpHeaders headers = new HttpHeaders();
    headers.put("Accept", Arrays.asList("application/vnd.schemaregistry.v1+json",
            "application/vnd.schemaregistry+json", "application/json"));
    headers.add("Content-Type", "application/json");
    Integer version = null;/*from   ww  w. j av  a2s . co  m*/
    try {
        String payload = this.mapper.writeValueAsString(Collections.singletonMap("schema", schema));
        HttpEntity<String> request = new HttpEntity<>(payload, headers);
        ResponseEntity<Map> response = this.template.exchange(this.endpoint + path, HttpMethod.POST, request,
                Map.class);
        version = (Integer) response.getBody().get("version");
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    SchemaRegistrationResponse schemaRegistrationResponse = new SchemaRegistrationResponse();
    schemaRegistrationResponse.setId(version);
    schemaRegistrationResponse.setSchemaReference(new SchemaReference(subject, version, "avro"));
    return schemaRegistrationResponse;
}

From source file:gr.cti.android.experimentation.service.GCMService.java

private String post(final Map<String, Object> message) {
    Entity entity;/*from w  w  w .  j  a va  2  s. c o m*/
    try {
        entity = Entity.json(new ObjectMapper().writeValueAsString(message));

        Response response = ClientBuilder.newClient().target("https://gcm-http.googleapis.com").path("gcm/send")
                .request().header("Content-Type", "application/json").header("Authorization", "key=" + gcmKey)
                .post(entity);
        Response.Status.Family statusFamily = response.getStatusInfo().getFamily();
        if (statusFamily == Response.Status.Family.SUCCESSFUL) {
            return response.readEntity(String.class);
        } else {
            return response.getStatusInfo().getReasonPhrase();
        }
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return null;
    }
}

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

public SchemaPayload setData(Payload data) {
    try {/*from  w w  w . j av a2 s  . c o  m*/
        objectNode.putPOJO(Parameter.DATA, objectMapper.writeValueAsString(data.getMap()));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return this;
}