merge in changes from MIR_1_0 branch that iplement media preview/download in the...
authormh <mh>
Wed, 27 Nov 2002 08:57:31 +0000 (08:57 +0000)
committermh <mh>
Wed, 27 Nov 2002 08:57:31 +0000 (08:57 +0000)
17 files changed:
source/mircoders/entity/EntityUploadedMedia.java
source/mircoders/media/MediaHandlerGeneric.java
source/mircoders/media/MediaHandlerImages.java
source/mircoders/media/MediaHandlerImagesJpeg.java
source/mircoders/media/MediaHandlerImagesPng.java
source/mircoders/media/MediaHandlerRealAudio.java
source/mircoders/media/MediaHandlerRealVideo.java
source/mircoders/servlet/ServletModuleImages.java
source/mircoders/servlet/ServletModuleUploadedMedia.java
templates/admin/audio.template
templates/admin/audiolist.template
templates/admin/image.template
templates/admin/imagelist.template
templates/admin/media.template
templates/admin/medialist.template
templates/admin/video.template
templates/admin/videolist.template

index 1b25542..caf2ab6 100755 (executable)
@@ -47,8 +47,8 @@ import java.util.HashMap;
 /**
  * Diese Klasse enthält die Daten eines MetaObjekts
  *
- * @author RK
- * @version 29.6.1999
+ * @author mh, mir-coders group
+ * @version $Id: EntityUploadedMedia.java,v 1.12 2002/11/27 08:57:31 mh Exp $
  */
 
 
