cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1405721 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/ main/java/org/apache/cxf/jaxrs/ext/multipart/ main/java/org/apache/cxf/jaxrs/interceptor/ main/java/org/apache/cxf/jaxrs/lifecycle/ main/java/org/apache/cxf/jax...
Date Mon, 05 Nov 2012 09:23:54 GMT
Author: sergeyb
Date: Mon Nov  5 09:23:53 2012
New Revision: 1405721

URL: http://svn.apache.org/viewvc?rev=1405721&view=rev
Log:
Reverting the code to do with mapping WAE to subclass mappers, updating the runtime to throw subclass exceptions instead of WAE where possible, as per the spec

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XPathProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java Mon Nov  5 09:23:53 2012
@@ -28,8 +28,7 @@ import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
+import javax.ws.rs.NotFoundException;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
@@ -312,7 +311,7 @@ public class AbstractJAXRSFactoryBean ex
                 new org.apache.cxf.common.i18n.Message("NO_RESOURCES_AVAILABLE", 
                                                        BUNDLE);
             LOG.severe(msg.toString());
-            throw new WebApplicationException(Response.Status.NOT_FOUND);
+            throw new NotFoundException();
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Mon Nov  5 09:23:53 2012
@@ -28,6 +28,8 @@ import java.util.List;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ServiceUnavailableException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.container.AsyncResponse;
 import javax.ws.rs.core.Application;
@@ -94,7 +96,7 @@ public class JAXRSInvoker extends Abstra
                 } else if (asyncImpl.handleTimeout()) {
                     return null;
                 } else {
-                    return handleFault(new Fault(new WebApplicationException(503)), 
+                    return handleFault(new Fault(new ServiceUnavailableException()), 
                                        exchange.getInMessage(), null, null);
                 }
             }
@@ -233,7 +235,7 @@ public class JAXRSInvoker extends Abstra
                                                                BUNDLE,
                                                                subResourcePath);
                     LOG.severe(errorM.toString());
-                    throw new WebApplicationException(404);
+                    throw new NotFoundException();
                 }
 
                 OperationResourceInfo subOri = JAXRSUtils.findTargetMethod(subCri,
@@ -254,8 +256,7 @@ public class JAXRSInvoker extends Abstra
             } catch (IOException ex) {
                 Response resp = JAXRSUtils.convertFaultToResponse(ex, exchange.getInMessage());
                 if (resp == null) {
-                    resp = JAXRSUtils.convertFaultToResponse(new WebApplicationException(ex), 
-                                                             exchange.getInMessage());
+                    resp = JAXRSUtils.convertFaultToResponse(ex, exchange.getInMessage());
                 }
                 return new MessageContentsList(resp);
             } catch (WebApplicationException ex) {
@@ -372,7 +373,7 @@ public class JAXRSInvoker extends Abstra
                                                        BUNDLE,
                                                        subResourcePath);
             LOG.info(errorM.toString());
-            throw new WebApplicationException(404);
+            throw new NotFoundException();
         }
 
         return result;

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java Mon Nov  5 09:23:53 2012
@@ -25,7 +25,7 @@ import java.util.List;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -132,7 +132,7 @@ public class Attachment {
                     return mbr.readFrom(cls, cls, new Annotation[]{}, getContentType(), 
                                         headers, getDataHandler().getInputStream());
                 } catch (Exception ex) {
-                    throw new WebApplicationException(ex);
+                    throw new InternalServerErrorException(ex);
                 }
             }
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Mon Nov  5 09:23:53 2012
@@ -25,6 +25,9 @@ import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotAcceptableException;
+import javax.ws.rs.NotFoundException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -143,7 +146,7 @@ public class JAXRSInInterceptor extends 
         try {
             acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes);
         } catch (IllegalArgumentException ex) {
-            throw new WebApplicationException(406);
+            throw new NotAcceptableException();
         }
         message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
 
@@ -161,7 +164,7 @@ public class JAXRSInInterceptor extends 
             LOG.warning(errorMsg.toString());
             Response resp = JAXRSUtils.createResponse(resource, message, errorMsg.toString(), 
                     Response.Status.NOT_FOUND.getStatusCode(), false);
-            throw new WebApplicationException(resp);
+            throw new NotFoundException(resp);
         }
 
         message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);
