cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r736743 - in /cxf/branches/2.1.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/ja...
Date Thu, 22 Jan 2009 19:03:02 GMT
Author: sergeyb
Date: Thu Jan 22 11:03:02 2009
New Revision: 736743

URL: http://svn.apache.org/viewvc?rev=736743&view=rev
Log:
Merged revisions 736726 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r736726 | sergeyb | 2009-01-22 17:49:43 +0000 (Thu, 22 Jan 2009) | 1 line
  
  JAXRS: context injection into base jaxb provider through setters, minor changes to message
context api
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    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/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/utils/AttachmentUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
    cxf/branches/2.1.x-fixes/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/MultipartStore.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 22 11:03:02 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,736358-736362,736408,736423,736621
+/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,736621,736726

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

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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -19,9 +19,6 @@
 
 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;
@@ -44,8 +41,6 @@
     Object get(Object key);
     void put(Object key, Object value);
     
-    Map<String, DataHandler> getAttachments();
-    
     UriInfo getUriInfo();
     Request getRequest();
     HttpHeaders getHttpHeaders();
@@ -58,4 +53,5 @@
     ServletConfig getServletConfig();
     
     <T> T getContext(Class<T> contextClass);
+    <T, E> T getResolver(Class<T> resolverClass, Class<E> resolveClazz);
 }

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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -20,6 +20,7 @@
 
 import java.lang.reflect.Type;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 
 import javax.activation.DataHandler;
@@ -55,10 +56,6 @@
         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);
     }
@@ -68,8 +65,11 @@
     }
     
     @SuppressWarnings("unchecked")
-    public <T> ContextResolver<T> getContextResolver(Class<T> resolveClazz)
{
-        return getContext(resolveClazz, ContextResolver.class);
+    public <T, E> T getResolver(Class<T> resolverClazz, Class<E> resolveClazz)
{
+        if (ContextResolver.class == resolverClazz) {
+            return resolverClazz.cast(getContext(resolveClazz, ContextResolver.class));
+        }
+        return null;
     }
     
     public Request getRequest() {
@@ -118,6 +118,9 @@
             return CastUtils.cast((Map)o);
         }
         Collection<Attachment> attachments = m.getAttachments();
+        if (attachments == null) {
+            return Collections.emptyMap();
+        }
         attachments.size();
         Map<String, DataHandler> dataHandlers = AttachmentUtil.getDHMap(attachments);
         m.put(propertyName, 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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -19,9 +19,6 @@
 
 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;
@@ -81,10 +78,6 @@
         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);
@@ -93,4 +86,8 @@
         
     }
 
+    public <T, E> T getResolver(Class<T> resolverClass, Class<E> resolveClazz)
{
+        return get() != null ? get().getResolver(resolverClass, resolveClazz) : null;
+    }
+
 }

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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.jaxrs.provider;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.List;
@@ -30,6 +32,7 @@
 import javax.ws.rs.WebApplicationException;
 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 +50,7 @@
 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.AttachmentUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 
@@ -54,16 +58,22 @@
     implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
     
     protected static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXBProvider.class);
-       
-    private static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
 
+    private static final MediaType MULTIPART_RELATED_TYPE = 
+        MediaType.valueOf("multipart/related");
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
     private static final String CHARSET_PARAMETER = "charset"; 
         
     private static Map<String, JAXBContext> packageContexts = new WeakHashMap<String,
JAXBContext>();
     private static Map<Class<?>, JAXBContext> classContexts = new WeakHashMap<Class<?>,
JAXBContext>();
-        
+   
+    private MessageContext mc;
     private Schema schema;
-    
+
+    protected void setContext(MessageContext context) {
+        mc = context;
+    } 
+
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns)
{
         return isSupported(type, genericType, anns)
                || AnnotationUtils.getAnnotation(anns, XmlJavaTypeAdapter.class) != null;
@@ -86,15 +96,31 @@
     }
  
 
-    // TODO : no contexts can be inhected in superclasses
-    protected abstract MessageContext getContext(); 
+    protected MessageContext getContext() {
+        return mc;
+    }
     
+    public InputStream getInputStream(Class<Object> type, Annotation[] anns, MediaType
mt, 
+                                      InputStream is) throws IOException {
+        if (mt.isCompatible(MULTIPART_RELATED_TYPE)) {
+            is = (InputStream)AttachmentUtils.getMultipart(type, anns, mt, getContext(),
is);
+            if (is == null) {
+                throw new WebApplicationException(404);
+            }
+        }
+        return is;
+    }
+    
+    @SuppressWarnings("unchecked")
     protected JAXBContext getJAXBContext(Class<?> type, Type genericType) throws JAXBException
{
-        MessageContext mc = getContext();
         if (mc != null) {
-            JAXBContext customContext = mc.getContext(JAXBContext.class);
-            if (customContext != null) {
-                return customContext;
+            ContextResolver<JAXBContext> resolver = 
+                mc.getResolver(ContextResolver.class, JAXBContext.class);
+            if (resolver != null) {
+                JAXBContext customContext = resolver.getContext(type);
+                if (customContext != null) {
+                    return customContext;
+                }
             }
         }
         

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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -42,7 +42,6 @@
 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" })
@@ -52,14 +51,11 @@
 @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;
+    @Context
+    public void setMessageContext(MessageContext mc) {
+        super.setContext(mc);
     }
     
     public void setConsumeMediaTypes(List<String> types) {
@@ -87,15 +83,10 @@
     }
     
     public Object readFrom(Class<Object> type, Type genericType, Annotation[] anns,
MediaType mt, 
-        MultivaluedMap<String, String> headers, InputStream is) 
+        MultivaluedMap<String, String> headers, InputStream stream) 
         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);
