7 import java.lang.reflect.*;
13 * This class handles saving, fetching creating representations
14 * for all images. The image content is stored in the DB. The content is
15 * written out to a file at the ProducerImages level.
16 * Remember that Handlers for specific image types, Gif, Jpeg, etc..
18 * It implements the MirMedia interface.
20 * ok. this is a big hack, it's cause putting the image in the DB
21 * and fetching it from the DB needs low level db connections for
22 * some reason. Does anyone know how to get around this?
25 * @see mir.media.MirMedia
31 public class MediaHandlerImages
33 protected final String WEBDB_JPG="0";
34 protected final String WEBDB_GIF="1";
36 protected String imageType="0";
37 private Logfile theLog = Logfile.getInstance(this.getClass().getName());
39 public byte[] get(Entity ent, Entity mediaTypeEnt)
41 byte[] image_data = null;
44 Method method = ent.getClass().getMethod("getImage",null);
45 image_data = (byte[])method.invoke(ent, null);
46 } catch ( NoSuchMethodException e) {
47 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
48 } catch ( IllegalAccessException e) {
49 theLog.printDebugInfo("method illegal: "+e.toString());
50 } catch ( InvocationTargetException e) {
51 theLog.printDebugInfo("get: invocation target illegal: "+e.toString());
58 protected boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt)
61 Class[] params = {byte[].class, String.class};
62 theLog.printDebugInfo("NAME: "+ent.getClass().getName()+" "+
63 mediaTypeEnt.getClass().getName()+" "+uploadData.length+" "+
65 Method method = ent.getClass().getMethod("setImage",params);
66 method.invoke(ent, new Object[] {uploadData, imageType});
67 } catch ( NoSuchMethodException e) {
68 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
70 } catch ( IllegalAccessException e) {
71 theLog.printDebugInfo("method illegal: "+e.toString());
73 } catch ( InvocationTargetException e) {
74 theLog.printDebugInfo("set: invocation target illegal: "+e.toString());
83 public byte[] getIcon(Entity ent)
85 byte[] icon_data = null;
88 Method method = ent.getClass().getMethod("getIcon",null);
89 icon_data = (byte[])method.invoke(ent, null);
90 } catch ( NoSuchMethodException e) {
91 theLog.printDebugInfo("method lookup unsuccesful: "+e.toString());
92 } catch ( IllegalAccessException e) {
93 theLog.printDebugInfo("method illegal: "+e.toString());
94 } catch ( InvocationTargetException e) {
95 theLog.printDebugInfo("getIcon: invocation target illegal: "+e.toString());
101 public String getURL(Entity ent, Entity mediaTypeEnt)
103 String title = ent.getValue("title");
104 return StringUtil.createIMGLinks(ent.getValue("publish_server")+
105 ent.getValue("publish_path"), title, ent.getValue("img_height"),
106 ent.getValue("img_width"));
109 public String getListView(Entity ent, Entity mediaTypeEnt)
111 //String title = ent.getValue("title");
112 return StringUtil.createIMGLinks( MirConfig.getProp("Producer.ProductionHost")+
113 ent.getValue("icon_path"), null, ent.getValue("icon_height"),
114 ent.getValue("icon_width"));
117 public String getStoragePath()
119 return MirConfig.getProp("Producer.Image.Path");
122 public String getIconStoragePath()
124 return MirConfig.getProp("Producer.Image.IconPath");
127 public String getPublishHost()
129 return MirConfig.getProp("Producer.Image.Host");
132 public String getTinyIcon ()
134 return MirConfig.getProp("Producer.Icon.TinyImage");
137 public String getBigIcon ()
139 return MirConfig.getProp("Producer.Icon.BigImage");
142 public String getIconAlt ()
147 public boolean isVideo ()
152 public boolean isAudio ()
157 public boolean isImage ()