X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Fservlet%2FServletModuleContent.java;h=a438ad8ac23d4283cd787f428a63f2ad21494f71;hb=7f8c84deada65f3aad3ef3931b3153d504969f6e;hp=6797d1536ab6d924dc0d9b20deeb05afb9517a3c;hpb=35404b2e50dc83add87eeed6aafe2d858447a7b0;p=mir.git diff --git a/source/mircoders/servlet/ServletModuleContent.java b/source/mircoders/servlet/ServletModuleContent.java index 6797d153..a438ad8a 100755 --- a/source/mircoders/servlet/ServletModuleContent.java +++ b/source/mircoders/servlet/ServletModuleContent.java @@ -34,7 +34,6 @@ public class ServletModuleContent extends ServletModule static ModuleTopics themenModule; static ModuleSchwerpunkt schwerpunktModule; - static ModuleGruppen gruppenModule; static ModuleImages imageModule; static String templateOpString; @@ -46,15 +45,14 @@ public class ServletModuleContent extends ServletModule private ServletModuleContent() { try { - theLog = Logfile.getInstance(Configuration.getProperty("Home") + Configuration.getProperty("ServletModule.Content.Logfile")); - templateListString = Configuration.getProperty("ServletModule.Content.ListTemplate"); - templateOpString = Configuration.getProperty("ServletModule.Content.OpTemplate"); - templateObjektString = Configuration.getProperty("ServletModule.Content.ObjektTemplate"); - templateConfirmString = Configuration.getProperty("ServletModule.Content.ConfirmTemplate"); + theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("ServletModule.Content.Logfile")); + templateListString = MirConfig.getProp("ServletModule.Content.ListTemplate"); + templateOpString = MirConfig.getProp("ServletModule.Content.OpTemplate"); + templateObjektString = MirConfig.getProp("ServletModule.Content.ObjektTemplate"); + templateConfirmString = MirConfig.getProp("ServletModule.Content.ConfirmTemplate"); mainModule = new ModuleContent(DatabaseContent.getInstance()); themenModule = new ModuleTopics(DatabaseTopics.getInstance()); schwerpunktModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance()); - gruppenModule = new ModuleGruppen(DatabaseGroups.getInstance()); imageModule = new ModuleImages(DatabaseImages.getInstance()); } catch (StorageObjectException e) { theLog.printDebugInfo("servletmodulecontent konnte nicht initialisiert werden"); @@ -148,19 +146,27 @@ public class ServletModuleContent extends ServletModule mergeData.put("is_published", "1"); String now = StringUtil.date2webdbDate(new GregorianCalendar()); mergeData.put("date", new SimpleScalar(now)); - mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); - mergeData.put("gruppenPopupData", gruppenModule.getGruppenAsSimpleList()); + try { + mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); + } catch (ModuleException e) { + theLog.printError("cannot get topics as simple list."); + throw new ServletModuleException(e.toString()); + } try { mergeData.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData()); } catch (Exception e) { theLog.printError("articletype could not be fetched."); + throw new ServletModuleException("articletype could not be fetched: " + +e.toString()); } try { mergeData.put("languagePopupData", DatabaseLanguage.getInstance().getPopupData()); + mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); } catch (Exception e) { - theLog.printError("language-popup could not be fetched."); + theLog.printError("language-popup or scwerpunk list could not be fetched."); + throw new ServletModuleException("language/schwerpunkt list could not be fetched.: " + +e.toString()); } - mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); mergeData.put("login_user", HTMLTemplateProcessor.makeSimpleHash(user)); deliver(req, res, mergeData, templateObjektString); } @@ -254,45 +260,32 @@ public class ServletModuleContent extends ServletModule String mediaIdParam = req.getParameter("mid"); String idParam = req.getParameter("cid"); if (idParam == null||mediaIdParam==null) throw new ServletModuleException("smod content :: attach :: cid/mid missing"); - + try { EntityContent entContent = (EntityContent)mainModule.getById(idParam); entContent.attach(mediaIdParam); } - catch(ModuleException e) { + catch(Exception e) { theLog.printError("smod content :: attach :: could not get entityContent"); } - - try{ - DatabaseContentToMedia.getInstance().setMedia(idParam,mediaIdParam); - } catch(Exception e){ - theLog.printError("set media failed"); - } _showObject(idParam, req, res); } public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException { - String idParam = req.getParameter("cid"); - if (idParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing"); - - //1-1-relation - //schould be deleted soon + String cidParam = req.getParameter("cid"); + String midParam = req.getParameter("mid"); + if (cidParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing"); + if (midParam == null) throw new ServletModuleException("smod content :: dettach :: mid missing"); + try { - EntityContent entContent = (EntityContent)mainModule.getById(idParam); - entContent.dettach(); + EntityContent entContent = (EntityContent)mainModule.getById(cidParam); + entContent.dettach(cidParam,midParam); } - catch(ModuleException e) { + catch(Exception e) { theLog.printError("smod content :: dettach :: could not get entityContent"); } - - //1-n-relation - try{ - DatabaseContentToMedia.getInstance().deleteByContentId(idParam); - } catch(Exception e){ - theLog.printError("remove media failed"); - } - _showObject(idParam, req, res); + _showObject(cidParam, req, res); } public void newswire(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException @@ -303,8 +296,9 @@ public class ServletModuleContent extends ServletModule EntityContent entContent = (EntityContent)mainModule.getById(idParam); entContent.newswire(); } - catch(ModuleException e) { + catch(Exception e) { theLog.printError("smod content :: newswire :: could not get entityContent"); + throw new ServletModuleException("smod content :: newswire :: could not get entityContent"+e.toString()); } list(req, res); } @@ -377,7 +371,6 @@ public class ServletModuleContent extends ServletModule //obsolete, because of psqgl 7.1.x //mergeData.put("content_data", entContent.getContentData()); mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList()); - mergeData.put("gruppenPopupData", gruppenModule.getGruppenAsSimpleList()); try { mergeData.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData()); } catch (Exception e) { @@ -389,15 +382,13 @@ public class ServletModuleContent extends ServletModule theLog.printError("language-popup could not be fetched."); } // get the images - String currentMediaId = entContent.getValue("to_media"); - SimpleHash imageHash = new SimpleHash(); - if (currentMediaId!=null && !currentMediaId.equals("")) { - imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId))); - mergeData.put("images", imageHash); + EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(entContent); + if (currentMedia!=null && currentMedia.getCount()>=1) { + SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia); + mergeData.put("to_media", mediaList); } - //mergeData.put("gruppenHashData", gruppenModule.getHashData()); mergeData.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList()); // hier code um zur liste zurueckzukommen String offsetParam, whereParam, orderParam; @@ -421,7 +412,6 @@ public class ServletModuleContent extends ServletModule SimpleHash modelRoot = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(theList); modelRoot.put("themenHashData", themenModule.getHashData()); modelRoot.put("schwerpunktHashData", schwerpunktModule.getHashData()); - modelRoot.put("gruppenHashData", gruppenModule.getHashData()); modelRoot.put("articletypeHash", DatabaseArticleType.getInstance().getHashData()); deliver(req, res, modelRoot, templateListString); } else { // count = 1 @@ -436,11 +426,10 @@ public class ServletModuleContent extends ServletModule throws ServletModuleException { try { - // hier dann htmlcode rausschreiben + // delivering html if (theList == null || theList.getCount() == 0 || theList.getCount()>1) { SimpleHash modelRoot = HTMLTemplateProcessor.makeSimpleHashWithEntitylistInfos(theList); modelRoot.put("articletypeHash", DatabaseArticleType.getInstance().getHashData()); - modelRoot.put("gruppenHashData", gruppenModule.getHashData()); deliver(req, res, modelRoot, templateListString); } else { // count = 1 _showObject(theList.elementAt(0).getId(), req, res);