cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r925381 - in /cxf/branches/2.2.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/attachment/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/
Date Fri, 19 Mar 2010 19:10:00 GMT
Author: sergeyb
Date: Fri Mar 19 19:10:00 2010
New Revision: 925381

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

........
  r925378 | sergeyb | 2010-03-19 18:58:06 +0000 (Fri, 19 Mar 2010) | 1 line
  
  Moving some duplicate code into AttachmentUtil
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
    cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentUnmarshaller.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 19 19:10:00 2010
@@ -1 +1 @@
-/cxf/trunk:925337
+/cxf/trunk:925337,925378

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

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=925381&r1=925380&r2=925381&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Fri Mar 19 19:10:00 2010
@@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingExcept
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URL;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.Collection;
@@ -39,6 +40,7 @@ import java.util.UUID;
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.activation.FileDataSource;
+import javax.activation.URLDataSource;
 import javax.mail.Header;
 import javax.mail.internet.InternetHeaders;
 
@@ -255,5 +257,26 @@ public final class AttachmentUtil {
         att.setXOP(isXop);
         return att;
     }
+
+    public static DataSource getAttachmentDataSource(String contentId, Collection<Attachment>
atts) {
+        // Is this right? - DD
+        if (contentId.startsWith("cid:")) {
+            try {
+                contentId = URLDecoder.decode(contentId.substring(4), "UTF-8");
+            } catch (UnsupportedEncodingException ue) {
+                contentId = contentId.substring(4);
+            }
+            return new LazyDataSource(contentId, atts);
+        } else if (contentId.indexOf("://") == -1) {
+            return new LazyDataSource(contentId, atts);
+        } else {
+            try {
+                return new URLDataSource(new URL(contentId));
+            } catch (MalformedURLException e) {
+                throw new Fault(e);
+            }
+        }
+        
+    }
     
 }

Modified: cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java?rev=925381&r1=925380&r2=925381&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java
Fri Mar 19 19:10:00 2010
@@ -22,19 +22,13 @@ package org.apache.cxf.jaxb.attachment;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
 import java.util.Collection;
 import java.util.logging.Logger;
 
 import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.activation.URLDataSource;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
 
-import org.apache.cxf.attachment.LazyDataSource;
+import org.apache.cxf.attachment.AttachmentUtil;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -52,14 +46,15 @@ public class JAXBAttachmentUnmarshaller 
 
     @Override
     public DataHandler getAttachmentAsDataHandler(String contentId) {
-        return new DataHandler(getAttachmentDataSource(contentId));
+        return new DataHandler(AttachmentUtil.getAttachmentDataSource(contentId, attachments));
     }
 
     @Override
     public byte[] getAttachmentAsByteArray(String contentId) {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         try {
-            InputStream is = getAttachmentDataSource(contentId).getInputStream();
+            InputStream is = AttachmentUtil.getAttachmentDataSource(contentId, attachments)
+                                           .getInputStream();
             IOUtils.copy(is, bos);
             is.close();
             bos.close();
@@ -74,24 +69,4 @@ public class JAXBAttachmentUnmarshaller 
         return attachments != null;
     }
 
-    private DataSource getAttachmentDataSource(String contentId) {
-        // Is this right? - DD
-        if (contentId.startsWith("cid:")) {
-            try {
-                contentId = URLDecoder.decode(contentId.substring(4), "UTF-8");
-            } catch (UnsupportedEncodingException ue) {
-                contentId = contentId.substring(4);
-            }
-            return new LazyDataSource(contentId, attachments);
-        } else if (contentId.indexOf("://") == -1) {
-            return new LazyDataSource(contentId, attachments);
-        } else {
-            try {
-                return new URLDataSource(new URL(contentId));
-            } catch (MalformedURLException e) {
-                throw new Fault(e);
-            }
-        }
-        
-    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentUnmarshaller.java?rev=925381&r1=925380&r2=925381&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentUnmarshaller.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBAttachmentUnmarshaller.java
Fri Mar 19 19:10:00 2010
@@ -22,19 +22,13 @@ package org.apache.cxf.jaxrs.provider;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLDecoder;
 import java.util.Collection;
 import java.util.logging.Logger;
 
 import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.activation.URLDataSource;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
 
-import org.apache.cxf.attachment.LazyDataSource;
+import org.apache.cxf.attachment.AttachmentUtil;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
@@ -52,14 +46,15 @@ public class JAXBAttachmentUnmarshaller 
 
     @Override
     public DataHandler getAttachmentAsDataHandler(String contentId) {
-        return new DataHandler(getAttachmentDataSource(contentId));
+        return new DataHandler(AttachmentUtil.getAttachmentDataSource(contentId, attachments));
     }
 
     @Override
     public byte[] getAttachmentAsByteArray(String contentId) {
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         try {
-            InputStream is = getAttachmentDataSource(contentId).getInputStream();
+            InputStream is = AttachmentUtil.getAttachmentDataSource(contentId, attachments)
+                                           .getInputStream();
             IOUtils.copy(is, bos);
             is.close();
             bos.close();
@@ -74,24 +69,5 @@ public class JAXBAttachmentUnmarshaller 
         return attachments != null;
     }
 
-    private DataSource getAttachmentDataSource(String contentId) {
-        // Is this right? - DD
-        if (contentId.startsWith("cid:")) {
-            try {
-                contentId = URLDecoder.decode(contentId.substring(4), "UTF-8");
-            } catch (UnsupportedEncodingException ue) {
-                contentId = contentId.substring(4);
-            }
-            return new LazyDataSource(contentId, attachments);
-        } else if (contentId.indexOf("://") == -1) {
-            return new LazyDataSource(contentId, attachments);
-        } else {
-            try {
-                return new URLDataSource(new URL(contentId));
-            } catch (MalformedURLException e) {
-                throw new Fault(e);
-            }
-        }
-        
-    }
+    
 }



Mime
View raw message