Changeset 10193 for trunk/gsdl3


Ignore:
Timestamp:
2005-06-29T16:59:36+12:00 (19 years ago)
Author:
kjdon
Message:

check the field param before sending it to IVia - it may contain an invalid index name if no index is selcted on the query page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/IViaSearch.java

    r10093 r10193  
    3131
    3232    protected String ivia_server_url = null;
    33 
     33    protected ArrayList index_ids = null;
    3434    public IViaSearch()
    3535    {
     
    5656    does_multi_index_search = true;
    5757    this.default_index = ",kw,au,su,ti,de,fu,"; // all of them
     58    index_ids = new ArrayList();
     59    index_ids.add("kw");
     60    index_ids.add("au");   
     61    index_ids.add("su");   
     62    index_ids.add("ti");
     63    index_ids.add("de");
     64    index_ids.add("fu");
     65
    5866    return true;
    5967    }
     
    8896    // check for fields
    8997    String fields = (String) params.get(INDEX_PARAM);
    90     if (fields != null && !fields.equals("")) {
     98    fields = checkFieldParam(fields); // removes invalid fields
     99    if (!fields.equals("")) {
    91100        url_string += "&fields="+fields;
    92101    }
    93 
    94102    //check for hits per page
    95103    String hits_per_page = (String) params.get(HITS_PER_PAGE_PARAM);
     
    151159    }
    152160     
    153 
     161    protected String checkFieldParam(String fields) {
     162   
     163    if (fields == null) {
     164        // return the default
     165        return "";
     166    }
     167    StringBuffer new_fields = new StringBuffer();
     168    String [] ids = fields.split(",");
     169    for (int i=0; i<ids.length; i++) {
     170        if(index_ids.contains(ids[i])) {
     171        new_fields.append(ids[i]);
     172        new_fields.append(",");
     173        }
     174    }
     175    if (new_fields.length() == 0) {
     176        return "";
     177    }
     178    return new_fields.toString();
     179    }
    154180    /**
    155181       An IVia server has a fixed list of fields to search (I think) so we can hard code them here rather than reading them in from a config file
    156182    */
    157183    protected void getIndexData(ArrayList index_ids, ArrayList index_names,String lang){
    158     index_ids.add("kw");
    159     index_ids.add("au");   
    160     index_ids.add("su");   
    161     index_ids.add("ti");
    162     index_ids.add("de");
    163     index_ids.add("fu");
     184    index_ids.addAll(this.index_ids);
    164185    index_names.add(getTextString("param."+INDEX_PARAM+".kw", lang));
    165186    index_names.add(getTextString("param."+INDEX_PARAM+".au", lang));
Note: See TracChangeset for help on using the changeset viewer.