1 14 package webEditor; 15 16 import java.io.*; 17 import java.lang.reflect.*; 18 import java.util.*; 19 20 import javax.servlet.*; 21 import javax.servlet.http.*; 22 import org.w3c.dom.*; 23 24 import webEditor.core.*; 25 import webEditor.util.*; 26 import webEditor.interfaces.*; 27 28 36 37 public class wEd extends HttpServlet { 38 39 String wEd_root = null; 42 43 String tmpDir = null; 44 45 configuration initConfig = null; 46 47 52 public void initialLoad (configuration initTable) { 53 54 55 this.tmpDir = initTable.readValue ("directories", "tmpDir"); 56 } 57 58 59 65 public void doGet (HttpServletRequest request, HttpServletResponse response) 66 throws ServletException, 67 IOException { 68 PrintWriter out; 69 HttpParameterParser myParser = new HttpParameterParser (request); 70 Hashtable parameters = new Hashtable (); 71 Hashtable headers = new Hashtable (); 72 73 response.setContentType("text/html"); 75 76 out = response.getWriter(); 78 79 this.wEd_root = this.getInitParameter("wEd_root"); 81 if (this.wEd_root == null) { 82 this.wEd_error ("wEd_root environment variable not defined",out); 84 return; 85 } 86 87 File checker = new File (this.wEd_root + "/general.xml"); 89 if ( !checker.exists() ) { 90 this.wEd_error ("webEditor configuration file (" + 91 this.wEd_root + "/general.xml) doesn't exists",out); 92 return; 93 } 94 95 this.initConfig = new configuration (this.wEd_root + "/general.xml"); 96 this.initialLoad (this.initConfig); 97 this.initConfig.storeValue ("webEditor_Root", "wEd_root", this.wEd_root); 99 100 parameters = myParser.getAllParameters (this.tmpDir); 102 this.initConfig.storeCategory ("HTTP Parameters", parameters); 103 headers = myParser.getAllHeaders (); 104 this.initConfig.storeCategory ("HTTP Headers", headers); 105 106 107 String opMode = this.initConfig.readValue ("HTTP Parameters", "mode"); 108 109 if (opMode == null) { 110 opMode = "composition"; 112 } 113 114 try { 115 Method m = getClass().getMethod(opMode, new Class [] {HttpServletRequest.class, PrintWriter.class} ); 117 m.invoke(this,new Object [] {request, out}); 118 } 119 catch (Exception e) { 120 out.println ("Method not supported"); 121 } 122 123 out.close(); 124 } 125 126 132 public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, 133 IOException 134 { 135 this.doGet (request , response); 136 } 137 138 144 public void composition (HttpServletRequest request, PrintWriter out) 145 throws ServletException, IOException 146 { 147 compositionMode myIndex = new compositionMode (this.initConfig); 148 myIndex.presentation (request, out); 149 } 150 151 157 public void config (HttpServletRequest request, PrintWriter out) 158 throws ServletException, IOException 159 { 160 configMode myConfig = new configMode(this.initConfig); 161 myConfig.showConfig (request, out); 162 } 163 164 170 public void edit (HttpServletRequest request, PrintWriter out) 171 throws ServletException, IOException 172 { 173 editMode myEditor = new editMode (initConfig); 174 myEditor.edition (request, out); 175 } 176 177 183 public void presentation (HttpServletRequest request, PrintWriter out) 184 throws ServletException, IOException 185 { 186 presentationMode myIndex = new presentationMode (this.initConfig); 187 myIndex.presentation (request, out); 188 } 189 190 196 public void images (HttpServletRequest request, PrintWriter out) 197 throws ServletException, IOException 198 { 199 imageMode myImage = new imageMode (this.initConfig); 200 myImage.edition (request, out); 201 } 202 203 208 public void wEd_error (String errorString, PrintWriter out) 209 { 210 String outputString = "<center><font face=\"Arial\" >" + 211 errorString + "</font></center>"; 212 213 out.println (outputString); 214 } 215 216 } 217 | Popular Tags |