/** *######################################################################### * * A component of the Gatherer application, part of the Greenstone digital * library suite from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * *

* * Author: John Thompson, Greenstone Digital Library, University of Waikato * *

* * Copyright (C) 1999 New Zealand Digital Library Project * *

* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * *

* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * *

* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *######################################################################## */ package org.greenstone.gatherer; import java.awt.*; import java.io.*; import java.lang.ref.*; import java.net.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.*; import org.greenstone.gatherer.util.ArrayTools; import org.greenstone.gatherer.util.StaticStrings; import org.greenstone.gatherer.util.Utility; import org.greenstone.gatherer.util.XMLTools; import org.w3c.dom.*; /** This class stores the mapping between sites and servlets available for them. The info is read in from the web.xml file. * @author Katherine Don, New Zealand Digital Library, University of Waikato * @version */ public class ServletConfiguration { static public String ADD_COMMAND = "?a=s&sa=a&st=collection&sn="; static public String DEACTIVATE_COMMAND = "?a=s&sa=d&st=collection&sn="; private String gsdl3_path = ""; private ArrayList sites = null; private HashMap mappings = null; public ServletConfiguration(String gsdl3_path) { this.gsdl3_path = gsdl3_path; //String web_xml_path = gsdl3_path + File.separator + "web" + File.separator + "WEB-INF"+ File.separator + "web.xml"; File web_xml = new File(gsdl3_path + "WEB-INF"+ File.separator + "web.xml"); if (!web_xml.exists()) { DebugStream.println("Error: no web.xml found at "+web_xml.toString()); return; } this.sites = new ArrayList(); // find the sites File start = new File(Utility.getSitesDir(gsdl3_path)); File possible_sites[] = start.listFiles(); ArrayTools.sort(possible_sites); for (int i=0; possible_sites != null && i < possible_sites.length; i++) { File site_config = new File(possible_sites[i], "siteConfig.xml"); if (site_config.exists()) { this.sites.add(possible_sites[i].getName()); } } this.mappings = new HashMap(); Document web_config = XMLTools.parseXMLFile(web_xml.getAbsolutePath(), false); NodeList servlet_mappings = web_config.getElementsByTagName("servlet-mapping"); // make a little map class HashMap url_mappings = new HashMap(); for (int i=0; i