we now support all image types via the image/* content-type. if a type is
[mir.git] / source / mir / media / MediaHandlerImages.java
index b85904a..cd8c7c5 100755 (executable)
@@ -28,7 +28,7 @@ import mir.entity.*;
  */
 
 
-public class MediaHandlerImages
+public class MediaHandlerImages implements MirMedia
 {
     protected final String        WEBDB_JPG="0";
     protected final String        WEBDB_GIF="1";
@@ -36,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;
 
@@ -45,18 +45,22 @@ 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("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()+" "+
@@ -66,13 +70,13 @@ public class MediaHandlerImages
             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("set: invocation target illegal: "+e.toString()); 
-            return false;
+            throw new MirMediaException(e.toString());
         }
         //deref. -mh
         uploadData=null;
@@ -80,7 +84,7 @@ public class MediaHandlerImages
         return true;
        }
 
-       public byte[] getIcon(Entity ent)
+       public byte[] getIcon(Entity ent) throws MirMediaException
        {
         byte[] icon_data = null;
 
@@ -89,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("getIcon: invocation target illegal: "+e.toString()); 
+            throw new MirMediaException(e.toString());
         }
 
         return icon_data;