X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Fservlet%2FServletModuleUploadedMedia.java;h=ba34a6392260daaab9be2c2154ee3db9b0f0942d;hb=a0e0629d9b38c2eb4eba6d9420ccbc6d1b44ab00;hp=27bcf2748fab2832407b12b27d10a4037ff66731;hpb=87809334c4eaf3955a1cfe609425ad2f07a26351;p=mir.git diff --git a/source/mircoders/servlet/ServletModuleUploadedMedia.java b/source/mircoders/servlet/ServletModuleUploadedMedia.java index 27bcf274..ba34a639 100755 --- a/source/mircoders/servlet/ServletModuleUploadedMedia.java +++ b/source/mircoders/servlet/ServletModuleUploadedMedia.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2001, 2002 The Mir-coders group * * This file is part of Mir. * @@ -18,15 +18,14 @@ * 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 the com.oreilly.servlet library, 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. + * 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. */ package mircoders.servlet; @@ -38,16 +37,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Vector; + import javax.servlet.ServletContext; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.fileupload.FileItem; -import freemarker.template.SimpleHash; -import freemarker.template.SimpleList; - import mir.config.MirPropertiesConfiguration; import mir.entity.Entity; import mir.entity.EntityList; @@ -66,16 +62,21 @@ 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; +import org.apache.commons.fileupload.FileItem; + +import freemarker.template.SimpleHash; +import freemarker.template.SimpleList; + /* * ServletModuleBilder - * liefert HTML fuer Bilder * - * @version $Id: ServletModuleUploadedMedia.java,v 1.25 2003/04/21 02:58:30 zapata Exp $ + * @version $Id: ServletModuleUploadedMedia.java,v 1.28 2003/04/29 02:36:51 zapata Exp $ * @author RK, the mir-coders group */ @@ -173,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); @@ -390,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();