@@ -226,7 +229,7 @@ public class JAXRSInInterceptor extends 
         } catch (IOException ex) {
             Response excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
             if (excResponse == null) {
-                throw new WebApplicationException(ex);
+                throw new InternalServerErrorException(ex);
             } else {
                 message.getExchange().put(Response.class, excResponse);
             }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/lifecycle/PerRequestResourceProvider.java Mon Nov  5 09:23:53 2012
@@ -23,7 +23,7 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Response;
 
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
@@ -72,16 +72,16 @@ public class PerRequestResourceProvider 
             return instance;
         } catch (InstantiationException ex) {
             String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated";
-            throw new WebApplicationException(Response.serverError().entity(msg).build());
+            throw new InternalServerErrorException(Response.serverError().entity(msg).build());
         } catch (IllegalAccessException ex) {
             String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated"
                 + " due to IllegalAccessException";
-            throw new WebApplicationException(Response.serverError().entity(msg).build());
+            throw new InternalServerErrorException(Response.serverError().entity(msg).build());
         } catch (InvocationTargetException ex) {
             String msg = "Resource class "
                 + c.getDeclaringClass().getName() + " can not be instantiated"
                 + " due to InvocationTargetException";
-            throw new WebApplicationException(Response.serverError().entity(msg).build());
+            throw new InternalServerErrorException(Response.serverError().entity(msg).build());
         }
         
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java Mon Nov  5 09:23:53 2012
@@ -46,7 +46,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger;
 
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -266,7 +267,7 @@ public class WadlGenerator implements Re
         try {
             return DOMUtils.readXml(new StringReader(entity));
         }  catch (Exception ex) {
-            throw new WebApplicationException(ex, 500);
+            throw new InternalServerErrorException(ex);
         }
     }
     
@@ -874,7 +875,7 @@ public class WadlGenerator implements Re
                         
                     }
                 } catch (Exception ex) {
-                    throw new WebApplicationException(ex, 500);
+                    throw new InternalServerErrorException(ex);
                 }
             }
         }
@@ -898,7 +899,7 @@ public class WadlGenerator implements Re
                         new DOMSource(docEl)).build();
                 }
             } catch (Exception ex) {
-                throw new WebApplicationException(ex, 400);
+                throw new BadRequestException();
             }
             
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Mon Nov  5 09:23:53 2012
@@ -37,6 +37,8 @@ import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.logging.Logger;
 
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -203,7 +205,7 @@ public abstract class AbstractJAXBProvid
     protected void reportEmptyContentLength() {
         String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
         LOG.warning(message);
-        throw new WebApplicationException(400);
+        throw new BadRequestException();
     }
     
     protected <X> X getStreamHandlerFromCurrentMessage(Class<X> staxCls) {
@@ -633,7 +635,7 @@ public abstract class AbstractJAXBProvid
             ? Response.Status.BAD_REQUEST : Response.Status.INTERNAL_SERVER_ERROR; 
         Response r = Response.status(status)
             .type(MediaType.TEXT_PLAIN).entity(message).build();
-        throw new WebApplicationException(t, r);
+        throw read ? new BadRequestException(r, t) : new InternalServerErrorException(r, t);
     }
     
     protected static void handleJAXBException(JAXBException e, boolean read) {
@@ -736,7 +738,7 @@ public abstract class AbstractJAXBProvid
                         ? Integer.valueOf(innerElementCountStr) : -1;
                     return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount);
                 } catch (Exception ex) {
-                    throw new WebApplicationException(ex);
+                    throw new InternalServerErrorException(ex);
                 }
             }
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java Mon Nov  5 09:23:53 2012
@@ -24,9 +24,10 @@ import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -72,7 +73,7 @@ public class DataBindingProvider<T> impl
             Object o = dataReader.read(null, reader, clazz);
             return o == null ? null : clazz.cast(o);
         } catch (Exception ex) {
-            throw new WebApplicationException(ex);
+            throw new BadRequestException(ex);
         } finally {
             StaxUtils.close(reader);
         }
@@ -102,7 +103,7 @@ public class DataBindingProvider<T> impl
             writer = createWriter(clazz, genericType, os);
             writeToWriter(writer, o);
         } catch (Exception ex) {
-            throw new WebApplicationException(ex);
+            throw new InternalServerErrorException(ex);
         } finally {
             StaxUtils.close(writer);
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java Mon Nov  5 09:23:53 2012
@@ -25,6 +25,7 @@ import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Encoded;
 import javax.ws.rs.Produces;
@@ -114,7 +115,7 @@ public class FormEncodingProvider<T> imp
         } catch (WebApplicationException e) {
             throw e;
         } catch (Exception e) {
-            throw new WebApplicationException(e);
+            throw new BadRequestException(e);
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Mon Nov  5 09:23:53 2012
@@ -34,7 +34,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
@@ -191,7 +193,7 @@ public class JAXBElementProvider<T> exte
             throw e;
         } catch (Exception e) {
             LOG.warning(getStackTrace(e));
-            throw new WebApplicationException(e, Response.status(400).build());        
+            throw new BadRequestException(e);        
         } finally {
             StaxUtils.close(reader);
         }
