KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > generator > eventhandler > GRValidateHandler


1 package de.webman.generator.eventhandler;
2
3 import java.io.*;
4 import java.net.*;
5
6 import com.teamkonzept.lib.*;
7 import com.teamkonzept.web.TKEvent;
8 import com.teamkonzept.web.TKHttpInterface;
9 import com.teamkonzept.webman.*;
10 import com.teamkonzept.webman.mainint.*;
11 import com.teamkonzept.webman.mainint.events.*;
12
13 /**
14 * Starts the validator.
15  * @author $Author: alex $
16  * @version $Revision: 1.2 $
17 */

18 public class GRValidateHandler extends DefaultEventHandler
19 {
20     private static GRValidateHandler instance = new GRValidateHandler();
21     
22     private GRValidateHandler()
23     {
24     }
25     
26     public static GRValidateHandler getInstance()
27     {
28         return instance;
29     }
30     
31     public void handleEvent(TKEvent evt) throws TKException
32     {
33         try
34         {
35             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.GENERATOR);
36
37             TKHttpInterface httpInf = evt.getHttpInterface();
38             PrintWriter out = new PrintWriter(httpInf.getOutputStream());
39             PrintWriter log = new PrintWriter(httpInf.getLogStream());
40             
41             println(out, getHeaderString());
42                                     
43             ProcessStarter ps = new ProcessStarter(out, log);
44             boolean successful = false;
45             try {
46                 String JavaDoc args = httpInf.getDocumentRoot() + " htmlOut";
47                 successful = ps.start("WebManValidator", args,
48                     ProcessStarter.getWMClasspath(httpInf.getDocumentRoot()));
49             }
50             catch (Exception JavaDoc e) {
51                 println(out, e.toString());
52                 log.println(e);
53             }
54             
55             // TODO: the backPath argument assumes WebManGen and WebManServlet
56
// in the same directory, - this may cause problems...
57
println(out, getReturnString(httpInf.getOwnName()));
58             println(out, getFooterString());
59                         
60             out.close();
61             log.close();
62         }
63         catch (Throwable JavaDoc e)
64         {
65             // TO DO : Analyze Exception !
66
throw WebmanExceptionHandler.getException(e);
67         }
68     }
69     
70     public boolean isHandler(TKEvent evt)
71     {
72         return evt.getName().equalsIgnoreCase("GR_VALIDATE");
73     }
74     
75     private String JavaDoc getHeaderString()
76     {
77         return "<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\"><META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"></HEAD><BODY>";
78     }
79     
80     private String JavaDoc getFooterString()
81     {
82         return "</BODY></HTML>";
83     }
84     
85     private String JavaDoc getReturnString(String JavaDoc backpath)
86     {
87         return "<A HREF=\"" + backpath + "\">zur&uuml;ck zum WebMan-Menu</A><br>";
88     }
89     
90     private void println(PrintWriter out, String JavaDoc line)
91     {
92         out.println(line);
93     }
94 }
95
Popular Tags