Modified config system:
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
index 6797d15..9a24af2 100755 (executable)
@@ -46,11 +46,11 @@ 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());
@@ -262,37 +262,24 @@ public class ServletModuleContent extends ServletModule
     catch(ModuleException 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");
+    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");
     
-    //1-1-relation
-    //schould be deleted soon
     try {
-      EntityContent entContent = (EntityContent)mainModule.getById(idParam);
-      entContent.dettach();
+      EntityContent entContent = (EntityContent)mainModule.getById(cidParam);
+      entContent.dettach(cidParam,midParam);
     }
     catch(ModuleException 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
@@ -389,11 +376,10 @@ 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);
       }