Changeset 36103


Ignore:
Timestamp:
2022-03-11T10:07:12+13:00 (2 years ago)
Author:
kjdon
Message:

added second hashmap so we can get site name for a servlet path

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/greenstone3/ServletConfiguration.java

    r26004 r36103  
    6363    private String gsdl3_path = "";
    6464    private ArrayList sites = null;
    65     private HashMap mappings = null;
     65    private HashMap site_to_servlet_list_map = null;
     66    private HashMap servlet_to_site_map = null;
    6667
    6768    public ServletConfiguration(String gsdl3_path) {
     
    7172    if (Gatherer.isGsdlRemote){
    7273        if (Gatherer.remoteGreenstoneServer.downloadWebXMLFile().equals("")) {
    73         System.err.println("Error: Could not download web.xml.");
     74        System.err.println("ServletConfiguration Error: Could not download web.xml.");
    7475        System.exit(0);
    7576        }
     
    9293        if (sites_on_server.equals("")) {
    9394        // !! Something went wrong : could not get names of the sites
    94         System.err.println("Error: Could not get names of the sites.");
     95        System.err.println("ServletConfiguration Error: Could not get names of the sites.");
    9596        System.exit(0);
    9697        }
     
    115116    }
    116117
    117     this.mappings = new HashMap();
     118    this.site_to_servlet_list_map = new HashMap();
     119    this.servlet_to_site_map = new HashMap();
    118120    Document web_config = XMLTools.parseXMLFile(web_xml.getAbsolutePath(), false);
    119121       
     
    137139           
    138140        if (site != null) {
    139         ArrayList this_site = (ArrayList)mappings.get(site);
     141        ArrayList this_site = (ArrayList)site_to_servlet_list_map.get(site);
    140142        if (this_site == null) {
    141143            this_site = new ArrayList();
     
    146148        }
    147149        this_site.add(url);
    148         mappings.put(site, this_site);
     150        this.site_to_servlet_list_map.put(site, this_site);
     151        this.servlet_to_site_map.put(url, site);
    149152        }
    150153       
     
    160163
    161164    public ArrayList getServletsForSite(String site) {
    162     return (ArrayList)this.mappings.get(site);
     165    return (ArrayList)this.site_to_servlet_list_map.get(site);
    163166    }
    164167    public String getServletPath(String site) {
    165168   
    166169    // for now, get the first one
    167     ArrayList servlets = (ArrayList)mappings.get(site);
     170    ArrayList servlets = (ArrayList)this.site_to_servlet_list_map.get(site);
    168171    if(servlets == null) {
    169172        return null;
    170173    }
    171174    return (String)servlets.get(0);
     175    }
     176
     177    public String getSiteForServlet(String servlet) {
     178    return (String)this.servlet_to_site_map.get(servlet);
    172179    }
    173180
Note: See TracChangeset for help on using the changeset viewer.