You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/05/19 00:31:42 UTC
svn commit: r945936 - in /cxf/branches/2.2.x-fixes: ./
rt/core/src/main/java/org/apache/cxf/attachment/
Author: dkulp
Date: Tue May 18 22:31:42 2010
New Revision: 945936
URL: http://svn.apache.org/viewvc?rev=945936&view=rev
Log:
Merged revisions 945859 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r945859 | dkulp | 2010-05-18 16:08:46 -0400 (Tue, 18 May 2010) | 2 lines
Register a DataContentHandler for images to make them work a bit more
reliably depending on the mail/activation version found on the classpath
........
Added:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java
- copied unchanged from r945859, cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentImpl.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Propchange: cxf/branches/2.2.x-fixes/
('svn:mergeinfo' removed)
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/AttachmentImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentImpl.java?rev=945936&r1=945935&r2=945936&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentImpl.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentImpl.java Tue May 18 22:31:42 2010
@@ -41,6 +41,7 @@ public class AttachmentImpl implements A
public AttachmentImpl(String idParam, DataHandler handlerParam) {
this.id = idParam;
this.dataHandler = handlerParam;
+ this.dataHandler.setCommandMap(AttachmentUtil.getCommandMap());
}
public String getId() {
@@ -53,6 +54,7 @@ public class AttachmentImpl implements A
public void setDataHandler(DataHandler dataHandler) {
this.dataHandler = dataHandler;
+ this.dataHandler.setCommandMap(AttachmentUtil.getCommandMap());
}
public void setHeader(String name, String value) {
Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java?rev=945936&r1=945935&r2=945936&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java Tue May 18 22:31:42 2010
@@ -30,12 +30,11 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import javax.activation.DataHandler;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Message;
-
public class AttachmentSerializer {
-
private Message message;
private String bodyBoundary;
private OutputStream out;
@@ -221,11 +220,14 @@ public class AttachmentSerializer {
headers = Collections.emptyMap();
}
- writeHeaders(a.getDataHandler().getContentType(), a.getId(),
+
+ DataHandler handler = a.getDataHandler();
+ handler.setCommandMap(AttachmentUtil.getCommandMap());
+
+ writeHeaders(handler.getContentType(), a.getId(),
headers, writer);
out.write(writer.getBuffer().toString().getBytes(encoding));
-
- a.getDataHandler().writeTo(out);
+ handler.writeTo(out);
}
}
StringWriter writer = new StringWriter();
@@ -244,5 +246,5 @@ public class AttachmentSerializer {
public void setXop(boolean xop) {
this.xop = xop;
}
-
+
}
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=945936&r1=945935&r2=945936&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 Tue May 18 22:31:42 2010
@@ -37,9 +37,11 @@ import java.util.Map;
import java.util.Random;
import java.util.UUID;
+import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
+import javax.activation.MailcapCommandMap;
import javax.activation.URLDataSource;
import javax.mail.Header;
import javax.mail.internet.InternetHeaders;
@@ -56,11 +58,22 @@ public final class AttachmentUtil {
private static final String ATT_UUID = UUID.randomUUID().toString();
private static final Random BOUND_RANDOM = new Random();
-
+ private static final MailcapCommandMap COMMAND_MAP = new MailcapCommandMap();
+
+
private AttachmentUtil() {
}
+
+ static {
+ COMMAND_MAP.addMailcap("image/*;;x-java-content-handler="
+ + ImageDataContentHandler.class.getName());
+ }
+ public static CommandMap getCommandMap() {
+ return COMMAND_MAP;
+ }
+
/**
* @param ns
* @return