--- /dev/null
+
+package mircoders.media;
+
+import java.lang.*;
+import java.io.*;
+import java.util.*;
+import java.lang.reflect.*;
+
+import mir.media.*;
+import mir.misc.*;
+import mir.entity.*;
+import mir.storage.StorageObjectException;
+import mircoders.entity.EntityImages;
+
+/**
+ * This class handles saving, fetching creating representations
+ * for all images. The image content is stored in the DB. The content is
+ * written out to a file at the ProducerImages level.
+ * Remember that Handlers for specific image types, Gif, Jpeg, etc..
+ * should override it.
+ * It implements the MirMedia interface.
+ * <p>
+ * slowly starting to look better, a next step would be to have the
+ * representation stuff (WebdbImage) happen here.
+ * -mh 01.03.2002
+ *
+ * @see mir.media.MirMedia
+ * @author mh
+ * @version 24.09.2001
+ */
+
+
+public class MediaHandlerImages implements MirMedia
+{
+ private Logfile theLog = Logfile.getInstance(MirConfig.getProp("Home")+
+ "log/media.log");
+
+ public byte[] get(Entity ent, Entity mediaTypeEnt)
+ throws MirMediaException
+ {
+ byte[] image_data = null;
+
+ try {
+ image_data = ((EntityImages)ent).getImage();
+ } catch ( StorageObjectException e) {
+ theLog.printDebugInfo("MediaHandlerImages.get: "+e.toString());
+ throw new MirMediaException(e.toString());
+ }
+
+
+ return image_data;
+ }
+
+ public boolean set(byte[] uploadData, Entity ent, Entity mediaTypeEnt)
+ throws MirMediaException {
+
+ try {
+ ((EntityImages)ent).setImage(uploadData);
+ } catch ( StorageObjectException e) {
+ theLog.printDebugInfo("MediaHandlerImages.set: "+e.toString());
+ throw new MirMediaException(e.toString());
+ }
+ //deref. -mh
+ uploadData=null;
+
+ return true;
+ }
+
+ public byte[] getIcon(Entity ent) throws MirMediaException
+ {
+ byte[] icon_data = null;
+
+ try {
+ icon_data = ((EntityImages)ent).getIcon();
+ } catch ( StorageObjectException e) {
+ theLog.printDebugInfo("MediaHandlerImages.getIcon: "+e.toString());
+ throw new MirMediaException(e.toString());
+ }
+
+ return icon_data;
+ }
+
+ public String getURL(Entity ent, Entity mediaTypeEnt)
+ {
+ String title = ent.getValue("title");
+ return StringUtil.createIMGLinks(ent.getValue("publish_server")+
+ ent.getValue("publish_path"), title, ent.getValue("img_height"),
+ ent.getValue("img_width"));
+ }
+
+ public String getListView(Entity ent, Entity mediaTypeEnt)
+ {
+ //String title = ent.getValue("title");
+ return StringUtil.createIMGLinks( MirConfig.getProp("Producer.ProductionHost")+
+ ent.getValue("icon_path"), null, ent.getValue("icon_height"),
+ ent.getValue("icon_width"));
+ }
+
+ public String getStoragePath()
+ {
+ return MirConfig.getProp("Producer.Image.Path");
+ }
+
+ public String getIconStoragePath()
+ {
+ return MirConfig.getProp("Producer.Image.IconPath");
+ }
+
+ public String getPublishHost()
+ {
+ return MirConfig.getProp("Producer.Image.Host");
+ }
+
+ public String getTinyIcon ()
+ {
+ return MirConfig.getProp("Producer.Icon.TinyImage");
+ }
+
+ public String getBigIcon ()
+ {
+ return MirConfig.getProp("Producer.Icon.BigImage");
+ }
+
+ public String getIconAlt ()
+ {
+ return "Image";
+ }
+
+ public boolean isVideo ()
+ {
+ return false;
+ }
+
+ public boolean isAudio ()
+ {
+ return false;
+ }
+
+ public boolean isImage ()
+ {
+ return true;
+ }
+
+}