X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=source%2Fmircoders%2Fservlet%2FServletModuleUsers.java;h=d9b57f213a3f2c67d862dbb2cfac57a76c63e3c9;hb=a43304491d4492208e37c53449497a8a05731899;hp=0dae57d3ca69154da98ea720cfb604d3b5535454;hpb=8563841098b6ab3e6233f61519e58b41dcc30266;p=mir.git diff --git a/source/mircoders/servlet/ServletModuleUsers.java b/source/mircoders/servlet/ServletModuleUsers.java index 0dae57d3..d9b57f21 100755 --- a/source/mircoders/servlet/ServletModuleUsers.java +++ b/source/mircoders/servlet/ServletModuleUsers.java @@ -44,6 +44,7 @@ import mir.module.*; import mir.misc.*; import mir.entity.*; import mir.storage.*; +import mir.log.*; import mircoders.entity.*; import mircoders.storage.*; @@ -59,53 +60,58 @@ import mircoders.module.*; public class ServletModuleUsers extends mir.servlet.ServletModule { - // Singelton / Kontruktor - private static ServletModuleUsers instance = new ServletModuleUsers(); - public static ServletModule getInstance() { return instance; } + private static ServletModuleUsers instance = new ServletModuleUsers(); + public static ServletModule getInstance() { return instance; } - private ServletModuleUsers() { - theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Users.Logfile")); - templateListString = MirConfig.getProp("ServletModule.Users.ListTemplate"); - templateObjektString = MirConfig.getProp("ServletModule.Users.ObjektTemplate"); - templateConfirmString = MirConfig.getProp("ServletModule.Users.ConfirmTemplate"); - try { - mainModule = new ModuleUsers(DatabaseUsers.getInstance()); - } - catch (StorageObjectException e) { - theLog.printDebugInfo("servletmoduleusers konnte nicht initialisiert werden"); - } - } + private ServletModuleUsers() { + logger = new LoggerWrapper("ServletModule.Users"); - public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException - { - String idParam = req.getParameter("id"); - if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben"); - try { - //theLog.printInfo("Showing User with id: " + idParam); - deliver(req, res, mainModule.getById(idParam), templateObjektString); - } - catch (ModuleException e) { throw new ServletModuleException(e.toString());} - } + templateListString = MirConfig.getProp("ServletModule.Users.ListTemplate"); + templateObjektString = MirConfig.getProp("ServletModule.Users.ObjektTemplate"); + templateConfirmString = MirConfig.getProp("ServletModule.Users.ConfirmTemplate"); - public void add(HttpServletRequest req, HttpServletResponse res) - throws ServletModuleException - { - try { - SimpleHash mergeData = new SimpleHash(); - mergeData.put("new", "1"); - deliver(req, res, mergeData, templateObjektString); - } - catch (Exception e) { throw new ServletModuleException(e.toString());} - } + try { + mainModule = new ModuleUsers(DatabaseUsers.getInstance()); + } + catch (StorageObjectException e) { + logger.debug("initialization of ServletModuleUsers failed!: " + e.getMessage()); + } + } - public void insert(HttpServletRequest req, HttpServletResponse res) - throws ServletModuleException - { - try { - HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject()); - String id = mainModule.add(withValues); - deliver(req, res, mainModule.getById(id), templateObjektString); - } - catch (Exception e) { throw new ServletModuleException(e.toString());} - } + public void edit(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException + { + String idParam = req.getParameter("id"); + + if (idParam == null) + throw new ServletModuleException("ServletModuleUser.edit: invalid call: (id) not specified"); + + try { + deliver(req, res, mainModule.getById(idParam), templateObjektString); + } + catch (ModuleException e) { + throw new ServletModuleException(e.toString()); + } + } + + public void add(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + SimpleHash mergeData = new SimpleHash(); + mergeData.put("new", "1"); + deliver(req, res, mergeData, templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } + + public void insert(HttpServletRequest req, HttpServletResponse res) + throws ServletModuleException + { + try { + HashMap withValues = getIntersectingValues(req, mainModule.getStorageObject()); + String id = mainModule.add(withValues); + deliver(req, res, mainModule.getById(id), templateObjektString); + } + catch (Exception e) { throw new ServletModuleException(e.toString());} + } }