wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r816949 - in /incubator/wink/trunk: wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
Date Sat, 19 Sep 2009 19:38:50 GMT
Author: bluk
Date: Sat Sep 19 19:38:50 2009
New Revision: 816949

URL: http://svn.apache.org/viewvc?rev=816949&view=rev
Log:
Add general info messages to client

Fix issue with HTTP methods

Modified:
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
    incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java?rev=816949&r1=816948&r2=816949&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
Sat Sep 19 19:38:50 2009
@@ -45,8 +45,11 @@
 import org.apache.wink.client.internal.handlers.HandlerContextImpl;
 import org.apache.wink.common.http.HttpMethodEx;
 import org.apache.wink.common.internal.CaseInsensitiveMultivaluedMap;
+import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.registry.ProvidersRegistry;
 import org.apache.wink.common.internal.utils.HeaderUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ResourceImpl implements Resource {
 
@@ -59,6 +62,8 @@
     private Map<String, Object>            attributes;
     private UriBuilder                     uriBuilder;
 
+    private static Logger                  logger     = LoggerFactory.getLogger(ResourceImpl.class);
+
     public ResourceImpl(URI uri, ClientConfig config, ProvidersRegistry providersRegistry)
{
         this.config = config;
         this.providersRegistry = providersRegistry;
@@ -200,7 +205,9 @@
         HandlerContext context = createHandlerContext();
         try {
             ClientResponse response = context.doChain(request);
-            if (ClientUtils.isErrorCode(response.getStatusCode())) {
+            int statusCode = response.getStatusCode();
+            if (ClientUtils.isErrorCode(statusCode)) {
+                logger.info(Messages.getMessage("clientResponseIsErrorCode"), statusCode);
                 throw new ClientWebException(request, response);
             }
             return response;
@@ -219,9 +226,12 @@
                                                   Object requestEntity) {
         ClientRequest request = new ClientRequestImpl();
         request.setEntity(requestEntity);
-        request.setURI(uriBuilder.build());
+        URI requestURI = uriBuilder.build();
+        request.setURI(requestURI);
         request.setMethod(method);
         request.getHeaders().putAll(headers);
+        logger.info(Messages.getMessage("clientIssueRequest"),
+                    new Object[] {method, requestURI, requestEntity, headers});
         if (headers.getFirst(HttpHeaders.USER_AGENT) == null) {
             request.getHeaders().add(HttpHeaders.USER_AGENT, USER_AGENT);
         }
@@ -265,7 +275,7 @@
     }
 
     public <T> T get(EntityType<T> responseEntity) {
-        return invoke(HttpMethod.DELETE, responseEntity, null);
+        return invoke(HttpMethod.GET, responseEntity, null);
     }
 
     public ClientResponse get() {
@@ -289,7 +299,7 @@
     }
 
     public <T> T put(EntityType<T> responseEntity, Object requestEntity) {
-        return invoke(HttpMethod.POST, responseEntity, requestEntity);
+        return invoke(HttpMethod.PUT, responseEntity, requestEntity);
     }
 
     public ClientResponse put(Object requestEntity) {

Modified: incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties?rev=816949&r1=816948&r2=816949&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
(original)
+++ incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
Sat Sep 19 19:38:50 2009
@@ -116,4 +116,6 @@
 noMethodInClassSupportsHTTPMethod=Could not find any method in class {} that supports {}
 
 # Client Handler
-clientAcceptHeaderHandlerSetAccept=Accept header automatically set to: {}
\ No newline at end of file
+clientIssueRequest=Issuing client {} method request to URI at {} with {} entity and {} headers
+clientAcceptHeaderHandlerSetAccept=Accept header automatically set to: {}
+clientResponseIsErrorCode=Client response is an error code: {}



Mime
View raw message