From jbossws-commits at lists.jboss.org Wed Nov 22 17:03:46 2006 Content-Type: multipart/mixed; boundary="===============3660227993813949662==" MIME-Version: 1.0 From: jbossws-commits at lists.jboss.org To: jbossws-commits at lists.jboss.org Subject: [jbossws-commits] JBossWS SVN: r1509 - trunk/src/main/java/org/jboss/ws/soap/attachment Date: Wed, 22 Nov 2006 17:03:46 -0500 Message-ID: --===============3660227993813949662== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: thomas.diesler(a)jboss.com Date: 2006-11-22 17:03:44 -0500 (Wed, 22 Nov 2006) New Revision: 1509 Modified: trunk/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandler= .java Log: [JBWS-1284] Gracefully handle invalid ImageIO mime types. Modified: trunk/src/main/java/org/jboss/ws/soap/attachment/ImageDataContent= Handler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandle= r.java 2006-11-22 22:00:49 UTC (rev 1508) +++ trunk/src/main/java/org/jboss/ws/soap/attachment/ImageDataContentHandle= r.java 2006-11-22 22:03:44 UTC (rev 1509) @@ -30,6 +30,7 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; import java.util.Iterator; = import javax.activation.ActivationDataFlavor; @@ -39,6 +40,8 @@ import javax.imageio.ImageWriter; import javax.imageio.stream.ImageOutputStream; = +import org.jboss.logging.Logger; + /** * ImageDataContentHandler is a JAF content handler that hand= les * marshalling/unmarshalling between Image objects and a stre= am. @@ -53,9 +56,13 @@ * an exception will be thrown indicating the lack of encoding support. * * @author Jason T. Greene + * @author Magesh Kumar B */ public class ImageDataContentHandler extends Component implements DataCont= entHandler { + // provide logging + private static Logger log =3D Logger.getLogger(ImageDataContentHandler.= class); + private static DataFlavor[] flavors; = static @@ -71,11 +78,28 @@ String[] mimeTypes =3D ImageIO.getReaderMIMETypes(); if (mimeTypes =3D=3D null) return; - flavors =3D new DataFlavor[mimeTypes.length]; + ArrayList flavs =3D new ArrayList (); + DataFlavor flavor; + //flavors =3D new DataFlavor[mimeTypes.length]; for (int i =3D 0; i < mimeTypes.length; i++) { - flavors[i] =3D new ActivationDataFlavor(Image.class, mimeTypes[i]= , "Image"); + try + { + flavor =3D new ActivationDataFlavor(Image.class, mimeTypes[i],= "Image"); + flavs.add(flavor); + } + catch (IllegalArgumentException iae) + { + //This mime type is not supported + log.warn("Unsupported MIME Type '" + mimeTypes[i] +"'"); + } } + int size =3D flavs.size(); + flavors =3D new DataFlavor[size]; + for (int i =3D 0; i < size; i++) + { + flavors[i] =3D (ActivationDataFlavor)flavs.get(i); + } } = private static ImageWriter getImageWriter(String mimeType) { --===============3660227993813949662==--