@@ -223,7 +225,7 @@ public class JAXBElementProvider<T> exte
                 try {
                     reader = factory.createXMLStreamReader(is);
                 } catch (XMLStreamException e) {
-                    throw new WebApplicationException(
+                    throw new InternalServerErrorException(
                         new RuntimeException("Can not create XMLStreamReader", e));
                 }
             }
@@ -252,7 +254,7 @@ public class JAXBElementProvider<T> exte
                 Reader reader = getStreamHandlerFromCurrentMessage(Reader.class);
                 if (reader == null) {
                     LOG.severe("No InputStream, Reader, or XMStreamReader is available");
-                    throw new WebApplicationException(500);
+                    throw new InternalServerErrorException();
                 }
                 xmlReader = StaxUtils.createXMLStreamReader(reader);
             } else {
@@ -288,7 +290,7 @@ public class JAXBElementProvider<T> exte
             throw e;
         } catch (Exception e) {
             e.printStackTrace();
-            throw new WebApplicationException(e);        
+            throw new InternalServerErrorException(e);        
         }
     }
 
@@ -531,7 +533,7 @@ public class JAXBElementProvider<T> exte
                     try {
                         writer = factory.createXMLStreamWriter(os);
                     } catch (XMLStreamException e) {
-                        throw new WebApplicationException(
+                        throw new InternalServerErrorException(
                             new RuntimeException("Cant' create XMLStreamWriter", e));
                     }
                 }
@@ -553,7 +555,7 @@ public class JAXBElementProvider<T> exte
             Writer writer = getStreamHandlerFromCurrentMessage(Writer.class);
             if (writer == null) {
                 LOG.severe("No OutputStream, Writer, or XMStreamWriter is available");
-                throw new WebApplicationException(500);
+                throw new InternalServerErrorException();
             }
             ms.marshal(obj, writer);
             writer.flush();

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java Mon Nov  5 09:23:53 2012
@@ -21,7 +21,6 @@ package org.apache.cxf.jaxrs.provider;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -40,7 +39,9 @@ import java.util.logging.Logger;
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.mail.internet.MimeUtility;
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
@@ -172,7 +173,7 @@ public class MultipartProvider extends A
             return null;
         }
         
-        throw new WebApplicationException(400);
+        throw new BadRequestException();
         
     }
     
@@ -266,7 +267,7 @@ public class MultipartProvider extends A
     
     private List<Attachment> convertToDataHandlers(Object obj,
                                                    Class<?> type, Type genericType,                          
-                                                   Annotation[] anns, MediaType mt) {
+                                                   Annotation[] anns, MediaType mt)  throws IOException {
         if (Map.class.isAssignableFrom(obj.getClass())) {
             Map<Object, Object> objects = CastUtils.cast((Map<?, ?>)obj);
             List<Attachment> handlers = new ArrayList<Attachment>(objects.size());
@@ -301,7 +302,7 @@ public class MultipartProvider extends A
         }
     }
     