@@ -95,7 +95,7 @@ public class EntityUploadedMedia extends Entity {
     if (key != null) {
       if (key.equals("big_icon"))
         returnValue = getBigIconName();
-      else if (key.equals("descr"))
+      else if (key.equals("descr") || key.equals("description"))
         returnValue = getDescr();
       else if (key.equals("mediatype"))
         returnValue = getMediaTypeString();
index 9e75b25..5f7b553 100755 (executable)
@@ -59,7 +59,7 @@ import mir.storage.*;
  *
  * @see mir.media.MirMedia
  * @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerGeneric.java,v 1.10 2002/11/04 04:35:22 mh Exp $
+ * @version $Id: MediaHandlerGeneric.java,v 1.11 2002/11/27 08:57:32 mh Exp $
  */
 
 public class MediaHandlerGeneric implements MirMedia
@@ -67,10 +67,10 @@ public class MediaHandlerGeneric implements MirMedia
     protected static String imageHost = MirConfig.getProp("Producer.Image.Host");
     protected static String imageRoot = MirConfig.getProp("Producer.ImageRoot");
     protected static Logfile theLog = Logfile.getInstance(
-                                                   MirConfig.getProp("Home")+
+                                                  MirConfig.getProp("Home")+
                                                   "log/media.log");
     private final String sepChar = File.separator;
-    
+
     public void set (InputStream in, Entity ent, Entity mediaTypeEnt )
         throws MirMediaException {
 
@@ -81,7 +81,7 @@ public class MediaHandlerGeneric implements MirMedia
         try {
             long size = FileUtil.write(getStoragePath()+sepChar+datePath+
                                       sepChar+mediaFname, in);
-            ent.setValueForProperty("publish_path",datePath+sepChar+mediaFname);
+            ent.setValueForProperty("publish_path",datePath+mediaFname);
             ent.setValueForProperty("size", new Long(size).toString());
             ent.update();
         } catch (Exception e) {
@@ -107,12 +107,12 @@ public class MediaHandlerGeneric implements MirMedia
 
     public InputStream getMedia (Entity ent, Entity mediaTypeEnt)
       throws MirMediaException {
-      String publishPath = mediaTypeEnt.getValue("publish_path");
+      String publishPath = ent.getValue("publish_path");
       String fname = getStoragePath()+publishPath;
       File f = new File(fname);
       if(! f.exists())
         throw new MirMediaException("error in MirMedia.getMedia(): "+fname+
-                                    "does not exist!");
+                                    " does not exist!");
       FileInputStream in;
       try {
         in = new FileInputStream(f);
@@ -138,7 +138,7 @@ public class MediaHandlerGeneric implements MirMedia
 
     public String getPublishHost()
     {
-        return MirConfig.getProp("Producer.Media.Host");
+        return StringUtil.removeSlash(MirConfig.getProp("Producer.Media.Host"));
     }
 
     public String getTinyIconName()
index 4b1fba6..974f097 100755 (executable)
@@ -59,7 +59,7 @@ import mircoders.entity.EntityImages;
  *
  * @see mir.media.MirMedia
  * @author mh
- * @version $Date: 2002/11/04 04:35:22 $ $Revision: 1.11 $
+ * @version $Id: MediaHandlerImages.java,v 1.12 2002/11/27 08:57:32 mh Exp $
  */
 
 
@@ -166,7 +166,7 @@ public abstract class MediaHandlerImages implements MirMedia
 
   public String getPublishHost()
   {
-    return MirConfig.getProp("Producer.Image.Host");
+    return StringUtil.removeSlash(MirConfig.getProp("Producer.Image.Host"));
   }
 
   public String getTinyIconName()
@@ -201,7 +201,7 @@ public abstract class MediaHandlerImages implements MirMedia
 
   public String getDescr(Entity mediaType)
   {
-    return "";
+    return "image/jpeg";
   }
 
 }
index 7498855..bc34b47 100755 (executable)
 
 package mircoders.media;
 
-//import java.lang.*;
-//import java.io.*;
-//import java.util.*;
-//import java.lang.reflect.*;
-
-//import freemarker.template.SimpleList;
-
 import mir.media.*;
-//import mir.misc.*;
+import mir.entity.Entity;
 
 /**
  * This class handles saving, fetching creating representations
@@ -51,8 +44,8 @@ import mir.media.*;
  *
  * @see mir.media.MirMedia
  * @see mircoders.media.MediaHandlerImages
- * @author mh
- * @version 24.09.2001
+ * @author mh, mir-coders group
+ * @version $Id: MediaHandlerImagesJpeg.java,v 1.3 2002/11/27 08:57:32 mh Exp $
  */
 
 
@@ -62,4 +55,9 @@ public class MediaHandlerImagesJpeg extends MediaHandlerImages implements MirMed
     return JPEG;
   }
 
+  public String getDescr(Entity mediaType)
+  {
+      return "image/jpeg";
+  }
+
 }
index 8a124ae..b2c87c1 100755 (executable)
 
 package mircoders.media;
 
-//import java.lang.*;
-//import java.io.*;
-//import java.util.*;
-//import java.lang.reflect.*;
-
-//import freemarker.template.SimpleList;
-
 import mir.media.*;
-//import mir.misc.*;
+import mir.entity.Entity;
 
 /**
  * This class handles saving, fetching creating representations
@@ -51,8 +44,8 @@ import mir.media.*;
  *
  * @see mir.media.MirMedia
  * @see mircoders.media.MediaHandlerImages
- * @author mh
- * @version 24.09.2001
+ * @author mh ,mir-coders
+ * @version $Id: MediaHandlerImagesPng.java,v 1.3 2002/11/27 08:57:32 mh Exp $
  */
 
 
@@ -62,4 +55,9 @@ public class MediaHandlerImagesPng extends MediaHandlerImages implements MirMedi
     return PNG;
   }
 
+  public String getDescr(Entity mediaType)
+  {
+      return "image/png";
+  }
+
 }
index 5b16e4a..bab016b 100755 (executable)
@@ -118,7 +118,7 @@ public class MediaHandlerRealAudio extends MediaHandlerAudio implements
 
   public String getPublishHost()
   {
-    return MirConfig.getProp("Producer.RealMedia.Host");
+    return StringUtil.removeSlash(MirConfig.getProp("Producer.RealMedia.Host"));
   }
 
 }
index 47ece1f..c268079 100755 (executable)
@@ -52,7 +52,7 @@ import mir.storage.*;
  * @see mir.media.MediaHandlerGeneric
  * @see mir.media.MirMedia
  * @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @version 11.10.2001
+ * @version $Id: MediaHandlerRealVideo.java,v 1.12 2002/11/27 08:57:32 mh Exp $
  */
 
 
@@ -118,7 +118,7 @@ public class MediaHandlerRealVideo extends MediaHandlerVideo implements
 
   public String getPublishHost()
   {
-    return MirConfig.getProp("Producer.RealMedia.Host");
+    return StringUtil.removeSlash(MirConfig.getProp("Producer.RealMedia.Host"));
   }
 
 }
