cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r736600 - in /cxf/branches/2.1.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/attachment/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/...
Date Thu, 22 Jan 2009 10:40:57 GMT
Author: sergeyb
Date: Thu Jan 22 02:40:56 2009
New Revision: 736600

URL: http://svn.apache.org/viewvc?rev=736600&view=rev
Log:
Merged revisions 736358,736361-736362 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r736358 | sergeyb | 2009-01-21 18:17:31 +0000 (Wed, 21 Jan 2009) | 1 line
  
  JAXRS : support for multipart/related
........
  r736361 | sergeyb | 2009-01-21 18:20:30 +0000 (Wed, 21 Jan 2009) | 1 line
  
  Removing in-process test flags
........
  r736362 | sergeyb | 2009-01-21 18:23:27 +0000 (Wed, 21 Jan 2009) | 1 line
  
  Forgot that tcptrace was used to run the test
........

Added:
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MultipartID.java
      - copied unchanged from r736362, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MultipartID.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java
      - copied, changed from r736362, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java
      - copied unchanged from r736362, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
      - copied unchanged from r736362, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
      - copied unchanged from r736362, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
      - copied, changed from r736362, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/attachmentData
      - copied unchanged from r736362, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/attachmentData
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBindingFactory.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 22 02:40:56 2009
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736352,736408,736423
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732827,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736352,736358-736362,736408,736423

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

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Thu Jan 22 02:40:56 2009
@@ -24,8 +24,13 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLEncoder;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.UUID;
 
+import javax.activation.DataHandler;
+
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.message.Attachment;
 
@@ -79,4 +84,19 @@
         return buffer.toString();
     }
 