-    private List<Attachment> getAttachments(List<?> objects, String rootMediaType) {
+    private List<Attachment> getAttachments(List<?> objects, String rootMediaType) throws IOException {
         List<Attachment> handlers = new ArrayList<Attachment>(objects.size());
         for (int i = 0; i < objects.size(); i++) {
             Object value = objects.get(i);
@@ -318,7 +319,7 @@ public class MultipartProvider extends A
                                              Annotation[] anns,
                                              String mimeType,
                                              String mainMediaType,
-                                             int id) {
+                                             int id) throws IOException {
         @SuppressWarnings("unchecked")
         Class<T> cls = (Class<T>)obj.getClass();
         return createDataHandler(obj, cls, genericType, anns, mimeType, mainMediaType, id);
@@ -329,7 +330,7 @@ public class MultipartProvider extends A
                                          Annotation[] anns,
                                          String mimeType,
                                          String mainMediaType,
-                                         int id) {
+                                         int id) throws IOException {
         DataHandler dh = null;
         if (InputStream.class.isAssignableFrom(obj.getClass())) {
             dh = createInputStreamDH((InputStream)obj, mimeType);
@@ -341,11 +342,7 @@ public class MultipartProvider extends A
             File f = (File)obj;
             ContentDisposition cd = mainMediaType.startsWith(MediaType.MULTIPART_FORM_DATA) 
                 ? new ContentDisposition("form-data;name=file;filename=" + f.getName()) :  null;
-            try {
-                return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, new FileInputStream(f), cd);
-            } catch (FileNotFoundException ex) {
-                throw new WebApplicationException(ex);
-            }
+            return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, new FileInputStream(f), cd);
         } else if (Attachment.class.isAssignableFrom(obj.getClass())) {
             Attachment att = (Attachment)obj;
             if (att.getObject() == null) {
@@ -394,7 +391,7 @@ public class MultipartProvider extends A
                                                    BUNDLE,
                                                    cls);
             LOG.severe(message.toString());
-            throw new WebApplicationException(500);
+            throw new InternalServerErrorException();
         }
         
         return new MessageBodyWriterDataHandler<T>(r, obj, cls, genericType, anns, mt);
@@ -459,7 +456,7 @@ public class MultipartProvider extends A
                 writer.writeTo(obj, cls, genericType, anns, contentType, 
                                new MetadataMap<String, Object>(), os);
             } catch (IOException ex) {
-                throw new WebApplicationException();
+                throw new InternalServerErrorException(ex);
             }
         }
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Mon Nov  5 09:23:53 2012
@@ -39,7 +39,6 @@ import java.util.logging.Logger;
 
 import javax.ws.rs.BindingPriority;
 import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.client.ClientRequestFilter;
 import javax.ws.rs.client.ClientResponseFilter;
 import javax.ws.rs.container.ContainerRequestFilter;
@@ -333,40 +332,21 @@ public final class ProviderFactory {
         return null;
     }
     
-    //This method can only be called from providers
     public <T extends Throwable> ExceptionMapper<T> createExceptionMapper(Class<?> exceptionType,
                                                                           Message m) {
-        return createExceptionMapper(null, exceptionType, m);
-    }
-    
-    public <T extends Throwable> ExceptionMapper<T> createExceptionMapper(T ex, 
-                                                                          Message m) {
-        return createExceptionMapper(ex, ex.getClass(), m);
-    }
-    
-    private <T extends Throwable> ExceptionMapper<T> createExceptionMapper(T ex, 
-                                                                           Class<?> exceptionType,
-                                                                           Message m) {
-        
-        ExceptionMapper<T> mapper = doCreateExceptionMapper(ex, exceptionType, m);
+        ExceptionMapper<T> mapper = doCreateExceptionMapper(exceptionType, m);
         if (mapper != null || this == SHARED_FACTORY) {
             return mapper;
         }
         
-        return SHARED_FACTORY.createExceptionMapper(ex, exceptionType, m);
+        return SHARED_FACTORY.createExceptionMapper(exceptionType, m);
     }
     
     @SuppressWarnings("unchecked")
     private <T extends Throwable> ExceptionMapper<T> doCreateExceptionMapper(
-        T exception, Class<?> exceptionType, Message m) {
+        Class<?> exceptionType, Message m) {
         
         List<ExceptionMapper<?>> candidates = new LinkedList<ExceptionMapper<?>>();
-        if (WebApplicationException.class == exceptionType 
-            && exception instanceof WebApplicationException) {
-            exceptionType = 
-                JAXRSUtils.getWebApplicationExceptionClass(((WebApplicationException)exception).getResponse(), 
-                                                           exceptionType);
-        }
         for (ProviderInfo<ExceptionMapper<?>> em : exceptionMappers) {
             handleMapper(candidates, em, exceptionType, m, ExceptionMapper.class, true);
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java Mon Nov  5 09:23:53 2012
@@ -34,8 +34,8 @@ import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -185,7 +185,7 @@ public class RequestDispatcherProvider e
         } catch (Throwable ex) {
             mc.put(AbstractHTTPDestination.REQUEST_REDIRECTED, Boolean.FALSE);
             ex.printStackTrace();
-            throw new WebApplicationException(ex);
+            throw new InternalServerErrorException(ex);
         }
     }
 
@@ -244,7 +244,7 @@ public class RequestDispatcherProvider e
                     new org.apache.cxf.common.i18n.Message("RESOURCE_DISPATCH_NOT_FOUND", 
                                                            BUNDLE, servletContextPath).toString();
                 LOG.severe(message);
