/**
*#########################################################################
*
* 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.greenstone3;
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.Gatherer;
import org.greenstone.gatherer.DebugStream;
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.greenstone.gatherer.remote.RemoteGreenstoneServer;
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;
if (Gatherer.isGsdlRemote){
web_xml = new File(gsdl3_path + "web.xml");
}else{
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();
if (Gatherer.isGsdlRemote){
if (RemoteGreenstoneServer.downloadWebXMLFile().equals("")) {
System.err.println("Error: Could not download web.xml.");
System.exit(0);
}
String sites_on_server = RemoteGreenstoneServer.getSiteNames();
if (sites_on_server.equals("")) {
// !! Something went wrong : could not get names of the sites
System.err.println("Error: Could not get names of the sites.");
System.exit(0);
}
String[] sites_arr=sites_on_server.split("-----");
for (int i=0; i