index 7044dbe..910858c 100755 (executable)
@@ -60,8 +60,8 @@ import mircoders.producer.*;
  *  ServletModuleImages -
  *  liefert HTML fuer Images
  *
- *
- * @author RK
+ * @version $Id: ServletModuleImages.java,v 1.23 2002/11/27 08:57:32 mh Exp $
+ * @author RK, the mir-coders group
  */
 
 public class ServletModuleImages extends ServletModuleUploadedMedia
@@ -88,68 +88,5 @@ public class ServletModuleImages extends ServletModuleUploadedMedia
     }
   }
 
-  public void showimg(HttpServletRequest req, HttpServletResponse res)
-    throws ServletModuleException
-  {
-    String idParam = req.getParameter("id");
-    if (idParam!=null && !idParam.equals("")) {
-      try {
-        EntityImages entImage =(EntityImages)mainModule.getById(idParam);
-        ServletContext ctx =
-                    (ServletContext)MirConfig.getPropAsObject("ServletContext");
-        String fName = entImage.getId()+"."
-                      +entImage.getMediaType().getValue("name");
-        res.setContentType(ctx.getMimeType(fName));
-        ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
-        InputStream in = entImage.getImage();
-        int read;
-        byte[] buf = new byte[8 * 1024];
-        while((read = in.read(buf)) != -1) {
-          out.write(buf, 0, read);
-        }
-        in.close();
-        out.close();
-      }
-
-      catch (IOException e) {throw new ServletModuleException(e.toString());}
-      catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-      catch (Exception e) {throw new ServletModuleException(e.toString());}
-    }
-    else theLog.printDebugInfo("id nicht angeben.");
-    // darf keine exception werfen
-  }
-
-  public void showicon(HttpServletRequest req, HttpServletResponse res)
-    throws ServletModuleException
-  {
-    String idParam = req.getParameter("id");
-    if (idParam!=null && !idParam.equals("")) {
-      try {
-        EntityImages entImage =(EntityImages)mainModule.getById(idParam);
-        ServletContext ctx =
-                    (ServletContext)MirConfig.getPropAsObject("ServletContext");
-        String fName = entImage.getId()+"."
-                      +entImage.getMediaType().getValue("name");
-        res.setContentType(ctx.getMimeType(fName));
-        ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
-
-        InputStream in = entImage.getIcon();
-        int read;
-        byte[] buf = new byte[8 * 1024];
-        while((read = in.read(buf)) != -1) {
-          out.write(buf, 0, read);
-        }
-        in.close();
-        //out.write(outbytes);
-        out.close();
-      }
-
-      catch (IOException e) {throw new ServletModuleException(e.toString());}
-      catch (ModuleException e) {throw new ServletModuleException(e.toString());}
-      catch (Exception e) {throw new ServletModuleException(e.toString());}
-    }
-    else throw new ServletModuleException("id nicht angeben.");
-  }
 }
 
index 62430c0..69a51e4 100755 (executable)
@@ -47,6 +47,7 @@ import mir.servlet.ServletModuleUserException;
 import mir.storage.Database;
 import mir.storage.StorageObjectException;
 import mircoders.entity.EntityUsers;
+import mircoders.entity.EntityUploadedMedia;
 import mircoders.storage.DatabaseMediaType;
 import mircoders.storage.DatabaseMediafolder;
 import mircoders.media.MediaRequest;
@@ -55,8 +56,10 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletOutputStream;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URLEncoder;
 import java.util.GregorianCalendar;
 import java.util.HashMap;
@@ -65,8 +68,8 @@ import java.util.HashMap;
  *  ServletModuleBilder -
  *  liefert HTML fuer Bilder
  *
- *
- * @author RK
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.11 2002/11/27 08:57:32 mh Exp $
+ * @author RK, the mir-coders group
  */
 
 public abstract class ServletModuleUploadedMedia
@@ -291,6 +294,94 @@ public abstract class ServletModuleUploadedMedia
     return (EntityUsers) session.getAttribute("login.uid");
   }
 
