use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class TopDao method mapperJson.
public List<Object> mapperJson(boolean useCache) {
List<Object> topCategorys = new ArrayList<Object>();
tabs.clear();
try {
String resultNews = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_NEWS_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
NewsMoreResponse newsMoreResponse = mObjectMapper.readValue(resultNews, new TypeReference<NewsMoreResponse>() {
});
if (newsMoreResponse != null) {
this.newsCategorys = newsMoreResponse.getResponse();
}
String resultBlogs = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_BLOG_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
BlogsMoreResponse blogsMoreResponse = mObjectMapper.readValue(resultBlogs, new TypeReference<BlogsMoreResponse>() {
});
if (blogsMoreResponse != null) {
this.blogsCategorys = blogsMoreResponse.getResponse();
}
String resultWiki = RequestCacheUtil.getRequestContent(mActivity, Urls.TOP_WIKI_URL + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
WikiMoreResponse wikiMoreResponse = mObjectMapper.readValue(resultWiki, new TypeReference<WikiMoreResponse>() {
});
if (wikiMoreResponse != null) {
this.wikiCategorys = wikiMoreResponse.getResponse();
}
Collections.addAll(topCategorys, newsCategorys, blogsCategorys, wikiCategorys);
return topCategorys;
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.codehaus.jackson.map.JsonMappingException in project onebusaway-application-modules by camsys.
the class AgencyMetadataResource method listAgencyMetadata.
@Path("/list")
@GET
@Produces("application/json")
public Response listAgencyMetadata() throws JsonGenerationException, JsonMappingException, IOException {
try {
List<AgencyMetadata> agencyMetadata = _agencyMetadataService.getAllAgencyMetadata();
Response response = constructResponse(agencyMetadata);
return response;
} catch (Exception e) {
log.error(e.getMessage());
throw new WebApplicationException(e, Response.serverError().build());
}
}
use of org.codehaus.jackson.map.JsonMappingException in project onebusaway-application-modules by camsys.
the class AgencyMetadataResource method constructResponse.
// Private methods
private Response constructResponse(Object result) {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
Response response = null;
try {
final org.codehaus.jackson.JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
mapper.writeValue(jsonGenerator, result);
response = Response.ok(sw.toString()).build();
} catch (JsonGenerationException e) {
log.error("Error generating response JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (JsonMappingException e) {
log.error("Error mapping response to JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (IOException e) {
log.error("I/O error while creating response JSON");
response = Response.serverError().build();
e.printStackTrace();
}
return response;
}
use of org.codehaus.jackson.map.JsonMappingException in project onebusaway-application-modules by camsys.
the class AgencyMetadataResource method createAgencyMetadata.
@Path("/create")
@GET
@Produces("application/json")
public Response createAgencyMetadata(@QueryParam("gtfs_id") String gtfs_id, @QueryParam("name") String name, @QueryParam("short_name") String short_name, @QueryParam("legacy_id") String legacy_id, @QueryParam("gtfs_feed_url") String gtfs_feed_url, @QueryParam("gtfs_rt_feed_url") String gtfs_rt_feed_url, @QueryParam("bounding_box") String bounding_box, @QueryParam("ntd_id") String ntd_id, @QueryParam("agency_message") String agency_message) throws JsonGenerationException, JsonMappingException, IOException {
log.info("Starting createAgencyMetadata with gtfs_id: " + gtfs_id + ", name: " + name + ", short_name: " + short_name + ", legacy_id: " + legacy_id + ", gtfs_feed_url: " + gtfs_feed_url + ", gtfs_rt_feed_url: " + gtfs_rt_feed_url + ", bounding_box: " + bounding_box + ", ntd_id: " + ntd_id + ", agency_message: " + agency_message);
String message = "Agency Metadata record created for: " + name;
try {
_agencyMetadataService.createAgencyMetadata(gtfs_id, name, short_name, legacy_id, gtfs_feed_url, gtfs_rt_feed_url, bounding_box, ntd_id, agency_message);
} catch (Exception e) {
log.error(e.getMessage());
throw new WebApplicationException(e, Response.serverError().build());
}
Response response = constructResponse(message);
return response;
}
use of org.codehaus.jackson.map.JsonMappingException in project onebusaway-application-modules by camsys.
the class KeysResource method constructResponse.
private Response constructResponse(Object result) {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
Response response = null;
try {
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
mapper.writeValue(jsonGenerator, result);
response = Response.ok(sw.toString()).build();
} catch (JsonGenerationException e) {
log.error("Error generating response JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (JsonMappingException e) {
log.error("Error mapping response to JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (IOException e) {
log.error("I/O error while creating response JSON");
response = Response.serverError().build();
e.printStackTrace();
}
return response;
}
Aggregations