Changeset 3476
- Timestamp:
- 2002-10-25T11:48:51+13:00 (22 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/Library2.java
r3363 r3476 37 37 public static void main(String args[]) { 38 38 39 if (args.length != 4) {40 System.out.println("Usage: Library2 < sites home> <site name> <interfaces home> <interface name>");39 if (args.length != 3) { 40 System.out.println("Usage: Library2 <gsdl3 home> <site name> <interface name>"); 41 41 System.exit(1); 42 42 } 43 43 44 44 ConfigVars config_ = new ConfigVars(); 45 config_. sites_home_ = args[0];45 config_.gsdl3_home_ = args[0]; 46 46 config_.site_name_ = args[1]; 47 config_.interfaces_home_ = args[2]; 48 config_.interface_name_ = args[3]; 47 config_.interface_name_ = args[2]; 49 48 50 49 config_.createXML(); … … 53 52 // the servlet wont use this directly 54 53 MessageRouter message_router_ = new MessageRouter(); 55 message_router_.setSiteHome(config_.sites_home_+File.separatorChar 56 +config_.site_name_); 54 55 message_router_.setSiteHome(GSFile.siteHome(config_.gsdl3_home_, 56 config_.site_name_)); 57 57 message_router_.configure(); 58 58 // new receptionist -
trunk/gsdl3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r3467 r3476 10 10 import java.io.File; 11 11 12 /** a servlet to serve the greenstone library - using servlets instead12 /** a servlet to serve the greenstone library - we are using servlets instead 13 13 * of cgi 14 14 * the init method is called only once - the first time the servlet classes … … 16 16 * method is called in a new thread (calls doGet/doPut etc) 17 17 * takes the a=p&p=home type args and builds a simple request to send to 18 * its receptionist, which returns theresult in html, cos output=html18 * its receptionist, which returns a result in html, cos output=html 19 19 * is set in the request 20 20 * @see Receptionist … … 33 33 config_ = new ConfigVars(); 34 34 String library_name_ = config.getInitParameter("libraryname"); 35 String sites_home_ = config.getInitParameter("siteshome");35 String gsdl3_home_ = config.getInitParameter("gsdl3home"); 36 36 String site_name_ = config.getInitParameter("sitename"); 37 String interfaces_home_ = config.getInitParameter("interfaceshome");38 37 String interface_name_ = config.getInitParameter("interfacename"); 39 if (library_name_ == null || sites_home_ == null || site_name_==null || interfaces_home_ ==null ||interface_name_==null) {38 if (library_name_ == null || gsdl3_home_ == null || site_name_==null || interface_name_==null) { 40 39 // must have this 41 40 System.err.println("initialisation parameters not all set!"); 42 System.err.println(" you must have libraryname, siteshome, sitename, interfaceshome,interfacename");41 System.err.println(" you must have libraryname, gsdl3home, sitename, interfacename"); 43 42 System.exit(1); 44 43 } 45 44 46 45 config_.library_name_ = library_name_; 47 config_. sites_home_ = sites_home_;46 config_.gsdl3_home_ = gsdl3_home_; 48 47 config_.site_name_ = site_name_; 49 config_.interfaces_home_ = interfaces_home_;50 48 config_.interface_name_ =interface_name_; 51 49 … … 55 53 // the servlet wont use this directly 56 54 message_router_ = new MessageRouter(); 57 message_router_.setSiteHome( config_.sites_home_+File.separatorChar58 +config_.site_name_);55 message_router_.setSiteHome(GSFile.siteHome(config_.gsdl3_home_, 56 config_.site_name_)); 59 57 message_router_.configure(); 60 58 // new receptionist … … 74 72 PrintWriter out = response.getWriter(); 75 73 74 // if the interface owns the default - keep this here, otherwise move 75 // it to receptionist 76 76 String lang = request.getParameter("l"); 77 77 if (lang==null || lang.equals("")) { … … 79 79 } 80 80 // the request to the receptionist 81 String xml_request="<message lang='"+lang+"'> ";81 String xml_request="<message lang='"+lang+"'><request type='action' output='html' action="; 82 82 83 83 String action = request.getParameter("a"); … … 85 85 // display the home page 86 86 // a=p&p=home 87 xml_request +=" <request type='action' output='html' action='p' subaction='home'/>";87 xml_request +="'p' subaction='home'/>"; 88 88 } else { 89 89 String subaction = request.getParameter("sa"); 90 xml_request += " <request type='action' action='"+action+"'";90 xml_request += "'"+action+"'"; 91 91 if (subaction != null) { 92 92 xml_request += " subaction='"+subaction+"'"; … … 96 96 while(params.hasMoreElements()) { 97 97 String name = (String)params.nextElement(); 98 if (!name.equals("a") && !name.equals("sa")) {99 98 //if (!name.equals("a") && !name.equals("sa")) { 99 String value = request.getParameter(name); 100 100 // for now, just add value as attribute - should un-url 101 102 103 104 }101 // encode them etc and so some might need to be text not atts 102 // or is that done already? 103 xml_request += "<param name='"+name+"' value='"+value+"'/>"; 104 // } 105 105 } 106 106 xml_request += "</paramList></request>"; -
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/ConfigVars.java
r3438 r3476 1 1 package org.greenstone.gsdl3.util; 2 3 /** holds all the site setup variables4 * includes a method to represent them as an XML node5 */6 2 7 3 import org.w3c.dom.Document; 8 4 import org.w3c.dom.Element; 9 5 6 /** holds all the site setup variables 7 * includes a method to represent them as an XML node 8 * 9 * is this only applicable to the servlet type interface? should this 10 * be called ServletConfigVars? or WebServletVars? 11 */ 10 12 public class ConfigVars { 11 13 14 /** the name that has been given to the servlet thats running eg library 15 * not needed for other types of clients*/ 12 16 public String library_name_=null; 13 public String sites_home_=null; 17 /** the gsdl home directory 18 * where the sites and interfaces directories live */ 19 public String gsdl3_home_ = null; 20 /** the name of the current site */ 14 21 public String site_name_=null; 15 public String interfaces_home_=null;22 /** the name of the current interface */ 16 23 public String interface_name_=null; 24 /** the xml <config> element containing all the variables */ 17 25 public Element config_xml_ = null; 18 26 27 /** creates the <config> Element containting all the variables*/ 19 28 public void createXML() { 20 29 … … 23 32 24 33 config_xml_ = doc.createElement("config"); 25 Element e = GSXML.createTextElement(doc, "library_name", library_name_); 34 35 Element e; 36 e = GSXML.createTextElement(doc, "library_name", library_name_); 26 37 config_xml_.appendChild(e); 27 e = GSXML.createTextElement(doc, " sites_home", sites_home_);38 e = GSXML.createTextElement(doc, "gsdl3_home", gsdl3_home_); 28 39 config_xml_.appendChild(e); 29 40 e = GSXML.createTextElement(doc, "site_name", site_name_); 30 config_xml_.appendChild(e);31 e = GSXML.createTextElement(doc, "interfaces_home", interfaces_home_);32 41 config_xml_.appendChild(e); 33 42 e = GSXML.createTextElement(doc, "interface_name", interface_name_);
Note:
See TracChangeset
for help on using the changeset viewer.