+  public void getMedia(HttpServletRequest req, HttpServletResponse res)
+    throws ServletModuleException
+  {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+        Entity mediaType = ent.getMediaType();
+        MirMedia mediaHandler;
+
+        ServletContext ctx =
+                    (ServletContext)MirConfig.getPropAsObject("ServletContext");
+        String fName = ent.getId()+"."+mediaType.getValue("name");
+
+        mediaHandler = MediaHelper.getHandler(mediaType);
+        InputStream in = mediaHandler.getMedia(ent, mediaType);
+
+        res.setContentType(ctx.getMimeType(fName));
+        //important that before calling this res.getWriter was not called first
+        ServletOutputStream out = res.getOutputStream();
+        int read ;
+        byte[] buf = new byte[8 * 1024];
+        while((read = in.read(buf)) != -1) {
+          out.write(buf, 0, read);
+        }
+        in.close();
+        out.close();
+      }
+
+      catch (IOException e) {
+        throw new ServletModuleException(e.toString());
+      }
+      catch (ModuleException e) {
+        throw new ServletModuleException(e.toString());
+      }
+      catch (Exception e) {
+        throw new ServletModuleException(e.toString());
+      }
+    }
+    else theLog.printDebugInfo("id nicht angeben.");
+    // darf keine exception werfen
+  }
+
+  public void getIcon(HttpServletRequest req, HttpServletResponse res)
+    throws ServletModuleException
+  {
+    String idParam = req.getParameter("id");
+    if (idParam!=null && !idParam.equals("")) {
+      try {
+        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+        Entity mediaType = ent.getMediaType();
+        MirMedia mediaHandler;
+
+        ServletContext ctx =
+                    (ServletContext)MirConfig.getPropAsObject("ServletContext");
+        String fName = ent.getId()+"."+mediaType.getValue("name");
+
+        mediaHandler = MediaHelper.getHandler(mediaType);
+        InputStream in = mediaHandler.getIcon(ent);
+        res.setContentType(ctx.getMimeType(fName));
+        //important that before calling this res.getWriter was not called first
+        ServletOutputStream out = res.getOutputStream();
+
+        int read ;
+        byte[] buf = new byte[8 * 1024];
+        while((read = in.read(buf)) != -1) {
+          out.write(buf, 0, read);
+        }
+        in.close();
+        out.close();
+      }
+
+      catch (IOException e) {
+        throw new ServletModuleException(e.toString());
+      }
+      catch (ModuleException e) {
+        throw new ServletModuleException(e.toString());
+      }
+      catch (Exception e) {
+        throw new ServletModuleException(e.toString());
+      }
+    }
+    else theLog.printDebugInfo("id nicht angeben.");
+    // darf keine exception werfen
+  }
+
 }
 
 
