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 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 GRHTMLWrapper out = new GRHTMLWrapper(new PrintWriter(httpInf.getOutputStream()), httpInf.getContextPath()); 50 51 try 52 { 53 String args = ""; 54 Hashtable params = httpInf.getParams(); 56 String query = (String )params.get("TK_PAR[configuration]"); 57 if ( query != null ) 58 { 59 args += "configuration=" + query; 60 } 61 query = (String )params.get("TK_PAR[showlog]"); 62 if ( query != null ) 63 { 64 args += ( args.length() == 0 ? "showlog=" + query : " showlog=" + query ); 65 } 66 String docroot = httpInf.getDocumentRoot(); 67 68 out.start("Stager",LoginFactory.getInstance().getLogin(evt.getRemoteUser()).getName()); 69 70 ProcessStarter ps = new ProcessStarter(out, log); 72 success = ps.start("webman.stager.SiteTransmitter",args,ProcessStarter.getWMClasspath(docroot)); 73 } 74 catch (Exception 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 e) 85 { 86 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 |