+    public static Map<String, DataHandler> getDHMap(Collection<Attachment> attachments)
{
+        Map<String, DataHandler> dataHandlers = null;
+        if (attachments != null) {
+            if (attachments instanceof LazyAttachmentCollection) {
+                dataHandlers = ((LazyAttachmentCollection)attachments).createDataHandlerMap();
+            } else {
+                //preserve the order of iteration
+                dataHandlers = new LinkedHashMap<String, DataHandler>();
+                for (Attachment attachment : attachments) {
+                    dataHandlers.put(attachment.getId(), attachment.getDataHandler());
+                }
+            }
+        }
+        return dataHandlers == null ? new LinkedHashMap<String, DataHandler>() : dataHandlers;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBindingFactory.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBindingFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSBindingFactory.java
Thu Jan 22 02:40:56 2009
@@ -21,9 +21,9 @@
 
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.binding.Binding;
-
 import org.apache.cxf.binding.xml.XMLBinding;
 import org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
 import org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor;
 import org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor;
@@ -40,7 +40,10 @@
     public Binding createBinding(BindingInfo bi) {
         XMLBinding binding = new XMLBinding(bi);
 
+        
+        binding.getInInterceptors().add(new AttachmentInInterceptor());
         binding.getInInterceptors().add(new JAXRSInInterceptor());
+        
         binding.getOutInterceptors().add(new JAXRSOutInterceptor());
         
         binding.getOutFaultInterceptors().add(new XMLFaultOutInterceptor());

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java
Thu Jan 22 02:40:56 2009
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.jaxrs.ext;
 
+import java.util.Map;
+
+import javax.activation.DataHandler;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -30,11 +33,18 @@
 import javax.ws.rs.ext.MessageBodyWorkers;
 
 /**
- * Represents an inbound internal message
+ * Represents an invocation context
  *
  */
 public interface MessageContext {
+    
+    String INBOUND_MESSAGE_ATTACHMENTS = "org.apache.cxf.jaxrs.attachments.inbound";
+    String OUTBOUND_MESSAGE_ATTACHMENTS = "org.apache.cxf.jaxrs.attachments.outbound";
+    
     Object get(Object key);
+    void put(Object key, Object value);
+    
+    Map<String, DataHandler> getAttachments();
     
     UriInfo getUriInfo();
     Request getRequest();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
Thu Jan 22 02:40:56 2009
@@ -19,7 +19,10 @@
 package org.apache.cxf.jaxrs.ext;
 
 import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Map;
 
+import javax.activation.DataHandler;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -31,7 +34,10 @@
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.MessageBodyWorkers;
 
+import org.apache.cxf.attachment.AttachmentUtil;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
 
 public class MessageContextImpl implements MessageContext {
@@ -43,9 +49,16 @@
     }
     
     public Object get(Object key) {
+        if (MessageContext.INBOUND_MESSAGE_ATTACHMENTS.equals(key.toString())) {
+            return createAttachments(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+        }
         return m.get(key);
     }
 
+    public Map<String, DataHandler> getAttachments() {
+        return createAttachments(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+    } 
+    
     public <T> T getContext(Class<T> contextClass) {
         return getContext(contextClass, contextClass);
     }
@@ -95,4 +108,20 @@
         return JAXRSUtils.createServletResourceValue(m, ServletContext.class);
     }
 
+    public void put(Object key, Object value) {
+        throw new UnsupportedOperationException("MessageContext.put() is not supported yet");
+    }
+
+    private Map<String, DataHandler> createAttachments(String propertyName) {
+        Object o = m.get(propertyName);
+        if (o != null) {
+            return CastUtils.cast((Map)o);
+        }
+        Collection<Attachment> attachments = m.getAttachments();
+        attachments.size();
+        Map<String, DataHandler> dataHandlers = AttachmentUtil.getDHMap(attachments);
+        m.put(propertyName, dataHandlers);
+        return dataHandlers;
+    }
+       
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java
Thu Jan 22 02:40:56 2009
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.jaxrs.impl.tl;
 
+import java.util.Map;
+
+import javax.activation.DataHandler;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -78,4 +81,16 @@
         return get() != null ? get().getRequest() : null;
     }
 
+    public Map<String, DataHandler> getAttachments() {
+        return get() != null ? get().getAttachments() : null;
+    }
+
+    public void put(Object key, Object value) {
+        if (get() != null) {
+            get().put(key, value);
+        }
+        throw new IllegalStateException("MessageContext is not set");
+        
+    }
+
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ProviderInfo.java
Thu Jan 22 02:40:56 2009
@@ -36,4 +36,16 @@
     public T getProvider() {
         return provider;
     }
+    
+    public boolean equals(Object obj) {
+        if (!(obj instanceof ProviderInfo)) {
+            return false;
+        }
+        return provider.equals(((ProviderInfo)obj).getProvider());
+    }
+
+    public int hashCode() {
+        return provider.hashCode();
+    }
+
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Thu Jan 22 02:40:56 2009
@@ -28,10 +28,8 @@
 import java.util.logging.Logger;
 
 import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.xml.bind.JAXBContext;
@@ -47,6 +45,7 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
@@ -63,7 +62,6 @@
     private static Map<String, JAXBContext> packageContexts = new WeakHashMap<String,
JAXBContext>();
     private static Map<Class<?>, JAXBContext> classContexts = new WeakHashMap<Class<?>,
JAXBContext>();
         
-    @Context protected ContextResolver<JAXBContext> resolver;
     private Schema schema;
     
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns)
{
@@ -88,13 +86,15 @@
     }
  
 
+    // TODO : no contexts can be inhected in superclasses
+    protected abstract MessageContext getContext(); 
+    
     protected JAXBContext getJAXBContext(Class<?> type, Type genericType) throws JAXBException
{
-        
-        if (resolver != null) {
-            JAXBContext context = resolver.getContext(type);
-            // it's up to the resolver to keep its contexts in a map
-            if (context != null) {
-                return context;
+        MessageContext mc = getContext();
+        if (mc != null) {
+            JAXBContext customContext = mc.getContext(JAXBContext.class);
+            if (customContext != null) {
+                return customContext;
             }
         }
         

Copied: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java
(from r736362, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java?p2=cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java&r1=736362&r2=736600&rev=736600&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ActivationProvider.java
Thu Jan 22 02:40:56 2009
@@ -26,7 +26,7 @@
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-import javax.ws.rs.Consumes;
+import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
@@ -38,14 +38,13 @@
 import org.apache.cxf.jaxrs.utils.AttachmentUtils;
 
 @Provider
-@Consumes("multipart/related")
+@ConsumeMime("multipart/related")
 public class ActivationProvider implements MessageBodyReader<Object> {
 
     @Context
     private MessageContext mc;
     
-    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,

-                              MediaType mediaType) {
+    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations)
{
         return DataSource.class.isAssignableFrom(type)
                || DataHandler.class.isAssignableFrom(type);
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Thu Jan 22 02:40:56 2009
@@ -31,6 +31,7 @@
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.Provider;
@@ -40,14 +41,26 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.AttachmentUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 
 @ProduceMime({"application/xml", "text/xml" })
-@ConsumeMime({"application/xml", "text/xml" })
+@ConsumeMime({"application/xml", "text/xml", 
+           "multipart/related;type=\"text/xml\"",
+           "multipart/related;type=\"application/xml\"" })
 @Provider
 public class JAXBElementProvider extends AbstractJAXBProvider  {
     
+    private static final MediaType MULTIPART_RELATED_TYPE = 
+        MediaType.valueOf("multipart/related");
+    
     private Map<String, Object> mProperties = new HashMap<String, Object>();
+    @Context private MessageContext mc;
+    
+    protected MessageContext getContext() {
+        return mc;
+    }
     
     public void setConsumeMediaTypes(List<String> types) {
         super.setConsumeMediaTypes(types);
@@ -73,10 +86,16 @@
         mProperties.put(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation);
     }
     
-    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
MediaType m, 
+    public Object readFrom(Class<Object> type, Type genericType, Annotation[] anns,
MediaType mt, 
         MultivaluedMap<String, String> headers, InputStream is) 
         throws IOException {
         try {
+            if (mt.isCompatible(MULTIPART_RELATED_TYPE)) {
+                is = (InputStream)AttachmentUtils.getMultipart(type, anns, mt, mc, is);
+                if (is == null) {
+                    throw new WebApplicationException(404);
+                }
+            }
             Class<?> theType = getActualType(type, genericType);
             Unmarshaller unmarshaller = createUnmarshaller(theType, genericType);
             

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Thu Jan 22 02:40:56 2009
@@ -33,6 +33,7 @@
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.Provider;
@@ -44,6 +45,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 import org.codehaus.jettison.AbstractXMLStreamWriter;
 import org.codehaus.jettison.mapped.Configuration;
@@ -52,7 +54,8 @@
 import org.codehaus.jettison.mapped.MappedXMLStreamWriter;
 
 @ProduceMime("application/json")
-@ConsumeMime("application/json")
+@ConsumeMime({"application/json",
+           "multipart/related;type=\"application/json\"" })
 @Provider
 public class JSONProvider extends AbstractJAXBProvider  {
     
@@ -62,6 +65,11 @@
     private Map<String, String> namespaceMap = new HashMap<String, String>();
     private boolean serializeAsArray;
     private List<String> arrayKeys;
+    @Context private MessageContext mc;
+    
+    protected MessageContext getContext() {
+        return mc;
+    }
     
     public void setConsumeMediaTypes(List<String> types) {
         super.setConsumeMediaTypes(types);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Thu Jan 22 02:40:56 2009
@@ -98,6 +98,7 @@
                      new SourceProvider(),
                      new FormEncodingReaderProvider(),
                      new PrimitiveTextProvider(),
+                     new ActivationProvider(),
                      new WebApplicationExceptionMapper(),
                      new MappingsHandler());
     }
@@ -392,8 +393,7 @@
         List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderConsumeTypes(ep);
         
         List<MediaType> availableMimeTypes = 
-            JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
-                                          supportedMediaTypes);
+            JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType), supportedMediaTypes);
 
         return availableMimeTypes.size() != 0 ? true : false;
         

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Thu Jan 22 02:40:56 2009
@@ -829,12 +829,17 @@
             for (MediaType userType : userMediaTypes) {
                 if (requiredType.isCompatible(userType) || userType.isCompatible(requiredType))
{
                     
+                    boolean parametersMatched = true;
                     for (Map.Entry<String, String> entry : userType.getParameters().entrySet())
{
                         String value = requiredType.getParameters().get(entry.getKey());
                         if (value != null && !value.equals(entry.getValue())) {
-                            continue;
+                            parametersMatched = false;
+                            break;
                         }
                     }
+                    if (!parametersMatched) {
+                        continue;
+                    }
                     
                     String type = requiredType.getType().equals(MediaType.MEDIA_TYPE_WILDCARD)

                                       ? userType.getType() : requiredType.getType();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java?rev=736600&r1=736599&r2=736600&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
Thu Jan 22 02:40:56 2009
@@ -23,16 +23,14 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 
 import javax.activation.DataHandler;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.MessageContext.Scope;
 
-import org.apache.cxf.attachment.LazyAttachmentCollection;
+import org.apache.cxf.attachment.AttachmentUtil;
 import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.endpoint.Endpoint;
@@ -290,27 +288,14 @@
             return null;
         }
         Collection<Attachment> attachments = mc.getAttachments();
-        Map<String, DataHandler> dataHandlers = getDHMap(attachments);
+        Map<String, DataHandler> dataHandlers = 
+            AttachmentUtil.getDHMap(attachments);
         mc.put(propertyName, 
                dataHandlers);
         scopes.put(propertyName, Scope.APPLICATION);
         return dataHandlers;
     }    
-    private static Map<String, DataHandler> getDHMap(Collection<Attachment> attachments)
{
-        Map<String, DataHandler> dataHandlers = null;
-        if (attachments != null) {
-            if (attachments instanceof LazyAttachmentCollection) {
-                dataHandlers = ((LazyAttachmentCollection)attachments).createDataHandlerMap();
-            } else {
-                //preserve the order of iteration
-                dataHandlers = new LinkedHashMap<String, DataHandler>();
-                for (Attachment attachment : attachments) {
-                    dataHandlers.put(attachment.getId(), attachment.getDataHandler());
-                }
-            }
-        }
-        return dataHandlers == null ? new LinkedHashMap<String, DataHandler>() : dataHandlers;
-    }    
+        
     public final boolean isEmpty() {
         return message.isEmpty();
     }

Copied: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
(from r736362, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?p2=cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java&p1=cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java&r1=736362&r2=736600&rev=736600&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
Thu Jan 22 02:40:56 2009
@@ -27,7 +27,7 @@
 import javax.activation.DataSource;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
+import javax.ws.rs.ProduceMime;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
@@ -49,7 +49,7 @@
     
     @POST
     @Path("/books/stream")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromStream(StreamSource source) throws Exception {
         JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
         Unmarshaller u = c.createUnmarshaller();
@@ -60,21 +60,21 @@
     
     @POST
     @Path("/books/istream")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromInputStream(InputStream is) throws Exception {
         return readBookFromInputStream(is);
     }
     
     @POST
     @Path("/books/dsource")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromDataSource(DataSource ds) throws Exception {
         return readBookFromInputStream(ds.getInputStream());
     }
     
     @POST
     @Path("/books/jaxb2")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBook2(@MultipartID("rootPart") Book b1,
                              @MultipartID("book2") Book b2) 
         throws Exception {
@@ -90,7 +90,7 @@
     
     @POST
     @Path("/books/dsource2")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromDataSource2(@MultipartID("rootPart") DataSource ds1,
                                            @MultipartID("book2") DataSource ds2) 
         throws Exception {
@@ -109,14 +109,14 @@
     
     @POST
     @Path("/books/dhandler")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromDataHandler(DataHandler dh) throws Exception {
         return readBookFromInputStream(dh.getInputStream());
     }
     
     @POST
     @Path("/books/mchandlers")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBookFromMessageContext() throws Exception {
         Map<String, DataHandler> handlers = context.getAttachments();
         for (Map.Entry<String, DataHandler> entry : handlers.entrySet()) {
@@ -129,7 +129,7 @@
     
     @POST
     @Path("/books/jaxb")
-    @Produces("text/xml")
+    @ProduceMime("text/xml")
     public Response addBook(Book b) throws Exception {
         b.setId(124);
         return Response.ok(b).build();



Mime
View raw message