cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1154874 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs...
Date Mon, 08 Aug 2011 08:48:33 GMT
Author: sergeyb
Date: Mon Aug  8 08:48:33 2011
New Revision: 1154874

URL: http://svn.apache.org/viewvc?rev=1154874&view=rev
Log:
Merged revisions 1154872 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes

................
  r1154872 | sergeyb | 2011-08-08 09:46:16 +0100 (Mon, 08 Aug 2011) | 9 lines
  
  Merged revisions 1154870 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1154870 | sergeyb | 2011-08-08 09:41:38 +0100 (Mon, 08 Aug 2011) | 1 line
    
    [CXF-3654] Optional reporting of uri mismatch related error messages
  ........
................

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  8 08:48:33 2011
@@ -1,2 +1,2 @@
-/cxf/branches/2.4.x-fixes:1153362,1153783,1153802
-/cxf/trunk:1153258,1153781,1153796
+/cxf/branches/2.4.x-fixes:1153362,1153783,1153802,1154872
+/cxf/trunk:1153258,1153781,1153796,1154870

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=1154874&r1=1154873&r2=1154874&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
Mon Aug  8 08:48:33 2011
@@ -244,7 +244,7 @@ public class JAXRSInvoker extends Abstra
                 Response excResponse;
                 if (JAXRSUtils.noResourceMethodForOptions(ex.getResponse(), 
                         (String)exchange.getInMessage().get(Message.HTTP_REQUEST_METHOD)))
{
-                    excResponse = JAXRSUtils.createResponse(subCri, 200, true);
+                    excResponse = JAXRSUtils.createResponse(subCri, null, null, 200, true);
                 } else {
                     excResponse = JAXRSUtils.convertFaultToResponse(ex, exchange.getInMessage());
                 }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java?rev=1154874&r1=1154873&r2=1154874&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
Mon Aug  8 08:48:33 2011
@@ -40,32 +40,23 @@ public class WebApplicationExceptionMapp
     private boolean printStackTrace;
     
     public Response toResponse(WebApplicationException ex) {
-        if (LOG.isLoggable(Level.WARNING)) {
-            String message = ex.getCause() == null ? ex.getMessage() : ex.getCause().getMessage();
-            if (message == null) {
-                if (ex.getCause() != null) {
-                    message = "cause is " + ex.getCause().getClass().getName();
-                } else {
-                    message = "no cause is available";
-                }
+        
+        String message = ex.getCause() == null ? ex.getMessage() : ex.getCause().getMessage();
+        if (message == null) {
+            if (ex.getCause() != null) {
+                message = "cause is " + ex.getCause().getClass().getName();
+            } else {
+                message = "no cause is available";
             }
-            org.apache.cxf.common.i18n.Message errorMsg = 
-                new org.apache.cxf.common.i18n.Message("WEB_APP_EXCEPTION", BUNDLE, message);
+        }
+        org.apache.cxf.common.i18n.Message errorMsg = 
+            new org.apache.cxf.common.i18n.Message("WEB_APP_EXCEPTION", BUNDLE, message);
+        if (LOG.isLoggable(Level.WARNING)) {
             LOG.warning(errorMsg.toString());
         }
         Response r = ex.getResponse(); 
         if (r == null) {
-            String message = null;
-            if (ex.getCause() == null) {
-                message = new org.apache.cxf.common.i18n.Message("DEFAULT_EXCEPTION_MESSAGE",

-                                                                 BUNDLE).toString();
-            } else {
-                message = ex.getCause().getMessage();
-                if (message == null) {
-                    message = ex.getCause().getClass().getName();
-                }
-            }
-            r = Response.status(500).type(MediaType.TEXT_PLAIN).entity(message).build();
+            r = Response.status(500).type(MediaType.TEXT_PLAIN).entity(errorMsg.toString()).build();
         }
         
         if (printStackTrace) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1154874&r1=1154873&r2=1154874&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Mon Aug  8 08:48:33 2011
@@ -146,8 +146,9 @@ public class JAXRSInInterceptor extends 
                                                    message.get(Message.REQUEST_URI),
                                                    rawPath);
             LOG.warning(errorMsg.toString());
-
-            throw new WebApplicationException(Response.Status.NOT_FOUND);
+            Response resp = JAXRSUtils.createResponse(resource, message, errorMsg.toString(),

+                    Response.Status.NOT_FOUND.getStatusCode(), false);
+            throw new WebApplicationException(resp);
         }
 
         message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);
@@ -207,7 +208,7 @@ public class JAXRSInInterceptor extends 
                 setExchangeProperties(message, ori, values, resources.size());
             } catch (WebApplicationException ex) {
                 if (JAXRSUtils.noResourceMethodForOptions(ex.getResponse(), httpMethod))
{
-                    Response response = JAXRSUtils.createResponse(resource, 200, true);
+                    Response response = JAXRSUtils.createResponse(resource, null, null, 200,
true);
                     message.getExchange().put(Response.class, response);
                     return;
                 } else {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1154874&r1=1154873&r2=1154874&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Mon Aug  8 08:48:33 2011
@@ -112,6 +112,7 @@ public final class JAXRSUtils {
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSUtils.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSUtils.class);
     private static final String PROPAGATE_EXCEPTION = "org.apache.cxf.propagate.exception";
+    private static final String REPORT_FAULT_MESSAGE_PROPERTY = "org.apache.cxf.jaxrs.report-fault-message";
     
     private JAXRSUtils() {        
     }
@@ -405,7 +406,8 @@ public final class JAXRSUtils {
         if (!"OPTIONS".equalsIgnoreCase(httpMethod) && logNow) {
             LOG.warning(errorMsg.toString());
         }
-        Response response = createResponse(resource, status, methodMatched == 0);
+        Response response = 
+            createResponse(resource, message, errorMsg.toString(), status, methodMatched
== 0);
         throw new WebApplicationException(response);
         
     }    
@@ -435,7 +437,8 @@ public final class JAXRSUtils {
         LOG.fine(errorMsg.toString());
     }
 
-    public static Response createResponse(ClassResourceInfo cri, int status, boolean addAllow)
{
+    public static Response createResponse(ClassResourceInfo cri, Message msg,
+                                          String responseMessage, int status, boolean addAllow)
{
         ResponseBuilder rb = Response.status(status);
         if (addAllow) {
             Set<String> allowedMethods = cri.getAllowedMethods();
@@ -450,6 +453,9 @@ public final class JAXRSUtils {
                 rb.header("Allow", "HEAD");
             }
         }
+        if (msg != null && MessageUtils.isTrue(msg.getContextualProperty(REPORT_FAULT_MESSAGE_PROPERTY)))
{
+            rb.type(MediaType.TEXT_PLAIN_TYPE).entity(responseMessage);
+        }
         return rb.build();
     }
     



Mime
View raw message