Added support for selection of topic/theme directly by open posters.
[mir.git] / source / mircoders / servlet / ServletModuleOpenIndy.java
index cc4e926..4d0052e 100755 (executable)
@@ -37,6 +37,7 @@ public class ServletModuleOpenIndy extends ServletModule
   private String          postingFormTemplate, postingFormDoneTemplate;
   private ModuleContent   contentModule;
   private ModuleImages    imageModule;
+  private ModuleTopics         themenModule;
   private String          directOp ="yes";
 
   // Singelton / Kontruktor
@@ -53,6 +54,7 @@ public class ServletModuleOpenIndy extends ServletModule
       directOp = MirConfig.getProp("DirectOpenposting").toLowerCase();
       mainModule = new ModuleComment(DatabaseComment.getInstance());
       contentModule = new ModuleContent(DatabaseContent.getInstance());
+      themenModule = new ModuleTopics(DatabaseTopics.getInstance());
       imageModule = new ModuleImages(DatabaseImages.getInstance());
       defaultAction="addposting";
     }
@@ -137,6 +139,7 @@ public class ServletModuleOpenIndy extends ServletModule
     }
     mergeData.put("medianum",numOfMedia);
     mergeData.put("mediafields",mediaFields);
+    mergeData.put("themenPopupData", themenModule.getTopicsAsSimpleList());
     
     
     /** @todo popups missing */
@@ -178,7 +181,17 @@ public class ServletModuleOpenIndy extends ServletModule
 
       // inserting  content into database
       String cid = contentModule.add(withValues);
-      
+
+      String[] to_topicsArr = mp.getParameterValues("to_topic"); 
+      if (to_topicsArr != null && to_topicsArr.length > 0) {
+        try{
+          DatabaseContentToTopics.getInstance().setTopics(cid,to_topicsArr);
+          theLog.printError("setting content_x_topic success");
+        } catch (Exception e) {
+          theLog.printError("setting content_x_topic failed");
+        } //end try
+      } //end if
+        
       // if op contains uploaddata
       String mediaId=null;
       int i=1;
@@ -222,9 +235,9 @@ public class ServletModuleOpenIndy extends ServletModule
               // inserting content and media id in table content_x_media
               try{
                 DatabaseContentToMedia.getInstance().addMedia(cid,mediaId);
-                theLog.printError("setting content_x_topic success");
+                theLog.printError("setting content_x_media success");
               } catch (Exception e) {
-                theLog.printError("setting content_x_topic failed");
+                theLog.printError("setting content_x_media failed");
               }
               
               // producing new page
@@ -254,7 +267,8 @@ public class ServletModuleOpenIndy extends ServletModule
     }
     catch (IOException e) { throw new ServletModuleException("IOException: "+ e.toString());}
     catch (StorageObjectException e) { throw new ServletModuleException("StorageObjectException" + e.toString());}
-    catch (ModuleException e) { throw new ServletModuleException("ModuleException"+e.toString());}
+    //catch (ModuleException e) { throw new ServletModuleException("ModuleException"+e.toString());}
+    catch (ModuleException e) { throw new ServletModuleException("ModuleException");}
 
     deliver(req, res, mergeData, postingFormDoneTemplate);
   }