X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmedia%2FMediaHandlerImages.java;h=cd8c7c57665e7c23090209a7345fdc451ee344d3;hb=f63d9796574e9dbe8846884eb13c5b08654bfa8b;hp=aa62a267c8a19525d55ea89a02bb2f0ce2145a45;hpb=cf27d209625dfc1886c4509c5a8d8cfed7194404;p=mir.git diff --git a/source/mir/media/MediaHandlerImages.java b/source/mir/media/MediaHandlerImages.java index aa62a267..cd8c7c57 100755 --- a/source/mir/media/MediaHandlerImages.java +++ b/source/mir/media/MediaHandlerImages.java @@ -11,18 +11,24 @@ import mir.entity.*; /** * This class handles saving, fetching creating representations - * for all images. - * + * for all images. The image content is stored in the DB. The content is + * written out to a file at the ProducerImages level. + * Remember that Handlers for specific image types, Gif, Jpeg, etc.. + * should override it. + * It implements the MirMedia interface. + *

* ok. this is a big hack, it's cause putting the image in the DB * and fetching it from the DB needs low level db connections for - * some reason. -mh 25.09.2001 + * some reason. Does anyone know how to get around this? + * -mh 25.09.2001 * + * @see mir.media.MirMedia * @author mh * @version 24.09.2001 */ -public class MediaHandlerImages +public class MediaHandlerImages implements MirMedia { protected final String WEBDB_JPG="0"; protected final String WEBDB_GIF="1"; @@ -30,7 +36,7 @@ public class MediaHandlerImages protected String imageType="0"; private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log"); - public byte[] get(Entity ent, Entity mediaTypeEnt) + public byte[] get(Entity ent, Entity mediaTypeEnt) throws MirMediaException { byte[] image_data = null; @@ -39,31 +45,38 @@ public class MediaHandlerImages image_data = (byte[])method.invoke(ent, null); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { - theLog.printDebugInfo("invocation target illegal: "+e.toString()); + theLog.printDebugInfo("get: invocation target illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } return image_data; } - protected boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt) - { + public boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt) + throws MirMediaException { + try { Class[] params = {byte[].class, String.class}; + theLog.printDebugInfo("NAME: "+ent.getClass().getName()+" "+ + mediaTypeEnt.getClass().getName()+" "+uploadData.length+" "+ + imageType); Method method = ent.getClass().getMethod("setImage",params); method.invoke(ent, new Object[] {uploadData, imageType}); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); - return false; + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); - return false; + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { - theLog.printDebugInfo("invocation target illegal: "+e.toString()); - return false; + theLog.printDebugInfo("set: invocation target illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } //deref. -mh uploadData=null; @@ -71,7 +84,7 @@ public class MediaHandlerImages return true; } - public byte[] getIcon(Entity ent) + public byte[] getIcon(Entity ent) throws MirMediaException { byte[] icon_data = null; @@ -80,10 +93,13 @@ public class MediaHandlerImages icon_data = (byte[])method.invoke(ent, null); } catch ( NoSuchMethodException e) { theLog.printDebugInfo("method lookup unsuccesful: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( IllegalAccessException e) { theLog.printDebugInfo("method illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } catch ( InvocationTargetException e) { - theLog.printDebugInfo("invocation target illegal: "+e.toString()); + theLog.printDebugInfo("getIcon: invocation target illegal: "+e.toString()); + throw new MirMediaException(e.toString()); } return icon_data;