Changeset 4672


Ignore:
Timestamp:
2003-06-16T10:03:28+12:00 (21 years ago)
Author:
jmt12
Message:

Local library stuff - use its own glisite.cfg file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/GSDLSiteConfig.java

    r4620 r4672  
    1212
    1313    static final public String ADD_COMMAND = "?a=config&cmd=add-collection&c=";
     14    static final public String SPECIFIC_CONFIG = "--config=";
    1415    static final public String RELEASE_COMMAND = "?a=config&cmd=release-collection&c=";
    1516    static final public String QUIT_COMMAND = "?a=config&cmd=kill";
     
    1920    static final private String ENTERLIB = "enterlib";
    2021    static final private String FALSE = "0";
    21     static final private String GLISITE = null ;//"glisite.cfg";
     22    static final private String GLISITE_CFG = "glisite.cfg";
    2223    static final private String GSDL = "gsdl";
    2324    static final private String GSDLSITE_CFG = "gsdlsite.cfg";
     25    static final private String LOCAL_HOST = "localhost";
    2426    static final private String PORTNUMBER = "portnumber";
    2527    static final private String SEPARATOR = "/";
     
    3133    debug("New GSDLSiteConfig for: " + server_exe.getAbsolutePath());
    3234    gsdlsite_cfg = new File(server_exe.getParentFile(), GSDLSITE_CFG);
    33     //glisite_cfg = new File(server_exe.getParentFile(), GLISITE_CFG);
     35    glisite_cfg = new File(server_exe.getParentFile(), GLISITE_CFG);
    3436    autoenter_initial = null;
    3537    start_browser_initial = null;
    36     load();
    37     }
    38 
    39     public boolean exists() {
    40     return gsdlsite_cfg.exists();
    41     }
    42 
    43     public String getSiteConfigFilename() {
    44     //return GLISITE_CFG;
    45     return GSDLSITE_CFG;
    46     }
    47 
    48     public String getURL() {
    49     // URL is made from url and portnumber
    50     String url = (String) get(URL);
    51     if(url != null) {
    52         StringBuffer temp = new StringBuffer(url);
    53         temp.append(COLON);
    54         temp.append((String)get(PORTNUMBER));
    55         String enterlib = (String)get(ENTERLIB);
    56         if(enterlib == null || enterlib.length() == 0) {
    57         // Use the default /gsdl and hope for the best.
    58         temp.append(SEPARATOR);
    59         temp.append(GSDL);
    60         }
    61         else {
    62         if(!enterlib.startsWith(SEPARATOR)) {
    63             temp.append(SEPARATOR);
    64         }
    65         temp.append(enterlib);
    66         }
    67         enterlib = null;
    68         url = temp.toString();
    69     }
    70     debug("Found Local Library Address: " + url);
    71     return url;
    72     }
    73 
    74     public void load() {
    7538    if(gsdlsite_cfg.exists()) {
    7639        debug("Load: " + gsdlsite_cfg.getAbsolutePath());
     
    10265    }
    10366
     67    public boolean exists() {
     68    return gsdlsite_cfg.exists();
     69    }
     70
     71    public String getLocalHostURL() {
     72    StringBuffer url = new StringBuffer(LOCAL_HOST);
     73    url.append(COLON);
     74    url.append((String)get(PORTNUMBER));
     75    String enterlib = (String)get(ENTERLIB);
     76    if(enterlib == null || enterlib.length() == 0) {
     77        // Use the default /gsdl and hope for the best.
     78        url.append(SEPARATOR);
     79        url.append(GSDL);
     80    }
     81    else {
     82        if(!enterlib.startsWith(SEPARATOR)) {
     83        url.append(SEPARATOR);
     84        }
     85        url.append(enterlib);
     86    }
     87    enterlib = null;
     88    debug("Found Local Library Address: " + url.toString());
     89    return url.toString();
     90    }
     91
     92    public String getSiteConfigFilename() {
     93    return SPECIFIC_CONFIG + glisite_cfg.getAbsolutePath();
     94    }
     95
     96    public String getURL() {
     97    // URL is made from url and portnumber
     98    String url = (String) get(URL);
     99    if(url != null) {
     100        StringBuffer temp = new StringBuffer(url);
     101        temp.append(COLON);
     102        temp.append((String)get(PORTNUMBER));
     103        String enterlib = (String)get(ENTERLIB);
     104        if(enterlib == null || enterlib.length() == 0) {
     105        // Use the default /gsdl and hope for the best.
     106        temp.append(SEPARATOR);
     107        temp.append(GSDL);
     108        }
     109        else {
     110        if(!enterlib.startsWith(SEPARATOR)) {
     111            temp.append(SEPARATOR);
     112        }
     113        temp.append(enterlib);
     114        }
     115        enterlib = null;
     116        url = temp.toString();
     117    }
     118    debug("Found Local Library Address: " + url);
     119    return url;
     120    }
     121
     122    public void load() {
     123    if(glisite_cfg.exists()) {
     124        debug("Load: " + glisite_cfg.getAbsolutePath());
     125        clear();
     126        try {
     127        BufferedReader in = new BufferedReader(new FileReader(glisite_cfg));
     128        String line = null;
     129        while((line = in.readLine()) != null) {
     130            String key = null;
     131            String value = null;
     132            int index = -1;
     133            if((index = line.indexOf("=")) != -1 && line.length() >= index + 1) {
     134            key = line.substring(0, index);
     135            value = line.substring(index + 1);
     136            }
     137            else {
     138            key = line;
     139            }
     140            put(key, value);
     141        }
     142        }
     143        catch (Exception error) {
     144        error.printStackTrace();
     145        }
     146    }
     147    else {
     148        debug("No GSDLsite.cfg file can be found!");
     149    }
     150    }
     151
    104152    /** Restore the autoenter value to its initial value, and remove url if present. */
    105153    public void restore() {
     
    137185
    138186    private void save() {
    139     debug("Save: " + gsdlsite_cfg.getAbsolutePath());
    140     //debug("Save: " + glisite_cfg.getAbsolutePath());
     187    //debug("Save: " + gsdlsite_cfg.getAbsolutePath());
     188    debug("Save: " + glisite_cfg.getAbsolutePath());
    141189    try {
    142         BufferedWriter out = new BufferedWriter(new FileWriter(gsdlsite_cfg, false));
    143         //BufferedWriter out = new BufferedWriter(new FileWriter(glisite_cfg, false));
     190        //BufferedWriter out = new BufferedWriter(new FileWriter(gsdlsite_cfg, false));
     191        BufferedWriter out = new BufferedWriter(new FileWriter(glisite_cfg, false));
    144192        for(Iterator keys = keySet().iterator(); keys.hasNext(); ) {
    145193        String key = (String) keys.next();
Note: See TracChangeset for help on using the changeset viewer.