use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class WikiDao method mapperJson.
public WikiResponseEntity mapperJson(boolean useCache) {
// TODO Auto-generated method stub
WikiJson wikiJson;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, Urls.WIKI_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
wikiJson = mObjectMapper.readValue(result, new TypeReference<WikiJson>() {
});
if (wikiJson == null) {
return null;
}
this.mWikiResponseEntity = wikiJson.getResponse();
return mWikiResponseEntity;
} 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 android-app by eoecn.
the class BlogsDao method getMore.
public BlogsMoreResponse getMore(String more_url) {
BlogsMoreResponse response;
try {
String result = RequestCacheUtil.getRequestContent(mActivity, more_url + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, true);
response = mObjectMapper.readValue(result, new TypeReference<BlogsMoreResponse>() {
});
return response;
} 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();
}
return null;
}
use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.
the class DetailDao method mapperJson.
public DetailResponseEntity mapperJson(boolean useCache) {
try {
String result = RequestCacheUtil.getRequestContent(mActivity, mUrl, Constants.WebSourceType.Json, Constants.DBContentType.Content_content, useCache);
Log.i("info", mUrl);
DetailJson detailJson = mObjectMapper.readValue(result, new TypeReference<DetailJson>() {
});
this.mDetailResponseEntity = detailJson.getResponse();
return this.mDetailResponseEntity;
} 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 databus by linkedin.
the class TestDbusEventBufferMult method convertToPhysicalSourceConfig.
public PhysicalSourceConfig convertToPhysicalSourceConfig(String str) {
_mapper = new ObjectMapper();
InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(str));
PhysicalSourceConfig pConfig = null;
try {
pConfig = _mapper.readValue(isr, PhysicalSourceConfig.class);
} catch (JsonParseException e) {
fail("Failed parsing", e);
} catch (JsonMappingException e) {
fail("Failed parsing", e);
} catch (IOException e) {
fail("Failed parsing", e);
}
try {
isr.close();
} catch (IOException e) {
fail("Failed", e);
}
return pConfig;
}
use of org.codehaus.jackson.map.JsonMappingException in project databus by linkedin.
the class TestRelayCommandsLocal method testRegisterV4CommandLessThanHappyPaths.
@Test
public void testRegisterV4CommandLessThanHappyPaths() throws Exception {
LOG.debug("\n\nstarting testRegisterV4CommandLessThanHappyPaths()\n");
// protocolVersion < 2
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/register?sources=4002&" + DatabusHttpHeaders.PROTOCOL_VERSION_PARAM + "=1");
SimpleTestHttpClient httpClient = SimpleTestHttpClient.createLocal(TimeoutPolicy.ALL_TIMEOUTS);
SimpleHttpResponseHandler respHandler = httpClient.sendRequest(_serverAddress, httpRequest);
assertTrue("failed to get a response", respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
HttpResponse respObj = respHandler.getResponse();
assertNotNull("/register failed to return expected error", respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
LOG.debug("DATABUS_ERROR_CLASS_HEADER = " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
// protocolVersion > 4
httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/register?sources=4002&" + DatabusHttpHeaders.PROTOCOL_VERSION_PARAM + "=5");
respHandler = httpClient.sendRequest(_serverAddress, httpRequest);
assertTrue("failed to get a response", respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
respObj = respHandler.getResponse();
assertNotNull("/register failed to return expected error", respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
LOG.debug("DATABUS_ERROR_CLASS_HEADER = " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
// protocolVersion == 2: this is a happy path, but explicitly specifying the version is
// unusual in this case (default = version 2 or 3, which are identical for /register), so
// check for expected response
httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/register?sources=4002&" + DatabusHttpHeaders.PROTOCOL_VERSION_PARAM + "=2");
respHandler = httpClient.sendRequest(_serverAddress, httpRequest);
assertTrue("failed to get a response", respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
respObj = respHandler.getResponse();
assertNull("/register v2 returned unexpected error: " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER), respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
LOG.debug("DATABUS_ERROR_CLASS_HEADER = " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
String registerResponseProtocolVersionStr = respObj.getHeader(DatabusHttpHeaders.DBUS_CLIENT_RELAY_PROTOCOL_VERSION_HDR);
assertNotNull("/register protocol-version response header not present", registerResponseProtocolVersionStr);
assertEquals("client-relay protocol response version mismatch", "2", registerResponseProtocolVersionStr);
byte[] respBytes = respHandler.getReceivedBytes();
if (LOG.isDebugEnabled()) {
LOG.debug("/register response: " + new String(respBytes));
}
ByteArrayInputStream in = new ByteArrayInputStream(respBytes);
ObjectMapper objMapper = new ObjectMapper();
List<RegisterResponseEntry> sourceSchemasList = null;
try {
sourceSchemasList = objMapper.readValue(in, new TypeReference<List<RegisterResponseEntry>>() {
});
} catch (JsonMappingException jmex) {
Assert.fail("ObjectMapper failed unexpectedly");
}
assertNotNull("missing source schemas in response", sourceSchemasList);
assertEquals("expected one source schema", 1, sourceSchemasList.size());
RegisterResponseEntry rre = sourceSchemasList.get(0);
assertEquals("unexpected source id", 4002, rre.getId());
Schema resSchema = Schema.parse(rre.getSchema());
assertEquals("unexpected source-schema name for source id 4002", "test4.source2_v1", resSchema.getFullName());
// protocolVersion == 3: as with v2 above; just do a quick sanity check
httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/register?sources=4002&" + DatabusHttpHeaders.PROTOCOL_VERSION_PARAM + "=3");
respHandler = httpClient.sendRequest(_serverAddress, httpRequest);
assertTrue("failed to get a response", respHandler.awaitResponseUninterruptedly(1, TimeUnit.SECONDS));
respObj = respHandler.getResponse();
assertNull("/register v3 returned unexpected error: " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER), respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
LOG.debug("DATABUS_ERROR_CLASS_HEADER = " + respObj.getHeader(DatabusHttpHeaders.DATABUS_ERROR_CLASS_HEADER));
registerResponseProtocolVersionStr = respObj.getHeader(DatabusHttpHeaders.DBUS_CLIENT_RELAY_PROTOCOL_VERSION_HDR);
assertNotNull("/register protocol-version response header not present", registerResponseProtocolVersionStr);
assertEquals("client-relay protocol response version mismatch", "3", registerResponseProtocolVersionStr);
}
Aggregations