1 14 15 package webEditor.interfaces; 16 17 import java.io.*; 18 import java.lang.reflect.*; 19 import java.util.*; 20 21 import javax.servlet.*; 22 import javax.servlet.http.*; 23 import org.w3c.dom.*; 24 25 import webEditor.util.*; 26 import webEditor.core.*; 27 28 32 33 public class configMode { 34 35 38 private configuration initValues; 39 40 43 private String wEd_root; 44 45 48 private String dataDir; 49 50 53 private String tplDir; 54 55 58 private xml_parser confParser= null; 59 60 63 private presentation myEditor= null; 64 65 69 public configMode (configuration initParam) { 70 71 this.initValues = initParam; 72 this.wEd_root = initParam.readValue ("webEditor_Root","wEd_root"); 73 74 this.dataDir = initParam.readValue ("directories","dataDir"); 75 this.dataDir = this.wEd_root + "/" + this.dataDir; 76 77 this.tplDir = initParam.readValue ("directories","tplDir"); 78 this.tplDir = this.dataDir + "/" + this.tplDir; 79 } 80 81 87 public void showConfig (HttpServletRequest request, PrintWriter out) 88 throws ServletException, 89 IOException { 90 91 String outputString = ""; 92 this.confParser = new xml_parser (); 93 this.myEditor = new presentation (this.initValues); 94 95 String opCode = this.initValues.readValue ("HTTP Parameters", "code"); 96 if (opCode == null) { 97 opCode = "show"; 99 } 100 101 try { 102 Method m = getClass().getMethod(opCode, new Class [] {HttpServletRequest.class, PrintWriter.class} ); 104 m.invoke(this,new Object [] {request, out}); 105 } 106 catch (Exception e) { 107 out.println ("Code not supported"); 108 } 109 110 } 111 112 118 public void edit (HttpServletRequest request, PrintWriter out) 119 throws ServletException, IOException 120 { 121 String action = this.initValues.readValue ("HTTP Parameters", "action"); 122 if (action == null) { 123 action = "show"; 124 } 125 configuration configValues = null; 126 if ( action.equals ("Save") ) { 127 Hashtable http_params = this.initValues.readCategory ("HTTP Parameters"); 129 130 configValues = new configuration (this.wEd_root + "/general.xml"); 131 Document oldConfig = this.confParser.writeDOM ("general", 132 configValues.returnData()); 133 oldConfig = configValues.writeDoc (http_params, oldConfig); 135 configValues.saveConfig (this.wEd_root + "/general.xml", oldConfig); 136 } 137 138 configValues = new configuration (this.wEd_root + "/general.xml"); 139 Document doc = this.confParser.writeDOM ("general", configValues.returnData()); 140 String outputString = this.myEditor.showConfigEditor (doc); 141 142 out.println (outputString); 143 } 144 145 151 public void show (HttpServletRequest request, PrintWriter out) 152 throws ServletException, IOException 153 { 154 Document doc = this.confParser.writeDOM ("general", this.initValues.returnData()); 156 String outputString = this.myEditor.showConfig (doc); 157 out.println (outputString); 158 } 159 160 } 161 | Popular Tags |