1 package mircoders.servlet;
8 import java.lang.reflect.*;
9 import javax.servlet.*;
10 import javax.servlet.http.*;
12 import freemarker.template.*;
13 import com.oreilly.servlet.multipart.*;
14 import com.oreilly.servlet.*;
23 import mircoders.entity.*;
24 import mircoders.storage.*;
25 import mircoders.module.*;
26 import mircoders.producer.*;
29 * ServletModuleImages -
30 * liefert HTML fuer Images
36 public class ServletModuleImages extends ServletModuleUploadedMedia
39 //private static DatabaseRights dbRights;
41 // Singelton / Kontruktor
42 private static ServletModuleImages instance = new ServletModuleImages();
43 public static ServletModule getInstance() { return instance; }
46 private ServletModuleImages() {
47 theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Images.Logfile"));
48 templateListString = MirConfig.getProp("ServletModule.Images.ListTemplate");
49 templateObjektString = MirConfig.getProp("ServletModule.Images.ObjektTemplate");
50 templateConfirmString = MirConfig.getProp("ServletModule.Images.ConfirmTemplate");
52 mainModule = new ModuleImages(DatabaseImages.getInstance());
53 //dbRights = DatabaseRights.getInstance();
55 catch (StorageObjectException e) {
56 theLog.printDebugInfo("servletmodulebilder konnte nicht initialisiert werden");
60 public void showimg(HttpServletRequest req, HttpServletResponse res)
61 throws ServletModuleException
63 String idParam = req.getParameter("id");
64 if (idParam!=null && !idParam.equals("")) {
66 EntityImages entImage =(EntityImages)mainModule.getById(idParam);
68 (ServletContext)MirConfig.getPropAsObject("ServletContext");
69 String fName = entImage.getId()+"."
70 +entImage.getMediaType().getValue("name");
71 res.setContentType(ctx.getMimeType(fName));
72 ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
74 byte[] outbytes = entImage.getImage();
79 catch (IOException e) {throw new ServletModuleException(e.toString());}
80 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
81 catch (Exception e) {throw new ServletModuleException(e.toString());}
83 else theLog.printDebugInfo("id nicht angeben.");
84 // darf keine exception werfen
87 public void showicon(HttpServletRequest req, HttpServletResponse res)
88 throws ServletModuleException
90 String idParam = req.getParameter("id");
91 if (idParam!=null && !idParam.equals("")) {
93 EntityImages entImage =(EntityImages)mainModule.getById(idParam);
95 (ServletContext)MirConfig.getPropAsObject("ServletContext");
96 String fName = entImage.getId()+"."
97 +entImage.getMediaType().getValue("name");
98 res.setContentType(ctx.getMimeType(fName));
99 ServletOutputStream out = res.getOutputStream(); // wichtig, dass vorher kein res.getwriter() gelaufen ist
101 byte[] outbytes = entImage.getIcon();
106 catch (IOException e) {throw new ServletModuleException(e.toString());}
107 catch (ModuleException e) {throw new ServletModuleException(e.toString());}
108 catch (Exception e) {throw new ServletModuleException(e.toString());}
110 else throw new ServletModuleException("id nicht angeben.");