cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1482410 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs: impl/AbstractRequestContextImpl.java impl/ContainerRequestContextImpl.java utils/JAXRSUtils.java
Date Tue, 14 May 2013 15:51:50 GMT
Author: sergeyb
Date: Tue May 14 15:51:49 2013
New Revision: 1482410

URL: http://svn.apache.org/r1482410
Log:
[CXF-5007] More API updates

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java?rev=1482410&r1=1482409&r2=1482410&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractRequestContextImpl.java
Tue May 14 15:51:49 2013
@@ -28,6 +28,7 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
 
 public abstract class AbstractRequestContextImpl extends AbstractPropertiesImpl {
@@ -78,7 +79,7 @@ public abstract class AbstractRequestCon
     }
 
     public String getMethod() {
-        return (String)getProperty(Message.HTTP_REQUEST_METHOD);
+        return HttpUtils.getProtocolHeader(m, Message.HTTP_REQUEST_METHOD, null);
     }
 
     public void setMethod(String method) throws IllegalStateException {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java?rev=1482410&r1=1482409&r2=1482410&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
Tue May 14 15:51:49 2013
@@ -23,6 +23,7 @@ import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Request;
@@ -45,7 +46,7 @@ public class ContainerRequestContextImpl
 
     @Override
     public InputStream getEntityStream() {
-        return m.get(InputStream.class);
+        return m.getContent(InputStream.class);
     }
 
 
@@ -56,7 +57,8 @@ public class ContainerRequestContextImpl
 
     @Override
     public SecurityContext getSecurityContext() {
-        return new SecurityContextImpl(m);
+        SecurityContext sc = m.get(SecurityContext.class);
+        return sc == null ? new SecurityContextImpl(m) : sc;
     }
 
     @Override
@@ -66,7 +68,8 @@ public class ContainerRequestContextImpl
 
     @Override
     public boolean hasEntity() {
-        return getEntityStream() != null;
+        InputStream is = getEntityStream();
+        return is != null && !HttpMethod.GET.equals(getMethod());
     }
 
     @Override
@@ -87,7 +90,7 @@ public class ContainerRequestContextImpl
     public void setRequestUri(URI requestUri) throws IllegalStateException {
         if (requestUri.isAbsolute()) {
             String baseUriString = new UriInfoImpl(m).getBaseUri().toString();
-            String requestUriString = new UriInfoImpl(m).getBaseUri().toString();
+            String requestUriString = requestUri.toString();
             if (!requestUriString.startsWith(baseUriString)) {
                 setRequestUri(requestUri, URI.create("/"));
                 return;
@@ -104,9 +107,7 @@ public class ContainerRequestContextImpl
     }
     
     public void doSetRequestUri(URI requestUri) throws IllegalStateException {
-        if (!preMatch) {
-            throw new IllegalStateException();
-        }
+        checkNotPreMatch();
         HttpUtils.resetRequestURI(m, requestUri.toString());
     }
 
@@ -122,7 +123,19 @@ public class ContainerRequestContextImpl
 
     @Override
     public void setSecurityContext(SecurityContext sc) {
+        checkContext();
         m.put(SecurityContext.class, sc);
     }
 
+    private void checkNotPreMatch() {
+        if (!preMatch) {
+            throw new IllegalStateException();
+        }
+    }
+    
+    @Override 
+    public void setMethod(String method) throws IllegalStateException {
+        checkNotPreMatch();
+        super.setMethod(method);
+    }
 }

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=1482410&r1=1482409&r2=1482410&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 Tue
May 14 15:51:49 2013
@@ -1613,12 +1613,14 @@ public final class JAXRSUtils {
         if (ex.getClass() == WebApplicationException.class) {
             WebApplicationException webEx = (WebApplicationException)ex;
             if (webEx.getResponse().hasEntity() 
-                && webEx.getCause() == null
-                && MessageUtils.isTrue(inMessage.getContextualProperty(SUPPORT_WAE_SPEC_OPTIMIZATION)))
{
-                response = webEx.getResponse();
-                
+                && webEx.getCause() == null) {
+                Object prop = inMessage.getContextualProperty(SUPPORT_WAE_SPEC_OPTIMIZATION);
+                if (prop == null || MessageUtils.isTrue(prop)) {
+                    response = webEx.getResponse();
+                }
             }
         }
+        
         if (response == null) {
             ExceptionMapper<T>  mapper =
                 ServerProviderFactory.getInstance(inMessage).createExceptionMapper(ex.getClass(),
inMessage);



Mime
View raw message