[jbossws-commits] JBossWS SVN: r13663 - stack/native/branches/jbossws-native-2.0.1.SP2_CP07_JBPAPP-5850/src/main/java/org/jboss/ws/core/utils.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Feb 3 18:55:06 EST 2011


Author: bmaxwell
Date: 2011-02-03 18:55:06 -0500 (Thu, 03 Feb 2011)
New Revision: 13663

Modified:
   stack/native/branches/jbossws-native-2.0.1.SP2_CP07_JBPAPP-5850/src/main/java/org/jboss/ws/core/utils/MimeUtils.java
Log:
[JBPAPP-5850] can't be build under OpenJDK - this fix was required for the MTOM + Security test case to pass

Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP07_JBPAPP-5850/src/main/java/org/jboss/ws/core/utils/MimeUtils.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP07_JBPAPP-5850/src/main/java/org/jboss/ws/core/utils/MimeUtils.java	2011-02-03 01:27:30 UTC (rev 13662)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP07_JBPAPP-5850/src/main/java/org/jboss/ws/core/utils/MimeUtils.java	2011-02-03 23:55:06 UTC (rev 13663)
@@ -1,39 +1,40 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.ws.core.utils;
 
-// $Id$
-
 import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
 import javax.mail.internet.ContentType;
 import javax.mail.internet.MimeMultipart;
 import javax.mail.internet.ParseException;
@@ -45,10 +46,6 @@
 import org.jboss.wsf.common.IOUtils;
 import org.jboss.wsf.common.JavaUtils;
 
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageDecoder;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-
 /**
  * Generic mime utility class.
  *
@@ -223,15 +220,18 @@
    {
       public Object readFrom(InputStream in) {
          Object converted = null;
+         
          try
          {
-            JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
-            BufferedImage bim = dec.decodeAsBufferedImage();
+            ImageReader decoder = ImageIO.getImageReadersByFormatName("JPEG").next();
+            ImageInputStream iis = ImageIO.createImageInputStream(in);
+            decoder.setInput(iis);
+            BufferedImage bim = decoder.read(0);
             converted = bim;
          }
          catch (Exception e)
          {
-            // ignore
+            e.printStackTrace();
          }
 
          return converted;
@@ -240,10 +240,12 @@
       public void writeTo(Object obj, OutputStream out) {
          if(obj instanceof BufferedImage)
          {
-            JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(out);
+            ImageWriter encoder = ImageIO.getImageWritersByFormatName("JPEG").next();
             try
             {
-               enc.encode((BufferedImage)obj);
+               ImageOutputStream ios = ImageIO.createImageOutputStream(out);
+               encoder.setOutput(ios);
+               encoder.write((BufferedImage)obj);
             }
             catch (IOException e)
             {
@@ -291,17 +293,12 @@
          Object converted = null;
          try
          {
-            BufferedReader br = new BufferedReader(new InputStreamReader(in));
-            StringBuilder sb = new StringBuilder();
-            String line = null;
-
-            while ((line = br.readLine()) != null) {
-               sb.append(line + "\n");
+            StringBuilder out = new StringBuilder();
+            byte[] b = new byte[4096];
+            for (int n; (n = in.read(b)) != -1;) {
+                out.append(new String(b, 0, n));
             }
-
-            br.close();
-
-            converted = sb.toString();
+            converted = out.toString();
          }
          catch (IOException e)
          {
@@ -401,4 +398,4 @@
    }
 
 
-}
+}
\ No newline at end of file



More information about the jbossws-commits mailing list