Skip to content

Commit

Permalink
Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Junge committed Dec 16, 2014
2 parents ab34319 + 1c46fb3 commit 8591e97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<artifactId>envaya-client</artifactId>
<packaging>jar</packaging>
<groupId>com.37coins</groupId>
<version>1.0.1</version>
<version>1.0.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
42 changes: 20 additions & 22 deletions src/main/java/com/_37coins/EnvayaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected <K> K parsePayload(HttpResponse response, Class<K> entityClass)
return new ObjectMapper().readValue(response.getEntity()
.getContent(), entityClass);
} catch (IOException e) {
log.error("envaya client error", e);
log.error("envaya client parsePayload error:", e);
throw new EnvayaClientException(
EnvayaClientException.Reason.ERROR_PARSING, e);
}
Expand All @@ -120,37 +120,35 @@ protected <K> K parsePayload(HttpResponse response, Class<K> entityClass)
protected <K> K getPayload(HttpRequestBase request, Class<K> entityClass)
throws EnvayaClientException {
HttpResponse response;

try{
log.debug("Request URL->:"+request.getURI().toURL().toString());
log.debug("Request Method->:"+request.getMethod().toString());
if(request instanceof HttpPost){
String reqBody=IOUtils.toString(((HttpPost)request).getEntity().getContent(), "UTF-8");
log.debug("Request PostData->:"+reqBody);
}
}catch(IOException ioe){
log.error("IOException",ioe);
throw new EnvayaClientException(EnvayaClientException.Reason.ERROR_PARSING);
}


try {
response = httpClient.execute(request);
} catch (IOException e) {
log.error("envaya client error", e);
log.error("envaya client httpClient.execute error", e);
throw new EnvayaClientException(
EnvayaClientException.Reason.ERROR_GETTING_RESOURCE, e);
}

if(log.isDebugEnabled()){
try{
log.error("no success in response. Status code:"+response.getStatusLine().getStatusCode());
log.info("Request URL->:"+request.getURI().toURL().toString());
log.info("Request Headers ->:"+request.getAllHeaders().toString());
if(request instanceof HttpPost){
String reqBody=IOUtils.toString(((HttpPost)request).getEntity().getContent(), "UTF-8");
log.info("Request PostData->:"+reqBody);
}
String respBody=IOUtils.toString(response.getEntity().getContent(), "UTF-8");
log.info("Request PostData->:"+respBody);
log.info("Response:"+response.getEntity().getContent());
}catch(IOException ioe){
ioe.printStackTrace();
throw new EnvayaClientException(EnvayaClientException.Reason.ERROR_PARSING);
}
}



log.debug("Response Status code:"+response.getStatusLine().getStatusCode());
if (isSucceed(response) && request.getMethod() != "DELETE") {
return parsePayload(response, entityClass);
return parsePayload(response, entityClass);
} else if (isSucceed(response)) {
return null;
return null;
} else {
throw new EnvayaClientException(
EnvayaClientException.Reason.AUTHENTICATION_FAILED);
Expand Down

0 comments on commit 8591e97

Please sign in to comment.