-                throw new WebApplicationException();
+                throw new InternalServerErrorException();
             }
         }
         return sc; 
@@ -259,7 +259,7 @@ public class RequestDispatcherProvider e
                 new org.apache.cxf.common.i18n.Message("RESOURCE_PATH_NOT_FOUND", 
                                                        BUNDLE, path).toString();
             LOG.severe(message);
-            throw new WebApplicationException();
+            throw new InternalServerErrorException();
         }
         return rd;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java Mon Nov  5 09:23:53 2012
@@ -26,6 +26,7 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
@@ -165,7 +166,7 @@ public class SourceProvider<T> extends A
         try {
             StaxUtils.copy(reader, writer);
         } catch (XMLStreamException e) {
-            throw new WebApplicationException(e);
+            throw new InternalServerErrorException(e);
         } finally {
             try {
                 reader.close();

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XPathProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XPathProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XPathProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XPathProvider.java Mon Nov  5 09:23:53 2012
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -83,7 +84,7 @@ public class XPathProvider<T> implements
             : classExpressions.get(cls.getName());
         if (expression == null) {
             // must not happen if isReadable() returned true
-            throw new WebApplicationException(500);
+            throw new InternalServerErrorException();
         }
         XMLSource source = new XMLSource(is);
         return source.getNode(expression, globalNamespaces, cls);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java Mon Nov  5 09:23:53 2012
@@ -31,9 +31,10 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.logging.Logger;
 
+import javax.ws.rs.BadRequestException;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.PathSegment;
@@ -175,7 +176,7 @@ public class XSLTJaxbProvider<T> extends
             return unmarshaller.unmarshal(source);
         } catch (TransformerConfigurationException ex) {
             LOG.warning("Transformation exception : " + ex.getMessage());
-            throw new WebApplicationException(ex);
+            throw new InternalServerErrorException(ex);
         }
     }
     
@@ -190,7 +191,7 @@ public class XSLTJaxbProvider<T> extends
             writer.close();
             return unmarshalFromInputStream(unmarshaller, out.getInputStream(), mt);
         } catch (Exception ex) {
-            throw new WebApplicationException(ex);
+            throw new BadRequestException(ex);
         }
     }
     
@@ -307,7 +308,7 @@ public class XSLTJaxbProvider<T> extends
                 return null;
             } else {
                 LOG.severe("No template is available");
-                throw new WebApplicationException(500);
+                throw new InternalServerErrorException();
             }
         }
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java Mon Nov  5 09:23:53 2012
@@ -28,7 +28,7 @@ import javax.security.auth.callback.Call
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.NotAuthorizedException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
@@ -73,12 +73,12 @@ public class KerberosAuthenticationFilte
             .getRequestHeader(HttpHeaders.AUTHORIZATION);
         if (authHeaders.size() != 1) {
             LOG.fine("No Authorization header is available");
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         }
         String[] authPair = authHeaders.get(0).split(" ");
         if (authPair.length != 2 || !NEGOTIATE_SCHEME.equalsIgnoreCase(authPair[0])) {
             LOG.fine("Negotiate Authorization scheme is expected");
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         }
                 
         byte[] serviceTicket = getServiceTicket(authPair[1]);
@@ -92,7 +92,7 @@ public class KerberosAuthenticationFilte
             
             GSSName srcName = gssContext.getSrcName();
             if (srcName == null) {
-                throw new WebApplicationException(getFaultResponse());
+                throw new NotAuthorizedException(getFaultResponse());
             }
             
             String complexUserName = srcName.toString();
@@ -114,13 +114,13 @@ public class KerberosAuthenticationFilte
             
         } catch (LoginException e) {
             LOG.fine("Unsuccessful JAAS login for the service principal");
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         } catch (GSSException e) {
             LOG.fine("GSS API exception: " + e.getMessage());
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         } catch (PrivilegedActionException e) {
             LOG.fine("PrivilegedActionException: " + e.getMessage());
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         }
         
         return null;
@@ -163,7 +163,7 @@ public class KerberosAuthenticationFilte
         try {
             return Base64Utility.decode(encodedServiceTicket);
         } catch (Base64Exception ex) {
-            throw new WebApplicationException(getFaultResponse());
+            throw new NotAuthorizedException(getFaultResponse());
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java Mon Nov  5 09:23:53 2012
@@ -31,6 +31,8 @@ import java.util.Map;
 import java.util.logging.Logger;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
 
@@ -75,7 +77,7 @@ public final class FormUtils {
             IOUtils.copy(is, bos, 1024);
             return new String(bos.toByteArray(), encoding);
         } catch (Exception ex) {
-            throw new WebApplicationException(ex);
+            throw new InternalServerErrorException(ex);
         }
     }
     
