KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > sitetree > eventhandler > STDuplicateDocumentHandler


1 package de.webman.sitetree.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
9
10 import com.teamkonzept.webman.mainint.db.queries.*;
11 import com.teamkonzept.webman.mainint.events.*;
12 import com.teamkonzept.lib.*;
13 import com.teamkonzept.field.*;
14 import com.teamkonzept.field.db.*;
15 import com.teamkonzept.db.*;
16 import com.teamkonzept.publishing.markups.*;
17
18 import java.sql.*;
19 import java.io.*;
20 import java.util.*;
21
22 /**
23 * Speichern des ueberschriebenen geerbten docs !!! shortname bleibt !!!
24 * (duplizieren des geerbten docs fuer diesen node)
25 *
26 * @author $Author: alex $
27 * @version $Revision: 1.3 $
28 */

29 public class STDuplicateDocumentHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
30 {
31     private STDuplicateDocumentHandler()
32     {}
33     
34     private static STDuplicateDocumentHandler instance = new STDuplicateDocumentHandler();
35     
36     public static STDuplicateDocumentHandler getInstance()
37     {
38         return instance;
39     }
40     
41     public void handleEvent(TKEvent evt) throws TKException
42     {
43         try
44         {
45             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.SITE_TREE);
46             String JavaDoc sDocType = evt.getParameter( PARAMETER, "DOCUMENT_TYPE" );
47             String JavaDoc sExtUrl = evt.getNotNullParameter( PARAMETER, "EXTERNAL_URL" );
48
49             String JavaDoc sOldNodeId = evt.getParameter( PARAMETER, "OLD_SITE_NODE_ID" );
50             String JavaDoc sOldNodeDocIdx = evt.getParameter( PARAMETER, "OLD_SITE_NODE_DOC_IDX" );
51             String JavaDoc sNodeId = evt.getParameter( PARAMETER, "SITE_NODE_ID" );
52             String JavaDoc sPresId = evt.getParameter( PARAMETER, "PRESENTATION_ID" );
53             String JavaDoc sDocName = evt.getParameter( PARAMETER, "DOCUMENT_NAME" );
54             String JavaDoc sDocShortName = evt.getParameter( PARAMETER, "DOCUMENT_SHORTNAME" );
55             String JavaDoc sHeretable = evt.getNotNullParameter( PARAMETER, "INHERITABLE" );
56             String JavaDoc sInheritBeginLevel = evt.getParameter( PARAMETER, "INHERIT_BEGIN_LEVEL" );
57             String JavaDoc sInheritEndLevel = evt.getParameter( PARAMETER, "INHERIT_END_LEVEL" );
58             if (sInheritBeginLevel.equals(""))
59                 sInheritBeginLevel = null;
60             if (sInheritEndLevel.equals(""))
61                 sInheritEndLevel = null;
62             
63             int heretable = sHeretable.equals( "" ) ? 0 : Integer.parseInt( sHeretable );
64             Integer JavaDoc inheritBeginLevel = sInheritBeginLevel!=null ? new Integer JavaDoc(sInheritBeginLevel) : null;
65             Integer JavaDoc inheritEndLevel = sInheritEndLevel!=null ? new Integer JavaDoc(sInheritEndLevel) : null;
66           
67             TKQuery q = TKDBManager.newQuery(TKDBSiteDocClone.class);
68             q.setQueryParams( "NODE_ID", new Integer JavaDoc(sOldNodeId) );
69             q.setQueryParams( "NODE_DOC_IDX", new Integer JavaDoc(sOldNodeDocIdx) );
70             q.setQueryParams( "SITE_NODE_ID", new Integer JavaDoc(sNodeId) );
71             q.setQueryParams( "PRESENTATION_ID", new Integer JavaDoc(sPresId) );
72             q.setQueryParams( "DOCUMENT_NAME", sDocName );
73             q.setQueryParams( "DOCUMENT_SHORTNAME", sDocShortName );
74             q.setQueryParams( "DOCUMENT_TYPE", new Integer JavaDoc(sDocType) );
75             q.setQueryParams( "EXTERNAL_URL", sExtUrl.equals( "" )?null:sExtUrl );
76             q.setQueryParams( "INHERITABLE", new Integer JavaDoc(heretable) );
77             q.setQueryParams( "INHERIT_BEGIN_LEVEL", inheritBeginLevel);
78             q.setQueryParams( "INHERIT_END_LEVEL", inheritEndLevel);
79             q.execute();
80             //ResultSet rs = q.fetchResultSet();
81
q.fetchResultSet();
82             STEditHandler.getInstance().handleEvent(evt);
83         }
84         catch (Throwable JavaDoc e)
85         {
86             // TO DO : Analyze Exception !
87
throw WebmanExceptionHandler.getException(e);
88         }
89     }
90     
91     public boolean isHandler(TKEvent evt)
92     {
93         return evt.getName().equalsIgnoreCase("ST_DUPLICATE_DOCUMENT");
94     }
95 }
96
Popular Tags