KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > content > eventhandler > CEExportHandler


1 package de.webman.content.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.*;
9 import com.teamkonzept.webman.mainint.events.*;
10 import com.teamkonzept.lib.*;
11 import com.teamkonzept.field.*;
12 import com.teamkonzept.field.db.*;
13 import com.teamkonzept.db.*;
14 import com.teamkonzept.publishing.markups.*;
15
16 import java.sql.*;
17 import java.io.*;
18
19 /**
20 * Exportieren von Content
21  * @author $Author: alex $
22  * @version $Revision: 1.6 $
23 */

24 public class CEExportHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
25 {
26     private CEExportHandler()
27     {}
28     
29     private static CEExportHandler instance = new CEExportHandler();
30     
31     public static CEExportHandler getInstance()
32     {
33         return instance;
34     }
35     
36     public void handleEvent(TKEvent evt) throws TKException
37     {
38         try
39         {
40             /*
41             CEUtils.checkEvent(evt);
42
43             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ce_fields.tmpl" );
44             ContentContext ceContext = CEUtils.keepCEContext( evt, t );
45
46             TKFormDBData data = new TKFormDBData( ceContext.formId.intValue() );
47             TKFormDBInterface.Get( data );
48             TKBaseField field = TKFieldRegistry.getFieldFromDB( data );
49             TKHashtable fieldContext = new TKHashtable();
50
51             Object realData = field.compileData( "", evt.getParams().getClass( PARAMETER ), fieldContext );
52
53             field.fillIntoTemplate( t, realData, "" );
54
55             evt.finishTemplate(t);
56
57             TKHashtable pathes = TKContentPathes.getContentPathes();
58             int nodeId = ceContext.conNodeType.intValue() == GROUP_INTEGER.intValue() ? ceContext.groupConNodeId : ceContext.conNodeId;
59
60             String contentPath = (String) pathes.get (new Integer (nodeId));
61             String contentFn = ceContext.conNodeShortName;
62
63             if (contentPath == null)
64             {
65                 return;
66             }
67
68             if (ceContext.conNodeType.intValue() == SINGLE_INTEGER.intValue()) {
69
70                 File fullPath = new File ((contentPath).replace ('/',File.separatorChar));
71                 contentFn = fullPath.getName();
72                 contentPath = fullPath.getParent();
73             }
74
75             TKMarkupAdmin.setup();
76             TKHTMLTemplate tt = evt.getPrepHTMLTemplate( "export/ce_fields.tmpl" );
77             ceContext.fillIntoTemplate (tt);
78             field.fillIntoTemplate( tt, realData, "" );
79             tt.doTagSubstitution();
80
81             String baseDir = (evt.getHttpInterface().getDocumentRoot()+"/export/content/"+contentPath)
82                 .replace ('/',File.separatorChar);
83
84             File expDir = new File( baseDir );
85
86             if( expDir.exists() ) {
87                 if( !expDir.isDirectory() ) {
88                     return ;
89                 }
90
91             } else if( !expDir.mkdirs() ) {
92                 return ;
93             }
94
95             File outFile = new File( expDir, contentFn+".xml" );
96             FileOutputStream f = new FileOutputStream( outFile );
97             PrintStream outf = new PrintStream(f);
98             tt.printTemplate( outf );
99             outf.close();
100             */

101             throw new RuntimeException JavaDoc("Event not implemented : " + evt.getName());
102             
103         }
104         catch (Throwable JavaDoc e)
105         {
106             // TO DO : Analyze Exception !
107
throw WebmanExceptionHandler.getException(e);
108         }
109     }
110     
111     public boolean isHandler(TKEvent evt)
112     {
113         return evt.getName().equalsIgnoreCase("CE_EXPORT");
114     }
115 }
116
Popular Tags