@@ -163,7 +165,7 @@ public final class FormUtils {
             String contentId = a.getContentId();
             String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", "");
             if (StringUtils.isEmpty(name)) { 
-                throw new WebApplicationException(400);
+                throw new BadRequestException();
             }
             if (CONTENT_DISPOSITION_FILES_PARAM.equals(name)) {
                 // this is a reserved name in Content-Disposition for parts containing files
@@ -176,9 +178,9 @@ public final class FormUtils {
             } catch (IllegalArgumentException ex) {
                 LOG.warning("Illegal URL-encoded characters, make sure that no "
                     + "@FormParam and @Multipart annotations are mixed up");
-                throw new WebApplicationException(415);
+                throw new InternalServerErrorException();
             } catch (IOException ex) {
-                throw new WebApplicationException(415);
+                throw new BadRequestException();
             }
         }
     }
@@ -198,7 +200,7 @@ public final class FormUtils {
                 throw new WebApplicationException(413);
             }
         } catch (NumberFormatException ex) {
-            throw new WebApplicationException(500);
+            throw new InternalServerErrorException();
         }
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Mon Nov  5 09:23:53 2012
@@ -50,6 +50,10 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.logging.Logger;
 
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.HttpHeaders;
@@ -311,9 +315,9 @@ public final class InjectionUtils {
                 //
                 if (pType == ParameterType.PATH || pType == ParameterType.QUERY
                     || pType == ParameterType.MATRIX) {
-                    throw new WebApplicationException(nfe, Response.Status.NOT_FOUND);
+                    throw new NotFoundException(nfe);
                 }
-                throw new WebApplicationException(nfe, Response.Status.BAD_REQUEST);
+                throw new BadRequestException(nfe);
             }
         }
         
@@ -343,7 +347,7 @@ public final class InjectionUtils {
                 LOG.severe(new org.apache.cxf.common.i18n.Message("CLASS_CONSTRUCTOR_FAILURE", 
                                                                    BUNDLE, 
                                                                    pClass.getName()).toString());
-                throw new WebApplicationException(ex, HttpUtils.getParameterFailureStatus(pType));
+                throw new ServerErrorException(HttpUtils.getParameterFailureStatus(pType), ex);
             }
         }
         if (result == null) {
@@ -414,7 +418,7 @@ public final class InjectionUtils {
         Response r = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
                          .type(MediaType.TEXT_PLAIN_TYPE)
                          .entity(errorMessage.toString()).build();
-        throw new WebApplicationException(r);
+        throw new InternalServerErrorException(r);
     }
     
     private static <T> T evaluateFactoryMethod(String value,
@@ -1118,7 +1122,7 @@ public final class InjectionUtils {
             } catch (IllegalAccessException ex) {
                 String msg = "Method " + method.getName() + " can not be invoked"
                     + " due to IllegalAccessException";
-                throw new WebApplicationException(Response.serverError().entity(msg).build());
+                throw new InternalServerErrorException(Response.serverError().entity(msg).build());
             } 
         }
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Mon Nov  5 09:23:53 2012
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
@@ -116,7 +115,6 @@ import org.apache.cxf.jaxrs.impl.Request
 import org.apache.cxf.jaxrs.impl.ResourceInfoImpl;
 import org.apache.cxf.jaxrs.impl.SecurityContextImpl;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
-import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.impl.WriterInterceptorContextImpl;
 import org.apache.cxf.jaxrs.impl.WriterInterceptorMBW;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -356,7 +354,7 @@ public final class JAXRSUtils {
             requestType = requestContentType == null
                                 ? ALL_TYPES : MediaType.valueOf(requestContentType);
         } catch (IllegalArgumentException ex) {
-            throw new WebApplicationException(ex, 415);
+            throw new NotSupportedException(ex);
         }
 
         int pathMatched = 0;
@@ -456,7 +454,7 @@ public final class JAXRSUtils {
         }
         Response response = 
             createResponse(resource, message, errorMsg.toString(), status, methodMatched == 0);
-        throw new WebApplicationException(response);
+        throw new ClientErrorException(response);
         
     }    
     
@@ -800,7 +798,7 @@ public final class JAXRSUtils {
                                                                BUNDLE, 
                                                                mt.toString());
                     LOG.warning(errorMsg.toString());
