small bugfixx at comment-module
[mir.git] / source / mircoders / module / ModuleComment.java
1 package mircoders.module;
2
3 import java.io.*;
4 import java.lang.*;
5 import java.util.*;
6 import java.sql.*;
7 import javax.servlet.*;
8 import javax.servlet.http.*;
9
10 import freemarker.template.*;
11
12 import mir.servlet.*;
13 import mir.module.*;
14 import mir.entity.*;
15 import mir.misc.*;
16 import mir.storage.*;
17
18 import mircoders.storage.*;
19
20
21 /*
22  *  ModuleComment - methods and access for comments
23  *
24  * @author RK
25  */
26
27 public class ModuleComment extends AbstractModule
28 {
29   static Logfile theLog;
30
31   // Contructor
32   public ModuleComment(StorageObject theStorage)
33   {
34     if (theLog == null) theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Comment.Logfile"));
35     if (theStorage == null) theLog.printWarning("StorageObject was null!");
36     this.theStorage = theStorage;
37   }
38
39   // Methoden
40   public SimpleList getCommentAsSimpleList() throws ModuleException {
41     try {
42       return ((DatabaseComment)theStorage).getPopupData();
43     } catch (StorageObjectException e) {
44       throw new ModuleException(e.toString());
45     }
46   }
47   
48   /**
49    * setValues in the Entity and updates them on the StorageObject
50    */
51   public String set(HashMap theValues) throws ModuleException
52   {
53     try {
54       Entity theEntity = theStorage.selectById((String)theValues.get("id"));
55       if (theEntity == null)
56          throw new ModuleException("No Objekt with id in Database id: " + theValues.get("id"));
57       theEntity.setValues(theValues);
58       theEntity.update();
59       //set content to unproduced
60       DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
61       return theEntity.getId();
62     }
63     catch (StorageObjectException e){
64       e.printStackTrace(System.err);
65       throw new ModuleException(e.toString());
66     }
67   }
68 }