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());
74 public byte[] getIcon(Entity ent)
76 byte[] icon_data = null;
79 Method method = ent.getClass().getMethod("getIcon",null);
80 icon_data = (byte[])method.invoke(ent, null);
81 } catch ( NoSuchMethodException e) {
82 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
83 } catch ( IllegalAccessException e) {
84 theLog.printDebugInfo("method illegal: "+e.toString());
85 } catch ( InvocationTargetException e) {
86 theLog.printDebugInfo("invocation target illegal: "+e.toString());
92 public String getURL(Entity ent, Entity mediaTypeEnt)
94 String title = ent.getValue("title");
95 return StringUtil.createIMGLinks(ent.getValue("publish_server")+
96 ent.getValue("publish_path"), title, ent.getValue("img_height"),
97 ent.getValue("img_width"));
100 public String getListView(Entity ent, Entity mediaTypeEnt)
102 //String title = ent.getValue("title");
103 return StringUtil.createIMGLinks( MirConfig.getProp("Producer.ProductionHost")+
104 ent.getValue("icon_path"), null, ent.getValue("icon_height"),
105 ent.getValue("icon_width"));
108 public String getStoragePath()
110 return MirConfig.getProp("Producer.Image.Path");
113 public String getIconStoragePath()
115 return MirConfig.getProp("Producer.Image.IconPath");
118 public String getPublishHost()
120 return MirConfig.getProp("Producer.Image.Host");
123 public String getTinyIcon ()
125 return MirConfig.getProp("Producer.Icon.TinyImage");
128 public String getBigIcon ()
130 return MirConfig.getProp("Producer.Icon.BigImage");
133 public String getIconAlt ()
138 public boolean isVideo ()
143 public boolean isAudio ()
148 public boolean isImage ()