-                    throw new WebApplicationException(415);
+                    throw new NotSupportedException();
                 }
             }
         }
@@ -1348,38 +1346,17 @@ public final class JAXRSUtils {
         return cls == null ? defaultExceptionType : cls;
     }
     
-    @SuppressWarnings("unchecked")
     public static <T extends Throwable> Response convertFaultToResponse(T ex, Message inMessage) {
-        ProviderFactory factory = ProviderFactory.getInstance(inMessage);
-        ExceptionMapper<T> mapper = factory.createExceptionMapper(ex, inMessage);
+        ExceptionMapper<T>  mapper =
+            ProviderFactory.getInstance(inMessage).createExceptionMapper(ex.getClass(), inMessage);
         if (mapper != null) {
-            if (!WebApplicationExceptionMapper.class.isAssignableFrom(mapper.getClass())
-                && WebApplicationException.class.isAssignableFrom(ex.getClass())) {
-                
-                WebApplicationException webEx = (WebApplicationException)ex;
-                Class<?> exceptionClass = getWebApplicationExceptionClass(webEx.getResponse(), 
-                                                                          WebApplicationException.class);
-                if (exceptionClass != WebApplicationException.class) {
-                    try {
-                        Constructor<?> ctr = exceptionClass.getConstructor(Response.class, Throwable.class);
-                        ex = (T)ctr.newInstance(webEx.getResponse(), webEx.getCause());
-                    } catch (Exception ex2) {
-                        ex2.printStackTrace();
-                        return Response.serverError().build();
-                    }
-                }
-            }
-            
             try {
                 return mapper.toResponse(ex);
             } catch (Exception mapperEx) {
                 mapperEx.printStackTrace();
                 return Response.serverError().build();
-            } finally {
-                factory.clearExceptionMapperProxies();
             }
         }
-        
         return null;
         
     }
@@ -1434,7 +1411,7 @@ public final class JAXRSUtils {
                 try {
                     filter.getProvider().filter(context);
                 } catch (IOException ex) {
-                    throw new WebApplicationException(ex);
+                    throw new InternalServerErrorException(ex);
                 }
                 if (m.getExchange().get(Response.class) != null) {
                     return true;

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java Mon Nov  5 09:23:53 2012
@@ -27,7 +27,8 @@ import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.NotSupportedException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 
@@ -116,8 +117,8 @@ public final class AttachmentUtils {
                                                            id.value(),
                                                            mt.toString());
                 LOG.warning(errorMsg.toString());
-                throw new WebApplicationException(
-                          new MultipartReadException(id.value(), id.type(), errorMsg.toString()), 400);
+                throw new BadRequestException(
+                          new MultipartReadException(id.value(), id.type(), errorMsg.toString()));
             } else {
                 return null;
             }
@@ -175,7 +176,7 @@ public final class AttachmentUtils {
     
     private static void checkMediaTypes(MediaType mt1, String mt2) {
         if (!mt1.isCompatible(MediaType.valueOf(mt2))) {                                            
-            throw new WebApplicationException(415);
+            throw new NotSupportedException();
         }
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Mon Nov  5 09:23:53 2012
@@ -1227,6 +1227,7 @@ public class JAXBElementProviderTest ext
                              new MetadataMap<String, Object>(), new ByteArrayOutputStream());
             fail("Validation exception expected");
         } catch (Exception ex) {
+            ex.printStackTrace();
             Throwable cause = ex.getCause();
             assertTrue(cause.getMessage().contains("Cannot find the declaration of element"));
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1405721&r1=1405720&r2=1405721&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Mon Nov  5 09:23:53 2012
@@ -37,12 +37,8 @@ import java.util.concurrent.TimeUnit;
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.ws.rs.Consumes;
-import javax.ws.rs.InternalServerErrorException;
-import javax.ws.rs.NotFoundException;
 import javax.ws.rs.Produces;
-import javax.ws.rs.ServerErrorException;
 import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
@@ -74,7 +70,6 @@ import org.apache.cxf.jaxrs.model.wadl.W
 import org.apache.cxf.jaxrs.provider.ProviderFactory.LegacyParamConverter;
 import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.resources.SuperBook;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -324,67 +319,6 @@ public class ProviderFactoryTest extends
     }
     
     @Test
-    public void testNotFoundExceptionMapper() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        Message message = prepareMessage(pf);
-        
-        
-        ExceptionMapper<?> mapper = 
-            pf.createExceptionMapper(WebApplicationException.class, message);
-        assertTrue(mapper instanceof WebApplicationExceptionMapper);
-        
-        mapper = pf.createExceptionMapper(NotFoundException.class, message);
-        assertTrue(mapper instanceof WebApplicationExceptionMapper);
-        
-        NotFoundExceptionMapper nf = new NotFoundExceptionMapper(); 
-        pf.registerUserProvider(nf);
-        
-        mapper = pf.createExceptionMapper(NotFoundException.class, message);
-        assertSame(mapper, nf);
-        
-        mapper = pf.createExceptionMapper(new NotFoundException(), message);
-        assertSame(mapper, nf);
-        
-        mapper = pf.createExceptionMapper(new WebApplicationException(404), message);
-        assertSame(mapper, nf);
-        
-        Response r = JAXRSUtils.convertFaultToResponse(new NotFoundException(), message);
-        assertNotNull(r);
-        assertEquals(404, r.getStatus());
-        
-        r = JAXRSUtils.convertFaultToResponse(new WebApplicationException(404), message);
-        assertNotNull(r);
-        assertEquals(404, r.getStatus());
-    }
-    
-    @Test
-    public void testServerErrorExceptionMapper() throws Exception {
-        ProviderFactory pf = ProviderFactory.getInstance();
-        Message message = prepareMessage(pf);
-        
-        ServerErrorExceptionMapper nf = new ServerErrorExceptionMapper(); 
-        pf.registerUserProvider(nf);
-        
-        ExceptionMapper<?> mapper = pf.createExceptionMapper(ServerErrorException.class, message);
-        assertSame(mapper, nf);
-        
-        mapper = pf.createExceptionMapper(new ServerErrorException(500), message);
-        assertSame(mapper, nf);
-        
-        mapper = pf.createExceptionMapper(new WebApplicationException(500), message);
-        assertSame(mapper, nf);
-        
-        mapper = pf.createExceptionMapper(new InternalServerErrorException(), message);
-        assertSame(mapper, nf);
-        
-        InternalServerErrorExceptionMapper is = new InternalServerErrorExceptionMapper(); 
-        pf.registerUserProvider(is);
-        
-        mapper = pf.createExceptionMapper(new InternalServerErrorException(), message);
-        assertSame(mapper, is);
-    }
-    
-    @Test
     public void testExceptionMappersHierarchy1() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper(); 
