KickJava   Java API By Example, From Geeks To Geeks.

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


1 package de.webman.generator.eventhandler;
2
3 import java.io.*;
4 import java.net.*;
5 import java.util.*;
6
7 import com.teamkonzept.lib.*;
8 import com.teamkonzept.web.TKEvent;
9 import com.teamkonzept.web.TKHttpInterface;
10 import com.teamkonzept.webman.*;
11 import com.teamkonzept.webman.mainint.*;
12 import com.teamkonzept.webman.mainint.events.*;
13 import de.webman.acl.LoginFactory;
14
15 /**
16  * Starts the site transmitter
17  * @author $Author: torsten $
18  * @version $Revision: 1.7 $
19  
20  */

21 public class GRTransmitHandler extends DefaultEventHandler
22 {
23     
24     private static GRTransmitHandler instance = new GRTransmitHandler();
25     
26     boolean usePushlet = false;
27     
28     private GRTransmitHandler(){}
29     
30     public static GRTransmitHandler getInstance()
31     {
32         return instance;
33     }
34     
35     public void handleEvent(TKEvent evt) throws TKException
36     {
37         try
38         {
39             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.GENERATOR);
40             if ( GRGenerateHandler.isGenerationInProgress() )
41             {
42                 throw new TKUserException("Generation in Progress", GENERATION_IN_PROGRESS, USER_SEVERITY, false, null);
43             }
44             TKHttpInterface httpInf = evt.getHttpInterface();
45             PrintWriter log = new PrintWriter(httpInf.getLogStream());
46             boolean success = false;
47             
48             //Ausgaben in schönes HTML verpacken
49
GRHTMLWrapper out = new GRHTMLWrapper(new PrintWriter(httpInf.getOutputStream()), httpInf.getContextPath());
50
51             try
52             {
53                 String JavaDoc args = "";
54                 // getting config file through url
55
Hashtable params = httpInf.getParams();
56                 String JavaDoc query = (String JavaDoc)params.get("TK_PAR[configuration]");
57                 if ( query != null )
58                 {
59                     args += "configuration=" + query;
60                 }
61                 query = (String JavaDoc)params.get("TK_PAR[showlog]");
62                 if ( query != null )
63                 {
64                     args += ( args.length() == 0 ? "showlog=" + query : " showlog=" + query );
65                 }
66                 String JavaDoc docroot = httpInf.getDocumentRoot();
67     
68                 out.start("Stager",LoginFactory.getInstance().getLogin(evt.getRemoteUser()).getName());
69
70                 // starting process
71
ProcessStarter ps = new ProcessStarter(out, log);
72                 success = ps.start("webman.stager.SiteTransmitter",args,ProcessStarter.getWMClasspath(docroot));
73             }
74             catch (Exception JavaDoc e)
75             {
76                 out.println(e.toString());
77                 log.println(e);
78             }
79             
80             out.end(success);
81             out.close();
82             log.close();
83         }
84         catch (Throwable JavaDoc e)
85         {
86             // TO DO : Analyze Exception !
87
throw WebmanExceptionHandler.getException(e);
88         }
89     }
90
91     
92     public boolean isHandler(TKEvent evt)
93     {
94         return evt.getName().equalsIgnoreCase("GR_TRANSMIT");
95     }
96     
97 }
98
99
100
101
102
103
Popular Tags