index 7a8ab72..6f4a526 100755 (executable)
@@ -27,7 +27,8 @@ function openWin(url) {
        <tr>
     <td align="right" class="darkgrey">
                <span class="witesmall">
-                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></span></td>
+                       <a href="${config.actionRoot}?module=Audio&do=getMedia&id=${data.id}">
+                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a></span></td>
     <td valign="bottom"><span class="spezialtext">
                ${lang("media.created")}: ${data.webdb_create}
         <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
index 48269ed..da922f5 100755 (executable)
   <list data.contentlist as entry>
   <tr <if grey=="1"><assign grey="0">class="list1"<else>class="list2"<assign grey="1"> </if>>
   <td>
-         <img src="${config.docRoot}/img/${entry.big_icon}" border=0></span></td>
+         <a href="${config.actionRoot}?module=Audio&do=getMedia&id=${entry.id}">
+         <img src="${config.docRoot}/img/${entry.big_icon}" border=0></a></span></td>
   <td>${entry.title}&nbsp;
-         <if entry.decription><br>${entry.description}</if></td>
+         <if entry.description><br>${entry.description}</if></td>
   <td>${data.mediafolderHashdata[entry.to_media_folder]["name"]}&nbsp;</td>
   <td>${entry.creator}&nbsp;</td>
   <td><span class="text">&nbsp;
index aedb80d..ebe936f 100755 (executable)
@@ -42,8 +42,8 @@ function openWin(url) {
     <td align="right" class="darkgrey">
                <if (data.icon_data!="" && data.icon_data!="0") && !new>
                <span class="witesmall">
-               <a href="JavaScript:openWin('${config.actionRoot}?module=Images&do=showimg&id=${data.id}')">
-               <img src="${config.actionRoot}?module=Images&do=showicon&id=${data.id}" border=0></a></span></td>
+               <a href="JavaScript:openWin('${config.actionRoot}?module=Images&do=getMedia&id=${data.id}')">
+               <img src="${config.actionRoot}?module=Images&do=getIcon&id=${data.id}" border=0></a></span></td>
                </if>
     <td valign="bottom"><span class="spezialtext">
                ${lang("media.created")}: ${data.webdb_create} <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
index 970ce94..90ba7f6 100755 (executable)
   <tr <if grey=="1"><assign grey="0">class="list1"<else>class="list2"<assign grey="1"> </if>>
   <td>
        <if entry.icon_data!="" && entry.icon_data!="0">
-       <a href="${config.actionRoot}?module=Images&do=showimg&id=${entry.id}" target="new">
-         <img src="${config.actionRoot}?module=Images&do=showicon&id=${entry.id}" border=0></a></span></td>
+       <a href="${config.actionRoot}?module=Images&do=getMedia&id=${entry.id}" target="new">
+         <img src="${config.actionRoot}?module=Images&do=getIcon&id=${entry.id}" border=0></a></span></td>
        </if>
   <td>${entry.title}&nbsp;
-         <if entry.decription><br>${entry.description}</if></td>
+         <if entry.description><br>${entry.description}</if></td>
   <td>${data.mediafolderHashdata[entry.to_media_folder]["name"]}&nbsp;</td>
   <td>${entry.creator}&nbsp;</td>
   <td><span class="text">&nbsp;
index b364056..d08b547 100755 (executable)
@@ -27,7 +27,8 @@ function openWin(url) {
        <tr>
     <td align="right" class="darkgrey">
                <span class="witesmall">
-                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></span></td>
+                       <a href="${config.actionRoot}?module=OtherMedia&do=getMedia&id=${data.id}">
+                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a></span></td>
     <td valign="bottom"><span class="spezialtext">
                ${lang("media.created")}: ${data.webdb_create}
         <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
index 2e3f7c8..75ec340 100755 (executable)
   </tr>
   <if data.contentlist>
   <list data.contentlist as entry>
-  <tr <if grey=="1"><assign grey="0">bgcolor="#dddddd"<else><assign grey="1"></if>
+  <tr <if grey=="1"><assign grey="0">class="list1"<else>class="list2"<assign grey="1"></if>>
   <td>
-         <img src="${config.docRoot}/img/${entry.big_icon}" border=0></span></td>
+         <a href="${config.actionRoot}?module=OtherMedia&do=getMedia&id=${entry.id}">
+         <img src="${config.docRoot}/img/${entry.big_icon}" border=0></a></span></td>
   <td>${entry.title}&nbsp;
-         <if entry.decription><br>${entry.description}</if></td>
+         <if entry.description><br>${entry.description}</if></td>
   <td>${data.mediafolderHashdata[entry.to_media_folder]["name"]}&nbsp;</td>
   <td>${entry.creator}&nbsp;</td>
   <td><span class="text">&nbsp;
index 45ba9bd..62975a1 100755 (executable)
@@ -27,7 +27,8 @@ function openWin(url) {
        <tr>
     <td align="right" class="darkgrey">
                <span class="witesmall">
-                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></span></td>
+                       <a href="${config.actionRoot}?module=Video&do=getMedia&id=${data.id}">
+                       <img src="${config.docRoot}/img/${data.big_icon}" border=0></a></span></td>
     <td valign="bottom"><span class="spezialtext">
                ${lang("media.created")}: ${data.webdb_create}
         <if data.webdb_lastchange>/ ${lang("media.changed")} ${data.webdb_lastchange}</if><br>
index 009e98a..b9c6369 100755 (executable)
   <list data.contentlist as entry>
   <tr <if grey=="1"><assign grey="0">class="list1"<else>class="list1"<assign grey="1"> </if>>
   <td>
-         <img src="${config.docRoot}/img/${entry.big_icon}" border=0></span></td>
+         <a href="${config.actionRoot}?module=Video&do=getMedia&id=${entry.id}">
+         <img src="${config.docRoot}/img/${entry.big_icon}" border=1></a></span></td>
   <td>${entry.title}&nbsp;
-         <if entry.decription><br>${entry.description}</if></td>
+         <if entry.description><br>${entry.description}</if></td>
   <td>${data.mediafolderHashdata[entry.to_media_folder]["name"]}&nbsp;</td>
   <td>${entry.creator}&nbsp;</td>
   <td><span class="text">&nbsp;