-                }
-            }
+            InputStream is = getInputStream(type, anns, mt, stream);
             Class<?> theType = getActualType(type, genericType);
             Unmarshaller unmarshaller = createUnmarshaller(theType, genericType);
             
@@ -107,6 +98,8 @@
             
         } catch (JAXBException e) {
             handleJAXBException(e);
+        } catch (WebApplicationException e) {
+            throw e;
         } catch (Exception e) {
             throw new WebApplicationException(e);        
         }

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=736743&r1=736742&r2=736743&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 11:03:02 2009
@@ -65,10 +65,10 @@
     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;
+    @Context
+    public void setMessageContext(MessageContext mc) {
+        super.setContext(mc);
     }
     
     public void setConsumeMediaTypes(List<String> types) {
@@ -99,11 +99,12 @@
         this.namespaceMap = namespaceMap;
     }
 
-    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
MediaType m, 
-        MultivaluedMap<String, String> headers, InputStream is) 
+    public Object readFrom(Class<Object> type, Type genericType, Annotation[] anns,
MediaType mt, 
+        MultivaluedMap<String, String> headers, InputStream stream) 
         throws IOException {
         
         try {
+            InputStream is = getInputStream(type, anns, mt, stream);
             Class<?> theType = getActualType(type, genericType);
             Unmarshaller unmarshaller = createUnmarshaller(theType, genericType);
             
@@ -121,6 +122,8 @@
             handleJAXBException(e);
         } catch (XMLStreamException e) {
             throw new WebApplicationException(e);
+        } catch (WebApplicationException e) {
+            throw e;
         } catch (Exception e) {
             throw new WebApplicationException(e);
         }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java?rev=736743&r1=736742&r2=736743&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AttachmentUtils.java
Thu Jan 22 11:03:02 2009
@@ -23,19 +23,31 @@
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.mail.util.ByteArrayDataSource;
 import javax.ws.rs.core.MediaType;
 
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.MultipartID;
 
 public final class AttachmentUtils {
+    private static final Logger LOG = LogUtils.getL7dLogger(AttachmentUtils.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AttachmentUtils.class);
+    
     private AttachmentUtils() {
     }
     
+    public static Map<String, DataHandler> getAttachments(MessageContext mc) {
+        return CastUtils.cast((Map)mc.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
+    }
+    
     public static Object getMultipart(Class<Object> c, Annotation[] anns, 
          MediaType mt, MessageContext mc, InputStream is) throws IOException {
         InputStream stream = null;
@@ -51,7 +63,7 @@
             }
             if (stream == null) {
                 // TODO: looks like the lazy attachments collection can only be accessed
this way
-                for (Map.Entry<String, DataHandler> entry : mc.getAttachments().entrySet())
{
+                for (Map.Entry<String, DataHandler> entry : getAttachments(mc).entrySet())
{
                     if (entry.getKey().equals(contentId)) {
                         DataHandler dh = entry.getValue();
                         return DataHandler.class.isAssignableFrom(c) ? dh 
@@ -59,6 +71,12 @@
                             : dh.getInputStream();
                     }
                 }
+                org.apache.cxf.common.i18n.Message errorMsg = 
+                    new org.apache.cxf.common.i18n.Message("MULTTIPART_ID_NOT_FOUND", 
+                                                           BUNDLE, 
+                                                           contentId,
+                                                           mt.toString());
+                LOG.warning(errorMsg.toString());
             }
         } else {
             stream = is;

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties?rev=736743&r1=736742&r2=736743&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
Thu Jan 22 11:03:02 2009
@@ -30,3 +30,4 @@
 NO_MSG_READER =.No message body reader found for request class : {0}, ContentType : {1}.
 NO_SUBRESOURCE_METHOD_FOUND=No operation matching request path {0} is found on subresource,
ContentType : {1}, Accept : {2}.
 NO_OP_EXC =.No operation matching request path {0} is found, ContentType : {1}, Accept :
{2}.
+MULTTIPART_ID_NOT_FOUND=No multipart with content id {0} found, request content type : {1}
\ No newline at end of file

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=736743&r1=736742&r2=736743&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Thu Jan 22 11:03:02 2009
@@ -37,7 +37,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly",
-                   launchServer(MultipartServer.class));
+                   launchServer(MultipartServer.class, true));
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/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?rev=736743&r1=736742&r2=736743&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/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 11:03:02 2009
@@ -37,6 +37,7 @@
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.MultipartID;
+import org.apache.cxf.jaxrs.utils.AttachmentUtils;
 
 @Path("/bookstore")
 public class MultipartStore {
@@ -118,7 +119,7 @@
     @Path("/books/mchandlers")
     @ProduceMime("text/xml")
     public Response addBookFromMessageContext() throws Exception {
-        Map<String, DataHandler> handlers = context.getAttachments();
+        Map<String, DataHandler> handlers = AttachmentUtils.getAttachments(context);
         for (Map.Entry<String, DataHandler> entry : handlers.entrySet()) {
             if (entry.getKey().equals("book2")) {
                 return readBookFromInputStream(entry.getValue().getInputStream());



Mime
View raw message