Changeset 9797 for branches/ant-install-branch
- Timestamp:
- 2005-05-03T09:49:20+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/service/IViaSearch.java
r9529 r9797 13 13 import java.util.HashMap; 14 14 import java.io.File; 15 import java.io.InputStream;16 15 import java.io.BufferedReader; 17 import java.io.InputStreamReader;18 import java.io.IOException;19 import java.net.HttpURLConnection;20 import java.net.URLConnection;21 import java.net.URL;22 16 import java.net.Authenticator; 23 import java.net.MalformedURLException;24 17 25 18 /** … … 108 101 String results_num = null; 109 102 String doc_ids = null; 103 BufferedReader reader = null; 110 104 try { 111 105 ///system.err.println("IViaSearch, sending "+url_string); 112 BufferedReader reader = makeConnection(url_string);106 reader = Misc.makeHttpConnection(url_string); 113 107 results_num = reader.readLine(); 114 108 doc_ids = reader.readLine(); 115 } catch (Exception e) { 116 System.err.println("IViaSearch.TextQuery Error: exception happened during query"); 117 e.printStackTrace(); 109 } catch (java.net.MalformedURLException e) { 110 GSXML.addError(this.doc, result, "Malformed URL: "+url_string); 111 return result; 112 } catch (java.io.IOException e) { 113 GSXML.addError(this.doc, result, "IOException during connection to "+url_string+": "+e.toString()); 118 114 return result; 119 115 } … … 123 119 } else { 124 120 System.err.println("IViaSearch.TextQuery Error: badly formatted results line: "+results_num); 121 GSXML.addError(this.doc, result, "Error: badly formatted result from IVia server: "+results_num); 125 122 return result; 126 123 } … … 129 126 } else { 130 127 System.err.println("IViaSearch.TextQuery Error: badly formatted docs line: "+doc_ids); 128 GSXML.addError(this.doc, result, "Error: badly formatted result from IVia server: "+doc_ids); 131 129 return result; 132 130 } … … 149 147 } 150 148 151 protected BufferedReader makeConnection(String url_string) {152 BufferedReader reader = null;153 try {154 URL url = new URL(url_string);155 HttpURLConnection connection = (HttpURLConnection)url.openConnection();156 InputStream input = connection.getInputStream();157 reader = new BufferedReader(new InputStreamReader(input));158 } catch (java.net.MalformedURLException e) {159 System.err.println("IViaSearch Error: Malformed URL: "+url_string);160 } catch (java.io.IOException e) {161 System.err.println("IViaSearch Error: An error occurred during IO to url "+url_string);162 }163 return reader;164 }165 149 166 150 /**
Note:
See TracChangeset
for help on using the changeset viewer.