@@ -610,29 +544,6 @@ public class ProviderFactoryTest extends
                    instanceof JAXBContextProvider2);
     }
     
-    private Message prepareMessage(ProviderFactory pf) {
-        
-        Message m = new MessageImpl();
-        m.put("org.apache.cxf.http.case_insensitive_queries", false);
-        Exchange e = new ExchangeImpl();
-        m.setExchange(e);
-        e.setInMessage(m);
-        Endpoint endpoint = EasyMock.createMock(Endpoint.class);
-        endpoint.getEndpointInfo();
-        EasyMock.expectLastCall().andReturn(null).anyTimes();
-        endpoint.get(Application.class.getName());
-        EasyMock.expectLastCall().andReturn(null);
-        endpoint.size();
-        EasyMock.expectLastCall().andReturn(0).anyTimes();
-        endpoint.isEmpty();
-        EasyMock.expectLastCall().andReturn(true).anyTimes();
-        endpoint.get(ProviderFactory.class.getName());
-        EasyMock.expectLastCall().andReturn(pf).anyTimes();
-        EasyMock.replay(endpoint);
-        e.put(Endpoint.class, endpoint);
-        return m;
-    }
-    
     private Message prepareMessage(String contentType, String acceptType) {
         Message message = new MessageImpl();
         Map<String, List<String>> headers = new MetadataMap<String, String>();
@@ -970,27 +881,5 @@ public class ProviderFactoryTest extends
         }
         
     }
-    
-    private static class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {
-
-        public Response toResponse(NotFoundException arg0) {
-            return Response.status(404).build();
-        }
-    }
-    
-    private static class ServerErrorExceptionMapper implements ExceptionMapper<ServerErrorException> {
-
-        public Response toResponse(ServerErrorException arg0) {
-            return Response.status(404).build();
-        }
-    }
-    
-    private static class InternalServerErrorExceptionMapper 
-        implements ExceptionMapper<InternalServerErrorException> {
-
-        public Response toResponse(InternalServerErrorException arg0) {
-            return Response.status(404).build();
-        }
-    }
-
+        
 }



Mime
View raw message