Skip to content

Commit

Permalink
Merge branch 'release/v1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Junge committed Dec 10, 2014
2 parents c728474 + 79b16d5 commit ab34319
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
target
target/
.settings/
.classpath
.project
/shippable/
7 changes: 6 additions & 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.0</version>
<version>1.0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -33,6 +33,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>

<build>
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/_37coins/EnvayaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.Map.Entry;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOExceptionWithCause;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
Expand All @@ -31,6 +33,8 @@
import com._37coins.pojo.EnvayaRequest.MessageType;
import com.fasterxml.jackson.databind.ObjectMapper;



public class EnvayaClient {
private static final Logger log = LoggerFactory.getLogger(EnvayaClient.class);
public final static String AUTH_HEADER = "X-Request-Signature";
Expand Down Expand Up @@ -123,6 +127,26 @@ protected <K> K getPayload(HttpRequestBase request, Class<K> entityClass)
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);
}
}


if (isSucceed(response) && request.getMethod() != "DELETE") {
return parsePayload(response, entityClass);
} else if (isSucceed(response)) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/_37coins/EnvayaClientException.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ public Reason getReason() {

@Override
public String toString() {
return "ProductsClientException{" +
return "EnvayaClientException{" +
"reason=" + reason +
'}';
}

public String getMessage(){
return toString();
}

public enum Reason {
INVALID_URI,
Expand Down

0 comments on commit ab34319

Please sign in to comment.