KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > duplication > eventhandler > DUSaveParamsInDBHandler


1 package de.webman.duplication.eventhandler;
2
3 import com.teamkonzept.web.*;
4 import com.teamkonzept.webman.*;
5 import com.teamkonzept.webman.db.TKWebmanDBManager;
6 import com.teamkonzept.webman.mainint.*;
7 import com.teamkonzept.webman.mainint.db.*;
8 import com.teamkonzept.webman.mainint.db.queries.duplication.*;
9
10
11 import com.teamkonzept.webman.mainint.db.queries.*;
12
13 import com.teamkonzept.webman.mainint.events.*;
14 import com.teamkonzept.lib.*;
15 import com.teamkonzept.field.*;
16 import com.teamkonzept.field.db.*;
17 import com.teamkonzept.db.*;
18 import com.teamkonzept.publishing.markups.*;
19
20 import java.sql.*;
21 import java.io.*;
22
23
24
25 /************************************************************************
26 /**
27 * Anzeigen der Maske zum Neuordnen des Contenttree
28 *
29 *
30 * @param
31 */

32 public class DUSaveParamsInDBHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
33 {
34     private DUSaveParamsInDBHandler()
35     {}
36     
37     private static DUSaveParamsInDBHandler instance = new DUSaveParamsInDBHandler();
38     
39     public static DUSaveParamsInDBHandler getInstance()
40     {
41         return instance;
42     }
43     
44     public void handleEvent(TKEvent evt) throws TKException
45     {
46         try{
47         // In der DB aufraeumen
48
TKQuery query = TKDBManager.newQuery(TKDBDeleteDUProperties.class) ;
49         query.execute();
50         query.close();
51         
52         // Neue Parameterwerte in DB schrteiben
53
ensurePropertyInDB("TEMPLATE_ROOT_ID", evt);
54         ensurePropertyInDB("TARGET_ROOT_ID", evt);
55         ensurePropertyInDB("ST_SUBTREE_ROOT_ID", evt);
56         ensurePropertyInDB("ST_TARGET_ROOT_ID", evt);
57         ensurePropertyInDB("ST_SUBTREE_ROOT_ID", evt);
58         ensurePropertyInDB("SITE_TREE_FLAG", evt);
59         ensurePropertyInDB("CONTENT_FLAG", evt);
60         
61         TKHTMLTemplate t = evt.getPrepHTMLTemplate( "du_intro.tmpl" );
62         t.set( "DONE", "1" );
63         t.set( "DB", "STORED" );
64         evt.finishTemplate(t);
65 // return true;
66
}
67         catch (Throwable JavaDoc e)
68         {
69             // TO DO : Analyze Exception !
70
throw WebmanExceptionHandler.getException(e);
71         }
72     }
73     
74     public boolean isHandler(TKEvent evt)
75     {
76         return evt.getName().equalsIgnoreCase("DU_STORE_IN_DB");
77     }
78         
79     /** Inserted einen Parameter in die DB als Property mit praefix "DU_",
80     * Stellt sicher, dass mindestens der Leerstring drinsteht
81     */

82     private void ensurePropertyInDB(String JavaDoc propName, TKEvent evt) throws SQLException{
83     
84             TKParams params = evt.getParams();
85         String JavaDoc propValue = params.get( "PAR",propName ) != null ? params.get( "PAR", propName ) : "" ;
86         TKQuery query = TKDBManager.newQuery(TKDBPutProperty.class) ;
87         query.setQueryParams("NAME", "DU_" + propName);
88         query.setQueryParams("VALUE", propValue);
89         query.execute();
90         query.close();
91         
92     }
93     
94         
95 }
96
Popular Tags