7 import java.lang.reflect.*;
13 * This class handles saving, fetching creating representations
16 * ok. this is a big hack, it's cause putting the image in the DB
17 * and fetching it from the DB needs low level db connections for
18 * some reason. -mh 25.09.2001
25 public class MediaHandlerImages
27 protected final String WEBDB_JPG="0";
28 protected final String WEBDB_GIF="1";
30 protected String imageType="0";
31 private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+"log/media.log");
33 public byte[] get(Entity ent, Entity mediaTypeEnt)
35 byte[] image_data = null;
38 Method method = ent.getClass().getMethod("getImage",null);
39 image_data = (byte[])method.invoke(ent, null);
40 } catch ( NoSuchMethodException e) {
41 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
42 } catch ( IllegalAccessException e) {
43 theLog.printDebugInfo("method illegal: "+e.toString());
44 } catch ( InvocationTargetException e) {
45 theLog.printDebugInfo("invocation target illegal: "+e.toString());
52 protected boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt)
55 Class[] params = {byte[].class, String.class};
56 Method method = ent.getClass().getMethod("setImage",params);
57 method.invoke(ent, new Object[] {uploadData, imageType});
58 } catch ( NoSuchMethodException e) {
59 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
61 } catch ( IllegalAccessException e) {
62 theLog.printDebugInfo("method illegal: "+e.toString());
64 } catch ( InvocationTargetException e) {
65 theLog.printDebugInfo("invocation target illegal: "+e.toString());
71 public byte[] getIcon(Entity ent)
73 byte[] icon_data = null;
76 Method method = ent.getClass().getMethod("getIcon",null);
77 icon_data = (byte[])method.invoke(ent, null);
78 } catch ( NoSuchMethodException e) {
79 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
80 } catch ( IllegalAccessException e) {
81 theLog.printDebugInfo("method illegal: "+e.toString());
82 } catch ( InvocationTargetException e) {
83 theLog.printDebugInfo("invocation target illegal: "+e.toString());
89 public String getStoragePath()
91 return MirConfig.getProp("Producer.Image.Path");
94 public String getIconStoragePath()
96 return MirConfig.getProp("Producer.Image.IconPath");
99 public String getPublishHost()
101 return MirConfig.getProp("Producer.Image.Host");
104 public String getTinyIcon ()
106 return MirConfig.getProp("Producer.Icon.TinyImage");
109 public String getIconAlt ()
114 public boolean isVideo ()
119 public boolean isAudio ()
124 public boolean isImage ()