Changeset 20294
- Timestamp:
- 2009-08-17T10:24:54+12:00 (15 years ago)
- Location:
- greenstone3/trunk/src/java/org/greenstone/gsdl3/service
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/FedoraSearch.java.tmp
r9886 r20294 44 44 import java.lang.Object; 45 45 46 import org.apache.log4j.*; 46 47 47 48 /** 48 49 * 49 * @author <a href="mailto:[email protected]">Chi-Yu Huang</a>50 * @version $Revision$51 50 * 52 51 */ … … 55 54 extends AbstractSearch { 56 55 56 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.FedoraSearch.class.getName()); 57 57 // the services on offer 58 58 // these strings must match what is found in the properties file … … 76 76 Element server_elem = (Element)GSXML.getChildByTagName(info, "fedoraServer"); 77 77 if (server_elem == null) { 78 System.err.println("FedoraSearch.configure error:no fedoraServer element found");78 logger.error("no fedoraServer element found"); 79 79 return false; 80 80 } 81 81 fedora_server_url = server_elem.getAttribute("url"); 82 System.err.println("Fedora Server:" + fedora_server_url);82 logger.info("Fedora Server:" + fedora_server_url); 83 83 84 84 if (fedora_server_url.equals("")) { 85 System.err.println("FedoraSearch.configure error:no url for the fedoraServer element");85 logger.error("no url for the fedoraServer element"); 86 86 return false; 87 87 } … … 113 113 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 114 114 if (param_list == null) { 115 System.err.println("FedoraSearch Error::TextQuery request had no paramList.");115 logger.error("TextQuery request had no paramList."); 116 116 return result; // Return the empty result 117 117 } … … 160 160 161 161 while (result_fedora != null) { 162 System.err.println("Search Result:" + result_fedora.getResultList().length);162 logger.info("Search Result:" + result_fedora.getResultList().length); 163 163 for (int i=0; i<result_fedora.getResultList().length; i++) { 164 164 ObjectFields o = result_fedora.getResultList()[i]; … … 202 202 } 203 203 } catch (Exception e) { 204 System.err.println("ERROR: " + e.getClass().getName()204 logger.error("ERROR: " + e.getClass().getName() 205 205 + ((e.getMessage()==null) ? "" : ": " + e.getMessage())); 206 206 } … … 210 210 211 211 // Add a metadata element specifying the number of matching documents 212 // System.err.println("FedoraSearch Number of Documents:" + matchNum);212 //logger.info("FedoraSearch Number of Documents:" + matchNum); 213 213 GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", ""+matchNum); 214 214 … … 222 222 // check if query contains any fields name (pid, label, fType....) 223 223 if (query_terms.matches("^("+ matchFields+").+")){ 224 System.err.println("Implementing Specific Query....");224 logger.info("Implementing Specific Query...."); 225 225 226 226 List conditions=fedora.server.search.Condition.getConditions(query_terms); … … 241 241 fedora_query.setConditions(cond); 242 242 } else { 243 System.err.println("Implementing Simple Query...");243 logger.info("Implementing Simple Query..."); 244 244 fedora_query.setTerms(query_terms); 245 245 } -
greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GoogleSearch.java.tmp
r11228 r20294 32 32 import java.lang.Object; 33 33 34 import org.apache.log4j.*; 34 35 35 36 /** … … 42 43 extends AbstractSearch { 43 44 45 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GoogleSearch.class.getName()); 46 44 47 //Parameters connect to Proxy Server 45 48 private boolean using_proxy = false; … … 62 65 return false; 63 66 } 64 System.err.println("Configuring GoogleSearch");67 logger.info("Configuring GoogleSearch"); 65 68 Element server_elem = (Element)GSXML.getChildByTagName(info, "googleServer"); 66 69 if (server_elem == null) { 67 System.err.println("GoogleSearch.configure error:no googleServer element found");70 logger.error("no googleServer element found"); 68 71 return false; 69 72 } … … 71 74 client_key = server_elem.getAttribute("key"); 72 75 if (client_key.equals("")) { 73 System.err.println("GoogleSearch.configure error:no client_key for the googleServer element");76 logger.error("no client_key for the googleServer element"); 74 77 return false; 75 78 } … … 86 89 proxy_port = Integer.parseInt(System.getProperty("http.proxyPort").trim()); 87 90 } catch (Exception e) { 88 System.err.println("GoogleSearch.configure error:couldn't get proxy port, defaulting to 80");91 logger.error("couldn't get proxy port, defaulting to 80"); 89 92 proxy_port = 80; 90 93 } … … 127 130 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 128 131 if (param_list == null) { 129 System.err.println("GoogleSearch.processTextQuery Error::TextQuery request had no paramList.");132 logger.error("TextQuery request had no paramList."); 130 133 return result; // Return the empty result 131 134 } … … 137 140 String query = (String) params.get(QUERY_PARAM); 138 141 if (query == null || query.equals("")) { 139 System.err.println("GoogleSearch.processTextQuery Error:TextQuery request had no query string.");142 logger.error("TextQuery request had no query string."); 140 143 return result; // Return the empty result 141 144 } … … 150 153 hits_per_page = Integer.parseInt(((String)params.get(HITS_PER_PAGE_PARAM)).trim()); 151 154 } catch (Exception e) { 152 System.err.println("GoogleSearch.processTextQuery error:couldn't get hits per page param, defaulting to 10");155 logger.error("couldn't get hits per page param, defaulting to 10"); 153 156 hits_per_page = 10; 154 157 } … … 158 161 start_page = Integer.parseInt(((String) params.get(START_PAGE_PARAM)).trim()); 159 162 } catch (Exception e) { 160 System.err.println("GoogleSearch.processTextQuery error:couldn't get start page param, defaulting to 1");163 logger.error("couldn't get start page param, defaulting to 1"); 161 164 start_page = 1; 162 165 } … … 182 185 google_result = search.doSearch(); 183 186 } catch (GoogleSearchFault ex) { 184 System.err.println("GoogleSearch.processTextQuery error:the call to the Google Web APIs failed:" + ex.toString());187 logger.error("the call to the Google Web APIs failed:" + ex.toString()); 185 188 // add the error to the result 186 189 return result;
Note:
See TracChangeset
for help on using the changeset viewer.