2 package mircoders.media;
7 import java.lang.reflect.*;
12 import mir.storage.StorageObjectException;
13 import mircoders.entity.EntityImages;
16 * This class handles saving, fetching creating representations
17 * for all images. The image content is stored in the DB. The content is
18 * written out to a file at the ProducerImages level.
19 * Remember that Handlers for specific image types, Gif, Jpeg, etc..
21 * It implements the MirMedia interface.
23 * slowly starting to look better, a next step would be to have the
24 * representation stuff (WebdbImage) happen here.
27 * @see mir.media.MirMedia
33 public class MediaHandlerImages implements MirMedia
35 private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+
38 public byte[] get(Entity ent, Entity mediaTypeEnt)
39 throws MirMediaException
41 byte[] image_data = null;
44 image_data = ((EntityImages)ent).getImage();
45 } catch ( StorageObjectException e) {
46 theLog.printDebugInfo("MediaHandlerImages.get: "+e.toString());
47 throw new MirMediaException(e.toString());
54 public boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt)
55 throws MirMediaException {
58 ((EntityImages)ent).setImage(uploadData);
59 } catch ( StorageObjectException e) {
60 theLog.printDebugInfo("MediaHandlerImages.set: "+e.toString());
61 throw new MirMediaException(e.toString());
69 public byte[] getIcon(Entity ent) throws MirMediaException
71 byte[] icon_data = null;
74 icon_data = ((EntityImages)ent).getIcon();
75 } catch ( StorageObjectException e) {
76 theLog.printDebugInfo("MediaHandlerImages.getIcon: "+e.toString());
77 throw new MirMediaException(e.toString());
83 public String getURL(Entity ent, Entity mediaTypeEnt)
85 String title = ent.getValue("title");
86 return StringUtil.createIMGLinks(ent.getValue("publish_server")+
87 ent.getValue("publish_path"), title, ent.getValue("img_height"),
88 ent.getValue("img_width"));
91 public String getListView(Entity ent, Entity mediaTypeEnt)
93 //String title = ent.getValue("title");
94 return StringUtil.createIMGLinks( MirConfig.getProp("Producer.ProductionHost")+
95 ent.getValue("icon_path"), null, ent.getValue("icon_height"),
96 ent.getValue("icon_width"));
99 public String getStoragePath()
101 return MirConfig.getProp("Producer.Image.Path");
104 public String getIconStoragePath()
106 return MirConfig.getProp("Producer.Image.IconPath");
109 public String getPublishHost()
111 return MirConfig.getProp("Producer.Image.Host");
114 public String getTinyIcon ()
116 return MirConfig.getProp("Producer.Icon.TinyImage");
119 public String getBigIcon ()
121 return MirConfig.getProp("Producer.Icon.BigImage");
124 public String getIconAlt ()
129 public boolean isVideo ()
134 public boolean isAudio ()
139 public boolean isImage ()