Ignore:
Timestamp:
2005-05-16T11:02:50+12:00 (19 years ago)
Author:
kjdon
Message:

merged from branch ant-install-branch: merge 1

File:
1 edited

Legend:

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

    r9273 r9874  
    22
    33// Greenstone classes
    4 import org.greenstone.gdbm.*;
    54import org.greenstone.gsdl3.util.*;
    65
     
    1413import java.util.HashMap;
    1514import java.io.File;
    16 import java.io.InputStream;
    1715import java.io.BufferedReader;
    18 import java.io.InputStreamReader;
    19 import java.io.IOException;
    20 import java.net.HttpURLConnection;
    21 import java.net.URLConnection;
    22 import java.net.URL;
    2316import java.net.Authenticator;
    24 import java.net.MalformedURLException;
    2517
    2618/**
    2719 *
    2820 * @author <a href="mailto:[email protected]">Katherine Don</a>
    29  * @version $Revision$
    30  * Modified by <a href="mailto:[email protected]">Chi-Yu Huang</a>
     21 * @author <a href="mailto:[email protected]">Chi-Yu Huang</a>
    3122 */
    3223
     
    109100    String results_num = null;
    110101    String doc_ids = null;
     102    BufferedReader reader = null;
    111103    try {
    112104        ///system.err.println("IViaSearch, sending "+url_string);
    113         BufferedReader reader = makeConnection(url_string);
     105        reader = Misc.makeHttpConnection(url_string);
    114106        results_num = reader.readLine();
    115107        doc_ids = reader.readLine();
    116     } catch (Exception e) {
    117         System.err.println("IViaSearch.TextQuery Error: exception happened during query");
    118         e.printStackTrace();
     108    } catch (java.net.MalformedURLException e) {
     109        GSXML.addError(this.doc, result, "Malformed URL: "+url_string);
     110        return result;
     111    } catch (java.io.IOException e) {
     112        GSXML.addError(this.doc, result, "IOException during connection to "+url_string+": "+e.toString());
    119113        return result;
    120114    }
     
    124118    } else {
    125119        System.err.println("IViaSearch.TextQuery Error: badly formatted results line: "+results_num);
     120        GSXML.addError(this.doc, result, "Error: badly formatted result from IVia server: "+results_num);
    126121        return result;
    127122    }
     
    130125    } else {
    131126        System.err.println("IViaSearch.TextQuery Error: badly formatted docs line: "+doc_ids);
     127        GSXML.addError(this.doc, result, "Error: badly formatted result from IVia server: "+doc_ids);
    132128        return result;
    133129    }
     
    150146    }
    151147     
    152     protected BufferedReader makeConnection(String url_string) {
    153     BufferedReader reader = null;
    154     try {
    155         URL url = new URL(url_string);
    156         HttpURLConnection connection = (HttpURLConnection)url.openConnection();
    157         InputStream input = connection.getInputStream();
    158         reader = new BufferedReader(new InputStreamReader(input)); 
    159     } catch (java.net.MalformedURLException e) {
    160         System.err.println("IViaSearch Error: Malformed URL: "+url_string);
    161     } catch (java.io.IOException e) {
    162         System.err.println("IViaSearch Error: An error occurred during IO to url "+url_string);
    163     }
    164     return reader;
    165     }
    166148
    167149    /**
Note: See TracChangeset for help on using the changeset viewer.