Ok, big merge. here's the new xml-config stuff in action. There's a few
[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() {
41     return ((DatabaseComment)theStorage).getPopupData();
42   }
43   
44   /**
45    * setValues in the Entity and updates them on the StorageObject
46    */
47   public String set(HashMap theValues) throws ModuleException
48   {
49     try {
50       Entity theEntity = theStorage.selectById((String)theValues.get("id"));
51       if (theEntity == null)
52          throw new ModuleException("No Objekt with id in Database id: " + theValues.get("id"));
53       theEntity.setValues(theValues);
54       theEntity.update();
55       //set content to unproduced
56       DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getValue("to_media"));
57       return theEntity.getId();
58     }
59     catch (StorageObjectException e){
60       e.printStackTrace(System.err);
61       throw new ModuleException(e.toString());
62     }
63   }
64 }