Changeset 20294

Show
Ignore:
Timestamp:
17.08.2009 10:24:54 (10 years ago)
Author:
kjdon
Message:

changed System.err to logger.error/info

Location:
greenstone3/trunk/src/java/org/greenstone/gsdl3/service
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/FedoraSearch.java.tmp

    r9886 r20294  
    4444import java.lang.Object; 
    4545 
     46import org.apache.log4j.*; 
    4647 
    4748/** 
    4849 * 
    49  * @author <a href="mailto:chi@cs.waikato.ac.nz">Chi-Yu Huang</a> 
    50  * @version $Revision$ 
    5150 * 
    5251 */ 
     
    5554    extends AbstractSearch { 
    5655     
     56     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.FedoraSearch.class.getName()); 
    5757    // the services on offer 
    5858    // these strings must match what is found in the properties file 
     
    7676    Element server_elem = (Element)GSXML.getChildByTagName(info, "fedoraServer"); 
    7777    if (server_elem == null) { 
    78         System.err.println("FedoraSearch.configure error: no fedoraServer element found"); 
     78        logger.error("no fedoraServer element found"); 
    7979        return false; 
    8080    } 
    8181    fedora_server_url = server_elem.getAttribute("url"); 
    82     System.err.println("Fedora Server:" + fedora_server_url); 
     82    logger.info("Fedora Server:" + fedora_server_url); 
    8383 
    8484    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"); 
    8686        return false; 
    8787    } 
     
    113113    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    114114    if (param_list == null) { 
    115         System.err.println("FedoraSearch Error:: TextQuery request had no paramList."); 
     115        logger.error("TextQuery request had no paramList."); 
    116116        return result;  // Return the empty result 
    117117    } 
     
    160160         
    161161        while (result_fedora != null) { 
    162         System.err.println("Search Result:" + result_fedora.getResultList().length); 
     162        logger.info("Search Result:" + result_fedora.getResultList().length); 
    163163        for (int i=0; i<result_fedora.getResultList().length; i++) { 
    164164            ObjectFields o = result_fedora.getResultList()[i]; 
     
    202202        } 
    203203    } catch (Exception e) { 
    204         System.err.println("ERROR: " + e.getClass().getName() 
     204        logger.error("ERROR: " + e.getClass().getName() 
    205205                   + ((e.getMessage()==null) ? "" : ": " + e.getMessage())); 
    206206    } 
     
    210210     
    211211    // 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); 
    213213    GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", ""+matchNum); 
    214214     
     
    222222        // check if query contains any fields name (pid, label, fType....) 
    223223        if (query_terms.matches("^("+ matchFields+").+")){ 
    224         System.err.println("Implementing Specific Query...."); 
     224        logger.info("Implementing Specific Query...."); 
    225225 
    226226        List conditions=fedora.server.search.Condition.getConditions(query_terms); 
     
    241241        fedora_query.setConditions(cond); 
    242242        } else { 
    243         System.err.println("Implementing Simple Query..."); 
     243        logger.info("Implementing Simple Query..."); 
    244244        fedora_query.setTerms(query_terms); 
    245245        } 
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/service/GoogleSearch.java.tmp

    r11228 r20294  
    3232import java.lang.Object; 
    3333 
     34import org.apache.log4j.*; 
    3435 
    3536/** 
     
    4243    extends AbstractSearch { 
    4344     
     45     static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GoogleSearch.class.getName()); 
     46      
    4447    //Parameters connect to Proxy Server 
    4548    private boolean using_proxy = false; 
     
    6265        return false; 
    6366    } 
    64     System.err.println("Configuring GoogleSearch"); 
     67    logger.info("Configuring GoogleSearch"); 
    6568    Element server_elem = (Element)GSXML.getChildByTagName(info, "googleServer"); 
    6669    if (server_elem == null) { 
    67         System.err.println("GoogleSearch.configure error: no googleServer element found"); 
     70        logger.error("no googleServer element found"); 
    6871        return false; 
    6972    } 
     
    7174    client_key = server_elem.getAttribute("key"); 
    7275    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"); 
    7477        return false; 
    7578    } 
     
    8689        proxy_port = Integer.parseInt(System.getProperty("http.proxyPort").trim()); 
    8790        } 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"); 
    8992        proxy_port = 80; 
    9093        } 
     
    127130    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 
    128131    if (param_list == null) { 
    129         System.err.println("GoogleSearch.processTextQuery Error:: TextQuery request had no paramList."); 
     132        logger.error("TextQuery request had no paramList."); 
    130133        return result;  // Return the empty result 
    131134    } 
     
    137140    String query = (String) params.get(QUERY_PARAM); 
    138141    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."); 
    140143        return result;  // Return the empty result 
    141144    } 
     
    150153        hits_per_page = Integer.parseInt(((String)params.get(HITS_PER_PAGE_PARAM)).trim()); 
    151154    } 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"); 
    153156        hits_per_page = 10; 
    154157    } 
     
    158161        start_page = Integer.parseInt(((String) params.get(START_PAGE_PARAM)).trim()); 
    159162    } 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"); 
    161164        start_page = 1; 
    162165    } 
     
    182185        google_result = search.doSearch(); 
    183186        } 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()); 
    185188        // add the error to the result 
    186189        return result;