whoops
[mir.git] / source / mircoders / servlet / ServletModuleUploadedMedia.java
index d404755..ba34a63 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 
@@ -62,7 +62,7 @@ import mircoders.entity.EntityContent;
 import mircoders.entity.EntityUploadedMedia;
 import mircoders.entity.EntityUsers;
 import mircoders.media.MediaUploadProcessor;
-import mircoders.media.UnsupportedMediaFormatExc;
+import mircoders.module.*;
 import mircoders.storage.DatabaseComment;
 import mircoders.storage.DatabaseContent;
 import mircoders.storage.DatabaseMediafolder;
@@ -76,7 +76,7 @@ import freemarker.template.SimpleList;
  *  ServletModuleBilder -
  *  liefert HTML fuer Bilder
  *
- * @version $Id: ServletModuleUploadedMedia.java,v 1.26 2003/04/21 12:42:51 idfx Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.28 2003/04/29 02:36:51 zapata Exp $
  * @author RK, the mir-coders group
  */
 
@@ -174,7 +174,7 @@ public abstract class ServletModuleUploadedMedia
     catch (Throwable t) {
       Throwable cause = ExceptionFunctions.traceCauseException(t);
 
-      if (cause instanceof UnsupportedMediaFormatExc) {
+      if (cause instanceof ModuleMediaType.UnsupportedMimeTypeExc) {
         throw new ServletModuleUserExc("media.error.unsupportedformat", new String[] {});
       }
       throw new ServletModuleFailure("ServletModuleUploadedMedia.insert: " + t.toString(), t);
@@ -391,17 +391,17 @@ public abstract class ServletModuleUploadedMedia
     String idParam = req.getParameter("id");
     if (idParam!=null && !idParam.equals("")) {
       try {
-        EntityUploadedMedia ent = (EntityUploadedMedia)mainModule.getById(idParam);
+        EntityUploadedMedia ent = (EntityUploadedMedia) mainModule.getById(idParam);
         Entity mediaType = ent.getMediaType();
         MirMedia mediaHandler;
 
-        ServletContext ctx = MirPropertiesConfiguration.getContext();
-        String fName = ent.getId()+"."+mediaType.getValue("name");
-
         mediaHandler = MediaHelper.getHandler(mediaType);
         InputStream in = mediaHandler.getIcon(ent);
 
-        res.setContentType(ctx.getMimeType(fName));
+        if (in==null)
+          throw new ServletModuleExc("no icon available");
+
+        res.setContentType(mediaHandler.getIconMimeType(ent, mediaType));
         //important that before calling this res.getWriter was not called first
         ServletOutputStream out = res.getOutputStream();