List of usage examples for com.fasterxml.jackson.core JsonProcessingException printStackTrace
public void printStackTrace()
From source file:org.gameontext.regsvc.db.RegistrationDocuments.java
/** * Register a room for an event/* w ww .ja va 2 s .c o m*/ */ public boolean registerRoom(Registration reg) { Log.mapOperations(Level.FINE, this, "Add new registration: {0}", reg); try { System.out.println("Registering room : " + mapper.writeValueAsString(reg)); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { db.create(reg); } catch (UpdateConflictException ex) { // If there is a conflict, we'll return false so that the caller tries again. return false; } return true; }
From source file:org.apache.streams.tika.TikaProcessor.java
private StreamsDatum expandLink(String link, StreamsDatum input) { LinkCrawler expander = new LinkCrawler((String) link); expander.run();//ww w. ja va2 s . c om StreamsDatum datum = null; if (input.getId() == null) try { datum = new StreamsDatum(this.mapper.writeValueAsString(expander.getArticle()), expander.getFinalURL()); } catch (JsonProcessingException e) { e.printStackTrace(); return null; } else try { datum = new StreamsDatum(this.mapper.writeValueAsString(expander.getArticle()), input.getId()); } catch (JsonProcessingException e) { e.printStackTrace(); return null; } datum.setSequenceid(input.getSequenceid()); datum.setMetadata(input.getMetadata()); datum.setTimestamp(input.getTimestamp()); return datum; }
From source file:org.ocsoft.olivia.models.contents.config.JsonObject.java
public void putJson(String key, String json) { try {// w w w .j a va2 s . c om root.put(key, JsonUtils.readTree(json)); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:ch.icclab.cyclops.resource.impl.MeterResource.java
/** * Returns the last persisted list of meters * * Pseudo Code/*from ww w. ja v a 2 s. c o m*/ * 1. Receive the request for the list of meters * 2. Query the DB to get the list * 3. Return the list of meters * * @return Representation A JSON response containing the list of meters */ @Get public Representation getMeterList() { String jsonStr; JsonRepresentation responseJson = null; TSDBData responseObj; ObjectMapper mapper = new ObjectMapper(); TSDBResource tsdbResource = new TSDBResource(); responseObj = tsdbResource.getMeterList(); //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.jimsey.projects.turbine.fuel.domain.TickJson.java
@Override public String toString() { String result = null;// w w w.j a v a 2s .c om try { result = json.writeValueAsString(this); } catch (JsonProcessingException e) { e.printStackTrace(); } return result; }
From source file:org.gameontext.regsvc.db.RatingRepository.java
public String getRatings() { try {/* w w w . j av a 2 s .c o m*/ List<Rating> data = ratings.getRatings(); Map<String, Rating> results = new HashMap<>(); for (Rating item : data) { if (!results.containsKey(item.getSiteId())) { RatingAverager avg = data.stream().filter(r -> r.getSiteId() == item.getSiteId()) .map(Rating::getRating) .collect(RatingAverager::new, RatingAverager::accept, RatingAverager::combiner); item.setRating(avg.calculate()); results.put(item.getSiteId(), item); } } return mapper.writeValueAsString(results.values()); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); return "{}"; } }
From source file:com.baidubce.services.bmr.BmrClientTest.java
@Test public void testListClusters() { int maxKeys = 1; ListClustersResponse response = this.bmrClient.listClusters(new ListClustersRequest().withMaxKeys(maxKeys)); try {//from w ww . j a v a2 s . c o m System.out.println(JsonUtils.toJsonPrettyString(response)); } catch (JsonProcessingException e) { e.printStackTrace(); } assertThat(response.getMaxKeys(), is(maxKeys)); assertThat(response.getClusters(), hasSize(maxKeys)); }
From source file:ch.icclab.cyclops.services.iaas.openstack.resource.impl.UserUsageResource.java
/** * * Construct the JSON response consisting of the meter and the usage values * */*from www . jav a 2 s . com*/ * * Pseudo Code<br/> * * 1. Create the HasMap consisting of time range<br/> * * 2. Create the response POJO<br/> * * 3. Convert the POJO to JSON<br/> * * 4. Return the JSON string * * @param usageArr An arraylist consisting of metername and corresponding usage * @param userId UserID for which the usage details is to be returned. * @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 usageArr, String userId, String fromDate, String toDate) { String jsonStr; JsonRepresentation responseJson = null; UserUsageResponse responseObj = new UserUsageResponse(); 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.setUsage(usageArr); //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.springframework.cloud.stream.FluxTest.java
@Before public void setup() { emitter = Flux.interval(Duration.ofMillis(100)).map(tick -> { return Quote.random(); }).map(quote -> {/*from w ww . j av a 2s . c o m*/ String payload = null; try { payload = mapper.writeValueAsString(quote); } catch (JsonProcessingException e) { e.printStackTrace(); } return payload; }); }
From source file:org.loklak.objects.AbstractIndexEntry.java
public String toString() { try {/*w w w .j a v a 2s .c o m*/ ObjectWriter ow = new ObjectMapper().writerWithDefaultPrettyPrinter(); return ow.writeValueAsString(this.toMap()); } catch (JsonProcessingException e) { e.printStackTrace(); return ""; } }