1-n-relation content_media
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
index e01d76f..6797d15 100755 (executable)
@@ -254,6 +254,7 @@ 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);
@@ -261,6 +262,12 @@ 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);
   }
 
@@ -268,6 +275,9 @@ public class ServletModuleContent extends ServletModule
   {
     String  idParam = req.getParameter("cid");
     if (idParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");
+    
+    //1-1-relation
+    //schould be deleted soon
     try {
       EntityContent entContent = (EntityContent)mainModule.getById(idParam);
       entContent.dettach();
@@ -275,6 +285,13 @@ public class ServletModuleContent extends ServletModule
     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);
   }