Changeset 13124


Ignore:
Timestamp:
2006-10-17T15:52:42+13:00 (18 years ago)
Author:
shaoqun
Message:

added the code to use log4j and replace system.out or system.err to logger.info or logger.error respectively. The commented out output has been replaced with logger.debug. The log file is in web/logs/greenstone.log

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/Action.java

    r9874 r13124  
    1616import java.util.Iterator;
    1717
     18import org.apache.log4j.*;
     19
    1820/** base class for Actions */
    1921abstract public class Action {
     
    2931     doesn't care about that */
    3032    protected ModuleInterface mr=null;
     33
     34    static Category logger = Category.getInstance(org.greenstone.gsdl3.action.Action.class.getName());
    3135
    3236    public Action() {
     
    5458    Document message_doc = this.converter.getDOM(xml_in);
    5559    if (message_doc == null) {
    56         System.err.println("Action.process(String) Error: Couldn't parse request");
    57         System.err.println(xml_in);
     60        logger.error("Couldn't parse request");
     61        logger.error(xml_in);
    5862        return null;
    5963    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/AppletAction.java

    r6300 r13124  
    1212import java.io.File;
    1313
     14import org.apache.log4j.*;
     15
    1416/** action class for handling applets */
    1517public class AppletAction extends Action {
    16    
     18
     19      static Category logger = Category.getInstance(org.greenstone.gsdl3.action.AppletAction.class.getName());   
    1720
    1821    public Element process (Element message) {
     
    3033    String request_type = (String)params.get(GSParams.REQUEST_TYPE);
    3134    if (!request_type.equals("d")&&!request_type.equals("r")) {
    32         System.err.println("AppletAction Error: the rt arg should be either d or r, instead it was "+request_type+"!");
     35        logger.error("AppletAction Error: the rt arg should be either d or r, instead it was "+request_type+"!");
    3336        return result;
    3437    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/BrowseAction.java

    r6695 r13124  
    1414import java.io.File;
    1515
     16import org.apache.log4j.*;
     17
    1618//NOTE: this class not used at present!!!!!
    1719/** action for classifier browsing */
    1820public class BrowseAction extends Action {
    19    
     21
     22    static Category logger = Category.getInstance(org.greenstone.gsdl3.action.BrowseAction.class.getName());
     23
    2024    public static final String CLASSIFIER_ARG = "cl";
    2125    public static final String SIBLING_ARG = "sib";
     
    4650    String collection = (String)params.get(GSParams.COLLECTION);
    4751    if (collection == null || collection.equals("")) {
    48         System.err.println("BrowseAction Error:classifierBrowse, need to specify a collection!");
     52        logger.error("classifierBrowse, need to specify a collection!");
    4953        return page_response;
    5054       
     
    123127    }
    124128   
    125     System.out.println("extracted meta names, "+metadata_names.toString());
     129    logger.info("extracted meta names, "+metadata_names.toString());
    126130    // get the browse structure for the selected node
    127131    Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
     
    166170                                path);
    167171    if (cl_structure ==null) {
    168         System.err.println("BrowseAction: classifier structure request returned no structure");
     172        logger.error("classifier structure request returned no structure");
    169173        return page_response;
    170174    }   
     
    281285       
    282286
    283     ///ystem.out.println("(BrowseAction) Page:\n" + this.converter.getPrettyString(page_response));
     287    logger.debug("(BrowseAction) Page:\n" + this.converter.getPrettyString(page_response));
    284288    return page_response;
    285289    }
    286290
    287291    protected Element unknownBrowse(Element page, Element request, String browse_type) {
    288     System.err.println("BrowseAction Error: unknown browse subtype: "+browse_type);
     292    logger.error("unknown browse subtype: "+browse_type);
    289293    return null;
    290294    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/DocumentAction.java

    r11276 r13124  
    3636import java.io.File;
    3737
     38import org.apache.log4j.*;
    3839
    3940/** Action class for retrieving Documents  via the message router
    4041 */
    4142public class DocumentAction extends Action {
    42  
     43
     44   static Category logger = Category.getInstance(org.greenstone.gsdl3.action.DocumentAction.class.getName());
     45
    4346    // this is used to specify that the sibling nodes of a selected one should be obtained
    4447    public static final String SIBLING_ARG = "sib";
     
    8689    String document_name = (String) params.get(GSParams.DOCUMENT);
    8790    if (document_name == null || document_name.equals("")) {
    88         System.err.println("DocumentAction Error: no document specified!");
     91        logger.error("no document specified!");
    8992        return result;
    9093    }
     
    352355        dc_request.appendChild(basic_doc_list);
    353356    }
    354     ///ystem.err.println("request = "+converter.getString(dc_message));
     357    logger.debug("request = "+converter.getString(dc_message));
    355358    Element dc_response_message = (Element) this.mr.process(dc_message);
    356359    if (processErrorElements(dc_response_message, page_response)) {
     
    453456    }
    454457    }
    455     ///ystem.out.println("(DocumentAction) Page:\n" + this.converter.getPrettyString(result));
     458    logger.debug("(DocumentAction) Page:\n" + this.converter.getPrettyString(result));
    456459    return result;
    457460    }
     
    499502    Element format_elem = (Element)GSXML.getChildByTagName(format_resp, GSXML.FORMAT_ELEM);
    500503    if (format_elem != null) {
    501         ///ystem.out.println("doc action found a format statement");
     504        logger.debug("doc action found a format statement");
    502505        // set teh format type
    503506        format_elem.setAttribute(GSXML.TYPE_ATT, "display"); 
     
    552555        String service_name = (String)previous_params.get(GSParams.SERVICE);
    553556    if (service_name == null || !service_name.endsWith("Query")) { // hack for now - we only do highlighting if we were in a query last - ie not if we were in a browse thingy
    554         System.err.println("DocumentAction: invalid service, not doing highlighting");
     557        logger.error("invalid service, not doing highlighting");
    555558        return dc_response_doc_content;
    556559    }
     
    578581    if (query_term_list_element == null) {
    579582        // no term info
    580         System.err.println("DocumentAction: Warning: No query term information.\n");
     583        logger.error("No query term information.\n");
    581584        return dc_response_doc_content;
    582585    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java

    r9900 r13124  
    1414import java.io.File;
    1515
     16import org.apache.log4j.*;
     17
    1618/** action for GS2 style classifier browsing */
    1719public class GS2BrowseAction extends Action {
    1820   
    1921    public static final String CLASSIFIER_ARG = "cl";
    20    
     22
     23    static Category logger = Category.getInstance(org.greenstone.gsdl3.action.GS2BrowseAction.class.getName());   
     24
    2125    /** process the request */
    2226    public Element process (Element message) {
     
    4448    String collection = (String)params.get(GSParams.COLLECTION);
    4549    if (collection == null || collection.equals("")) {
    46         System.err.println("GS2BrowseAction Error:classifierBrowse, need to specify a collection!");
     50        logger.error("classifierBrowse, need to specify a collection!");
    4751        return page_response;
    4852       
     
    175179                                path);
    176180    if (cl_structure ==null) {
    177         System.err.println("GS2BrowseAction: classifier structure request returned no structure");
     181        logger.error("classifier structure request returned no structure");
    178182        return page_response;
    179183    }   
     
    302306       
    303307
    304     ///ystem.out.println("(GS2BrowseAction) Page:\n" + this.converter.getPrettyString(page_response));
     308    logger.debug("(GS2BrowseAction) Page:\n" + this.converter.getPrettyString(page_response));
    305309    return page_response;
    306310    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/GeneralAction.java

    r8800 r13124  
    1313import java.util.Iterator;
    1414import java.io.File;
     15
    1516
    1617public class GeneralAction extends Action {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java

    r8677 r13124  
    1717import java.io.File;
    1818
     19import org.apache.log4j.*;
     20
    1921/** action class for queries
    2022 * this is used when querying isn't collection specific, but it occurs across all collections in the site. The service description is assumed to be known by the xslt so we dont ask for it. we just pass all the service params to the TextQuery service of all the collections */
    2123public class NoCollQueryAction extends Action {
    22    
     24   
     25    static Category logger = Category.getInstance(org.greenstone.gsdl3.action.NoCollQueryAction.class.getName());
    2326    /** process - processes a request.
    2427     */
     
    7073   
    7174    if (query_coll_list == null || query_coll_list.equals("")) {
    72         System.err.println("NoCollQueryAction Error: no collections were specified!");
     75        logger.error("no collections were specified!");
    7376        Element coll_list = getCollectionList(lang, uid);
    7477        page_response.appendChild(this.doc.importNode(coll_list, true));
     
    167170    Element coll_list_response = (Element)this.mr.process(coll_list_message);
    168171    if (coll_list_response==null) {
    169         System.err.println("NoCollQueryAction Error: couldn't query the message router!");
     172        logger.error("couldn't query the message router!");
    170173        return null;
    171174    }
     
    193196    // check that have same number of responses as collections
    194197    if (colls.getLength() != coll_responses.getLength()) {
    195         System.err.println("NoCollQueryAction Error: didn't get a response for each collection - somethings gone wrong!");
     198        logger.error("didn't get a response for each collection - somethings gone wrong!");
    196199        // for now, dont use the metadata
    197200    } else {
     
    203206            GSXML.mergeElements(c1, (Element)GSXML.getChildByTagName(c2, GSXML.COLLECTION_ELEM));
    204207        } else {
    205             System.err.println("NoCollQueryAction Error: response does not correspond to request!");
     208            logger.error("response does not correspond to request!");
    206209        }
    207210       
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r11230 r13124  
    1212import java.io.File;
    1313
     14import org.apache.log4j.*;
     15
    1416public class PageAction extends Action {
     17   
     18     static Category logger = Category.getInstance(org.greenstone.gsdl3.action.PageAction.class.getName());
    1519
    1620    public static final String HOME_PAGE = "home";
     
    3539    } else { // unknown page
    3640       
    37         System.err.println("PageAction Error: unknown page specified!");
     41        logger.error("unknown page specified!");
    3842        response =  unknownPage(request);
    3943    }
    4044   
    4145    result.appendChild(this.doc.importNode(response, true));
    42     ///ystem.out.println("page action result: "+this.converter.getPrettyString(result));
     46    logger.debug("page action result: "+this.converter.getPrettyString(result));
    4347    return result;
    4448    }
     
    5559    Element info_response_message = (Element)this.mr.process(info_message);
    5660    if (info_response_message==null) {
    57         System.err.println("PageAction Error: couldn't query the message router!");
     61        logger.error(" couldn't query the message router!");
    5862        return null;
    5963    }
    6064    Element info_response = (Element)GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM);
    6165    if (info_response==null) {
    62         System.err.println("PageAction Error: couldn't query the message router!");
     66        logger.error("couldn't query the message router!");
    6367        return null;
    6468    }
     
    108112    String coll_name = (String)params.get(GSParams.COLLECTION);
    109113    if (coll_name == null || coll_name.equals("")) {
    110         System.err.println("PageAction Error: about page requested with no collection or cluster specified!");
     114        logger.error("about page requested with no collection or cluster specified!");
    111115        // return an empty response
    112116        return this.doc.createElement(GSXML.RESPONSE_ELEM);
     
    194198    // check that have same number of responses as requests
    195199    if (items.getLength() != responses.getLength()) {
    196         System.err.println("PageAction Error: didn't get a response for each request - somethings gone wrong!");
     200        logger.error("didn't get a response for each request - somethings gone wrong!");
    197201        return false;
    198202    }
     
    205209        GSXML.mergeElements(c1, c2);
    206210        } else {
    207         System.err.println("PageAction Error: response does not correspond to request!");
     211        logger.error(" response does not correspond to request!");
    208212        }
    209213       
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/QueryAction.java

    r11013 r13124  
    1717import java.io.File;
    1818
     19import org.apache.log4j.*;
     20
    1921/** action class for queries */
    2022public class QueryAction extends Action {
     23
     24
     25     static Category logger = Category.getInstance(org.greenstone.gsdl3.action.QueryAction.class.getName());
    2126   
    2227    /** process - processes a request.
     
    116121    Element query_result_metadata_list = (Element) GSXML.getChildByTagName(query_response, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    117122    if (query_result_metadata_list == null) {
    118         System.err.println("QueryAction: Warning: No query result metadata.\n");
     123        logger.error("No query result metadata.\n");
    119124    } else { // add it into the page response
    120125        page_response.appendChild(this.doc.importNode(query_result_metadata_list, true));
     
    123128    Element query_term_info_list = (Element) GSXML.getChildByTagName(query_response, GSXML.TERM_ELEM+GSXML.LIST_MODIFIER);
    124129    if (query_term_info_list == null) {
    125         System.err.println("QueryAction: Warning: No query term information.\n");
     130        logger.error("No query term information.\n");
    126131    } else { // add it into the page response
    127132        page_response.appendChild(this.doc.importNode(query_term_info_list, true));
     
    140145    NodeList doc_metadata = document_list.getElementsByTagName(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    141146    if (doc_metadata.getLength()>0) {
    142         System.err.println("have already found metadata!");
     147        logger.error("have already found metadata!");
    143148        // append the doc list to the result
    144149        page_response.appendChild(this.doc.importNode(document_list, true));
     
    193198    }
    194199   
    195     ///ystem.out.println("Query page:\n" + this.converter.getPrettyString(page_response));
     200    logger.debug("Query page:\n" + this.converter.getPrettyString(page_response));
    196201    return page_response;
    197202    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/action/SystemAction.java

    r6300 r13124  
    1313import java.util.HashMap;
    1414
     15import org.apache.log4j.*;
     16
    1517public class SystemAction extends Action {
    1618   
     19      static Category logger = Category.getInstance(org.greenstone.gsdl3.action.SystemAction.class.getName());
     20
    1721    /** process a request */
    1822    public Element process (Element message) {
     
    6569        // create the default response
    6670        // for now just have an error
    67         System.err.println("SystemAction error: bad subaction type");
     71        logger.error("bad subaction type");
    6872        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    6973        result.appendChild(page_response);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r9874 r13124  
    1414import java.util.Enumeration;
    1515
     16import org.apache.log4j.*;
     17
    1618/** The default greenstone receptionist - needs some extra info for each page
    1719 */
    1820public class DefaultReceptionist extends TransformingReceptionist {
     21
     22     static Category logger = Category.getInstance(org.greenstone.gsdl3.core.DefaultReceptionist.class.getName());
    1923   
    2024    protected void addExtraInfo(Element page) {
     
    2731    String action = page_request.getAttribute(GSXML.ACTION_ATT);
    2832    if (action.equals("s")) {
    29         System.err.println("HACK: don't ask for coll info if system action");
     33        logger.error("HACK: don't ask for coll info if system action");
    3034        return;
    3135    }
    32     ///ystem.out.println("add extra info, page request="+this.converter.getString(page_request));
     36    logger.debug("add extra info, page request="+this.converter.getString(page_request));
    3337    // is a collection defined?
    3438    Element param_list = (Element)GSXML.getChildByTagName(page_request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    3539    if (param_list==null) { // must be the original home page
    36         ///ystem.out.println("DefaultReceptionist: no param list, assuming home page");
     40        logger.debug(" no param list, assuming home page");
    3741        return;
    3842    }
    3943    Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSParams.COLLECTION);
    4044    if (coll_param == null) {
    41         ///ystem.out.println("DefaultReceptionist: coll param is null, returning");
     45        logger.debug(" coll param is null, returning");
    4246        return;
    4347    }
     
    7579       
    7680        if (coll_description == null) {
    77         System.err.println("DefaultReceptionist: no collection description, returning");
     81        logger.error(" no collection description, returning");
    7882        return;
    7983        }
     
    8993    Element service_list = (Element)GSXML.getChildByTagName(coll_description, GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER);
    9094    if (service_list == null) {
    91         System.err.println("DefaultReceptionist: no service list, returning");
     95        logger.error(" no service list, returning");
    9296        // something weird has gone wrong
    9397        return;
     
    96100    NodeList services = service_list.getElementsByTagName(GSXML.SERVICE_ELEM);
    97101    if (services.getLength()==0) {
    98         System.err.println("DefaultReceoptionist: no services found for colllection/cluster "+ coll_name);
     102        logger.error("DefaultReceoptionist: no services found for colllection/cluster "+ coll_name);
    99103        return;
    100104    }
     
    118122
    119123    // if get here, we need to get the service descriptions
    120     ///ystem.out.println("getting services description");
     124    logger.debug("getting services description");
    121125       
    122126    // we will send all the requests in a single message
     
    139143    // check that have same number of responses as collections
    140144    if (services.getLength() != service_responses.getLength()) {
    141         System.err.println("DefaultReceptionist Error: didn't get a response for each service - somethings gone wrong!");
     145        logger.error(" didn't get a response for each service - somethings gone wrong!");
    142146        // for now, dont use the metadata
    143147    } else {
     
    149153            GSXML.mergeElements(c1, c2);
    150154        } else {
    151             System.err.println("DefaultReceptionist Error: response does not correspond to request!");
     155            logger.error(" response does not correspond to request!");
    152156        }
    153157       
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r11269 r13124  
    4242import java.util.Properties;
    4343
     44import org.apache.log4j.*;
     45
    4446/**
    4547 * The hub of a Greenstone system.
     
    6264public class MessageRouter implements  ModuleInterface {
    6365
     66     static Category logger = Category.getInstance(org.greenstone.gsdl3.core.MessageRouter.class.getName());
     67
    6468    /** the (directory) name of the site */
    6569    protected String site_name = null;
     
    127131    public boolean configure() {
    128132
    129     System.out.println("MessageRouter:configuring site");
     133    logger.info("configuring site");
    130134
    131135    if (this.site_name==null) {
    132         System.err.println("MessageRouter: You must set site_name before calling configure");
     136        logger.error(" You must set site_name before calling configure");
    133137        return false;
    134138    }
     
    158162           
    159163        } catch (Exception e) {
    160             System.err.println("MessageRouter Error: couldn't set up an authenticator the proxy");
     164            logger.error("MessageRouter Error: couldn't set up an authenticator the proxy");
    161165           
    162166        }
     
    168172
    169173    if (!configFile.exists() ) {
    170         System.err.println("MessageRouter: site config file: "+configFile.getPath()+" not found!");
     174        logger.error(" site config file: "+configFile.getPath()+" not found!");
    171175        return false;
    172176    }
     
    174178    Document config_doc = this.converter.getDOM(configFile);
    175179    if (config_doc == null) {
    176 System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     180logger.error(" couldn't parse site config file: "+configFile.getPath());
    177181        return false;
    178182    }
     
    226230     */
    227231    public Element process(Element message) {
    228 
    229     ///ystem.out.println("MR received request");
    230     ///ystem.out.println(this.converter.getString(message));
     232     
     233    logger.debug("MR received request");
     234    logger.debug(this.converter.getString(message));
    231235    // check that its a correct message tag
    232236    if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) {
    233         System.err.println("MessageRouter: Invalid message. GSDL message should start with <"+GSXML.MESSAGE_ELEM+">, instead it starts with:"+message.getTagName()+".");
     237        logger.error(" Invalid message. GSDL message should start with <"+GSXML.MESSAGE_ELEM+">, instead it starts with:"+message.getTagName()+".");
    234238        return null;
    235239    }
     
    254258        Element req = (Element)requests.item(i);
    255259        if (req == null) {
    256         System.err.println("request "+i+" is null");
     260        logger.error("request "+i+" is null");
    257261        continue;
    258262        }
     
    294298                response.setAttribute(GSXML.FROM_ATT, this_mod);
    295299                mainResult.appendChild(response);
    296                 System.err.println("MessageRouter Error: request had null result!");
     300                logger.error("MessageRouter Error: request had null result!");
    297301            }
    298302           
    299303            } else {   
    300             System.err.println("MessageRouter Error: request has illegal module name in:\n"+this.converter.getString(req));
     304            logger.error("MessageRouter Error: request has illegal module name in:\n"+this.converter.getString(req));
    301305            }
    302306        }
     
    305309    } // for each request
    306310   
    307     ///ystem.out.println("MR returned response");
    308     ///ystem.out.println(this.converter.getString(mainResult));
     311    logger.debug("MR returned response");
     312    logger.debug(this.converter.getString(mainResult));
    309313
    310314    return mainResult;
     
    322326
    323327    // load up the individual services
    324     System.out.println("loading service modules...");
     328    logger.info("loading service modules...");
    325329   
    326330    if (service_rack_list == null) {
    327         System.out.println("... none to be loaded");
     331        logger.info("... none to be loaded");
    328332        return true;
    329333    }
     
    331335    NodeList service_racks = service_rack_list.getElementsByTagName(GSXML.SERVICE_CLASS_ELEM);
    332336    if (service_racks.getLength()==0) {
    333         System.out.println("... none to be loaded");
     337        logger.info("... none to be loaded");
    334338        return true;
    335339    }
     
    342346        Element n = (Element)service_racks.item(i);
    343347        String service_name = n.getAttribute(GSXML.NAME_ATT);
    344         System.out.println("..."+service_name);
     348        logger.info("..."+service_name);
    345349        try {
    346350        ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+service_name).newInstance();
     
    355359        NodeList services = service_response.getElementsByTagName(GSXML.SERVICE_ELEM);
    356360        if (services.getLength()==0) {
    357             System.err.println("MessageRouter configure error: serviceRack "+service_name+" has no services!");
     361            logger.error("MessageRouter configure error: serviceRack "+service_name+" has no services!");
    358362        } else {
    359363            for (int j=0; j<services.getLength();j++) {
     
    366370        }
    367371        } catch (Exception e ) {
    368         System.err.println("MessageRouter configure exception:  in ServiceRack class specification:  "+ e.getMessage());
     372        logger.error("MessageRouter configure exception:  in ServiceRack class specification:  "+ e.getMessage());
    369373        e.printStackTrace();
    370374        }
     
    377381    this.cluster_list = this.doc.createElement(GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);
    378382    // load up the service clusters
    379     System.out.println("loading service clusters ...");
     383    logger.info("loading service clusters ...");
    380384    if (config_cluster_list == null) {
    381         System.out.println("... none to be loaded");
     385        logger.info("... none to be loaded");
    382386        return true;
    383387    }
    384388    NodeList service_clusters = config_cluster_list.getElementsByTagName(GSXML.CLUSTER_ELEM);
    385389    if (service_clusters.getLength()==0) {
    386         System.out.println("... none to be loaded");
     390        logger.info("... none to be loaded");
    387391        return true;
    388392    }
     
    391395        Element cluster = (Element)service_clusters.item(i);
    392396        String name = cluster.getAttribute(GSXML.NAME_ATT);
    393         System.out.println("..."+name);
     397        logger.info("..."+name);
    394398        ServiceCluster sc = new ServiceCluster();
    395399        sc.setSiteHome(this.site_home);
     
    415419    File collectDir = new File(GSFile.collectDir(this.site_home));
    416420    if (collectDir.exists()) {
    417         System.out.println("Reading thru directory "+collectDir.getPath()+" to find collections.");
     421        logger.info("Reading thru directory "+collectDir.getPath()+" to find collections.");
    418422        File[] contents = collectDir.listFiles();
    419423        for (int i=0; i<contents.length;i++) {
     
    434438    this.site_list = this.doc.createElement(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
    435439    // load up the sites
    436     System.out.println("loading external sites...");
     440    logger.info("loading external sites...");
    437441    if (config_site_list ==null ) {
    438         System.out.println("...none found");
     442        logger.info("...none found");
    439443        return true;
    440444    }
     
    442446    NodeList sites = config_site_list.getElementsByTagName(GSXML.SITE_ELEM);
    443447    if (sites.getLength()==0) {
    444         System.out.println("...none found");
     448        logger.info("...none found");
    445449        return true;
    446450    }
     
    475479        // have to be added later
    476480        if (!getRemoteSiteInfo(comm, name)) {
    477             System.err.println("MessageRouter: couldn't get info from site "+name);
     481            logger.error(" couldn't get info from site "+name);
    478482        }
    479483        } else {
    480         System.err.println("MessageRouter: couldn't configure soap site:"+name);
     484        logger.error(" couldn't configure soap site:"+name);
    481485        return false;
    482486        }
    483487       
    484488    } else {
    485         System.err.print("MessageRouter: cant talk to server of type:"+type + ", so not making a connection to "+name);
     489        System.err.print(" cant talk to server of type:"+type + ", so not making a connection to "+name);
    486490        return false;
    487491    }
     
    497501    protected boolean getRemoteSiteInfo(Communicator comm, String site_name) {
    498502   
    499     System.out.println("MessageRouter: getting info from site:"+site_name);
     503    logger.info(" getting info from site:"+site_name);
    500504
    501505    Element info_request = this.doc.createElement(GSXML.MESSAGE_ELEM);
     
    630634                File configFile = new File(GSFile.siteConfigFile(this.site_home));
    631635                if (!configFile.exists() ) {
    632                     System.err.println("MessageRouter: site config file: "+configFile.getPath()+" not found!");
     636                    logger.error(" site config file: "+configFile.getPath()+" not found!");
    633637                    continue;
    634638                }
    635639                Document site_config_doc = this.converter.getDOM(configFile);
    636640                if (site_config_doc == null) {
    637                     System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     641                    logger.error(" couldn't parse site config file: "+configFile.getPath());
    638642                    continue;
    639643                }
     
    696700   
    697701    // if get here something has gone wrong
    698     System.err.println("MessageRouter: cant process request:");
    699     System.err.println(this.converter.getString(req));
     702    logger.error(" cant process request:");
     703    logger.error(this.converter.getString(req));
    700704    return null;
    701705       
     
    708712    NodeList commands = request.getElementsByTagName("command");
    709713    if (commands == null) {
    710         System.err.println("no commands, "+converter.getPrettyString(request));
     714        logger.error("no commands, "+converter.getPrettyString(request));
    711715        return response;
    712716    }
     
    769773    protected boolean activateCollectionByName(String col_name) {
    770774
    771     System.out.println("MessageRouter:Activating collection: "+col_name+".");
     775    logger.info("Activating collection: "+col_name+".");
    772776       
    773777    // now we need to look for the etc/collectionInit.xml file, and see what sort of Collection to load
     
    784788                c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance();
    785789            } catch (Exception e) {
    786                 System.out.println("MessageRouter: couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
     790                logger.info(" couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection");
    787791            }
    788792            }
     
    809813        return true;
    810814    } else {
    811         System.err.println("MessageRouter:Couldn't configure collection: "+
     815        logger.error("Couldn't configure collection: "+
    812816                   col_name+".");
    813817        return false;
     
    817821   
    818822    protected boolean activateSiteByName(String site_name) {
    819     System.out.println("MessageRouter:Activating site: "+site_name+".");
     823    logger.info("Activating site: "+site_name+".");
    820824   
    821825    // just in case this is a reactivation, deactivate this site first
     
    824828
    825829    if (!configFile.exists() ) {
    826         System.err.println("MessageRouter: site config file: "+configFile.getPath()+" not found!");
     830        logger.error(" site config file: "+configFile.getPath()+" not found!");
    827831        return false;
    828832    }
    829833    Document config_doc = this.converter.getDOM(configFile);
    830834    if (config_doc == null) {
    831         System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath());
     835        logger.error(" couldn't parse site config file: "+configFile.getPath());
    832836        return false;
    833837    }
     
    836840    Element config_site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);
    837841    if (config_site_list ==null ) {
    838         System.err.println("MessageRouter:activateSite, no sites found");
     842        logger.error("activateSite, no sites found");
    839843        return false;
    840844    }
     
    847851    Element this_site_elem = GSXML.getNamedElement(config_site_list, GSXML.SITE_ELEM, GSXML.NAME_ATT, site_name);
    848852    if (this_site_elem == null) {
    849         System.err.println("MessageRouter:activateSite, site "+site_name+" not found");
     853        logger.error("activateSite, site "+site_name+" not found");
    850854        return false;
    851855    }
     
    867871    if (this.module_map.containsKey(name)) {
    868872
    869         System.out.println("MessageRouter: deactivating "+name);
     873        logger.info(" deactivating "+name);
    870874        ModuleInterface m = (ModuleInterface)this.module_map.remove(name);
    871875        m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows
     
    900904        }
    901905        } else {
    902         System.err.println("MessageRouter: couldn't deactivate coll");
     906        logger.error(" couldn't deactivate coll");
    903907        // couldn't do it
    904908        return false;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/NZDLReceptionist.java

    r6677 r13124  
    1414import java.util.Enumeration;
    1515
     16import org.apache.log4j.*;
     17
    1618/**
    1719 * This is a new version of the Receptionist for the NZDL interface
     
    2022 */
    2123public class NZDLReceptionist extends DefaultReceptionist {
    22    
     24
     25     static Category logger = Category.getInstance(org.greenstone.gsdl3.core. NZDLReceptionist.class.getName());
     26
    2327    protected void addExtraInfo(Element page) {
    24     ///ystem.out.println("the  page before adding extra info is");
    25     ///ystem.out.println(this.converter.getPrettyString(page));
     28    logger.debug("the  page before adding extra info is");
     29    logger.debug(this.converter.getPrettyString(page));
    2630
    2731    super.addExtraInfo(page);
     
    8791        }
    8892    }
    89     ///ystem.out.println("the final page before transforming is");
    90     ///ystem.out.println(this.converter.getPrettyString(page));
     93    logger.debug("the final page before transforming is");
     94    logger.debug(this.converter.getPrettyString(page));
    9195    return;
    9296    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/Receptionist.java

    r10293 r13124  
    1515import java.util.ArrayList;
    1616
     17import org.apache.log4j.*;
     18
    1719/** the most basic Receptionist, used for interface generation.
    1820 * Receives requests consisting
     
    2325public class Receptionist implements ModuleInterface {
    2426
     27     static Category logger = Category.getInstance(org.greenstone.gsdl3.core.Receptionist.class.getName());
     28
    2529    /** the set up variables */
    2630    protected HashMap config_params = null;
     
    6771
    6872    if (this.config_params==null) {
    69         System.err.println("Receptionist Error: config variables must be set before calling configure");
     73        logger.error(" config variables must be set before calling configure");
    7074        return false;
    7175    }
    7276    if (this.mr==null) {       
    73         System.err.println("Receptionist Error: message router must be set  before calling configure");
     77        logger.error(" message router must be set  before calling configure");
    7478        return false;
    7579    }
     
    7882    File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.INTERFACE_NAME))));
    7983    if (!interface_config_file.exists()) {
    80         System.err.println("Receptionist: interface config file: "+interface_config_file.getPath()+" not found!");
     84        logger.error(" interface config file: "+interface_config_file.getPath()+" not found!");
    8185        return false;
    8286    }
     
    8488    Document config_doc = this.converter.getDOM(interface_config_file);
    8589    if (config_doc == null) {
    86         System.err.println("Receptionist: could not parse interface config file: "+interface_config_file.getPath());
     90        logger.error(" could not parse interface config file: "+interface_config_file.getPath());
    8791        return false;
    8892    }
     
    104108        ac = (Action)Class.forName("org.greenstone.gsdl3.action."+class_name).newInstance();
    105109        } catch (Exception e) {
    106         System.err.println("Receptionist: couldn't load in action "+class_name);
     110        logger.error(" couldn't load in action "+class_name);
    107111        e.printStackTrace();
    108112        continue;
     
    117121    this.language_list = (Element)GSXML.getChildByTagName(config_elem, "languageList");
    118122    if (language_list == null) {
    119         System.err.println("Receptionist: didn't find a language list in the config file!!");
     123        logger.error(" didn't find a language list in the config file!!");
    120124    }
    121125
     
    138142    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
    139143    if (request == null) {
    140         System.err.println("Receptionist Error: message had no request!");
     144        logger.error(" message had no request!");
    141145        return null;
    142146    }
     
    145149    if (!type.equals(GSXML.REQUEST_TYPE_PAGE)) {
    146150        // now Receptionist forwards non-page requests straight to the MR, and returns the responses
    147         System.err.println("Receptionist: request type is not '"+GSXML.REQUEST_TYPE_PAGE+"', but it is '"+type+"', so forwarding the message to the MR!");
     151        logger.error(" request type is not '"+GSXML.REQUEST_TYPE_PAGE+"', but it is '"+type+"', so forwarding the message to the MR!");
    148152        // process the whole message - mr needs <message> tags, and
    149153        // in this case, there may be more than one request in the message
     
    153157    String action = request.getAttribute(GSXML.ACTION_ATT);
    154158    if (action.equals("")) {
    155         System.err.println("Receptionist Error: no action specified in the request!");
     159        logger.error(" no action specified in the request!");
    156160        return null;
    157161    }
     
    173177        } catch (Exception e) {
    174178       
    175         System.err.println("Receptionist Error: a new action ("+action_name+") was specified and it couldn't be created. Error message:"+e.getMessage());
     179        logger.error(" a new action ("+action_name+") was specified and it couldn't be created. Error message:"+e.getMessage());
    176180        return null;
    177181        }
     
    209213    page.appendChild(page_response);
    210214
    211     ///ystem.out.println("Receptionist: raw page="+this.converter.getString(page));
     215    logger.debug(" raw page="+this.converter.getString(page));
    212216    // transform the result in some way
    213217    Element resulting_page = postProcessPage(page);
     
    226230        File base_interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), base_interface)));
    227231        if (!base_interface_config_file.exists()) {
    228         System.err.println("Receptionist: base interface config file: "+base_interface_config_file.getPath()+" not found!");
     232        logger.error(" base interface config file: "+base_interface_config_file.getPath()+" not found!");
    229233        return false;
    230234        }
     
    237241        Document config_doc = this.converter.getDOM(base_interface_config_file);
    238242        if (config_doc == null) {
    239         System.err.println("Receptionist: could not parse base interface config file: "+base_interface_config_file.getPath());
     243        logger.error(" could not parse base interface config file: "+base_interface_config_file.getPath());
    240244        return false;
    241245        }
     
    249253    Element option_list = (Element)GSXML.getChildByTagName(config_elem, "optionList");
    250254    if (option_list != null) {
    251         System.err.println("found an option list");
     255        logger.error("found an option list");
    252256        // we set any options in the config params
    253257        NodeList options = option_list.getElementsByTagName("option");
     
    256260        String name = option.getAttribute(GSXML.NAME_ATT);
    257261        String value = option.getAttribute(GSXML.VALUE_ATT);
    258         System.err.println("option: "+name+", "+value);
     262        logger.error("option: "+name+", "+value);
    259263        if (!name.equals("") && !value.equals("")) {
    260264            this.config_params.put(name, value);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java

    r10293 r13124  
    1414import java.util.Enumeration;
    1515
     16import org.apache.log4j.*;
     17
    1618/** A receptionist that uses xslt to transform the page_data before returning it. . Receives requests consisting
    1719 * of an xml representation of cgi args, and returns the page of data - in
     
    2224public class TransformingReceptionist extends Receptionist{
    2325   
     26     static Category logger = Category.getInstance(org.greenstone.gsdl3.core.TransformingReceptionist.class.getName());
     27
    2428    /** the list of xslt to use for actions */
    2529    protected HashMap xslt_map = null;
     
    3842   
    3943    if (this.config_params==null) {
    40         System.err.println("TransformingReceptionist Error: config variables must be set before calling configure");
     44        logger.error(" config variables must be set before calling configure");
    4145        return false;
    4246    }
    4347    if (this.mr==null) {       
    44         System.err.println("TransformingReceptionist Error: message router must be set  before calling configure");
     48        logger.error(" message router must be set  before calling configure");
    4549        return false;
    4650    }
     
    4953    File interface_config_file = new File(GSFile.interfaceConfigFile(GSFile.interfaceHome(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.INTERFACE_NAME))));
    5054    if (!interface_config_file.exists()) {
    51         System.err.println("TransformingReceptionist: interface config file: "+interface_config_file.getPath()+" not found!");
     55        logger.error(" interface config file: "+interface_config_file.getPath()+" not found!");
    5256        return false;
    5357    }
    5458    Document config_doc = this.converter.getDOM(interface_config_file, "utf-8");
    5559    if (config_doc == null) {
    56         System.err.println("TransformingReceptionist: could not parse interface config file: "+interface_config_file.getPath());
     60        logger.error(" could not parse interface config file: "+interface_config_file.getPath());
    5761        return false;
    5862    }
     
    7377        ac = (Action)Class.forName("org.greenstone.gsdl3.action."+class_name).newInstance();
    7478        } catch (Exception e) {
    75         System.err.println("TransformingReceptionist Error: couldn't load in action "+class_name);
     79        logger.error(" couldn't load in action "+class_name);
    7680        e.printStackTrace();
    7781        continue;
     
    9599       
    96100        String map_key = action_name+":"+subname;
    97         ///ystem.out.println("adding in to xslt map, "+map_key+"->"+subxslt);
     101        logger.debug("adding in to xslt map, "+map_key+"->"+subxslt);
    98102        this.xslt_map.put(map_key, subxslt);
    99103        }
     
    103107    Element lang_list = (Element)GSXML.getChildByTagName(config_elem, "languageList");
    104108    if (lang_list == null) {
    105         System.err.println("TransformingReceptionist: didn't find a language list in the config file!!");
     109        logger.error(" didn't find a language list in the config file!!");
    106110    } else {
    107111        this.language_list = (Element) this.doc.importNode(lang_list, true);
     
    130134    protected Element transformPage(Element page) {
    131135
    132     //ystem.out.println("page before transfomring:");
    133     //ystem.out.println(this.converter.getPrettyString(page));
     136    logger.debug("page before transfomring:");
     137    logger.debug(this.converter.getPrettyString(page));
    134138
    135139    Element request = (Element)GSXML.getChildByTagName(page, GSXML.PAGE_REQUEST_ELEM);
     
    157161    if (xslt_file==null) {
    158162        // cant transform the page - return null or the original?
    159         System.err.println("TransformingReceptionist: cant find the xslt file needed, so returning the original page!");
     163        logger.error(" cant find the xslt file needed, so returning the original page!");
    160164        return page;
    161165    }
    162166    Document style_doc = this.converter.getDOM(new File(xslt_file), "UTF-8");
    163167    if (style_doc == null) {
    164         System.err.println("TransformingReceptionist: cant parse the xslt file needed, so returning the original page!");
     168        logger.error(" cant parse the xslt file needed, so returning the original page!");
    165169        return page;
    166170       
     
    172176    if (format_elem != null) {
    173177        //page_response.removeChild(format_elem);
    174         ///ystem.err.println("format elem="+this.converter.getPrettyString(format_elem));
     178        logger.debug("format elem="+this.converter.getPrettyString(format_elem));
    175179        // need to transform the format info
    176180        String stylesheet_file = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces,   "config_format.xsl");
     
    180184        format_doc.appendChild(format_doc.importNode(format_elem, true));
    181185        Element new_format = (Element)this.transformer.transform(stylesheet_doc, format_doc);
    182         ///ystem.err.println("new format elem="+this.converter.getPrettyString(new_format));
     186        logger.debug("new format elem="+this.converter.getPrettyString(new_format));
    183187       
    184188        // add it in to the main stylesheet
    185189        GSXSLT.mergeStylesheets(style_doc, new_format);
    186190        } else {
    187         System.err.println("TransformingReceptionist: couldn't parse the config_format stylesheet, adding the format info as is");
     191        logger.error(" couldn't parse the config_format stylesheet, adding the format info as is");
    188192        GSXSLT.mergeStylesheets(style_doc, format_elem);
    189193        }
    190         ///ystem.out.println("the converted stylesheet is:");
    191         ///ystem.out.println(this.converter.getPrettyString(style_doc.getDocumentElement()));
     194        logger.debug("the converted stylesheet is:");
     195        logger.debug(this.converter.getPrettyString(style_doc.getDocumentElement()));
    192196    }
    193197   
     
    215219    String stylesheet = GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(), (String)this.config_params.get(GSConstants.SITE_NAME), collection, (String)this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name);
    216220    if (stylesheet==null) {
    217         System.out.println("TransformingReceptionist: cant find stylesheet for "+name);
     221        logger.info(" cant find stylesheet for "+name);
    218222    }
    219223    return stylesheet;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractBrowse.java

    r11280 r13124  
    3434import java.util.ArrayList;
    3535
     36import org.apache.log4j.*;
     37
    3638/** Partially implements a generic classifier service
    3739 *
    3840 * @author <a href="mailto:[email protected]">Katherine Don</a>
    3941 */
    40 
    4142public abstract class AbstractBrowse
    4243    extends ServiceRack {
     44
     45     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractBrowse.class.getName());
    4346
    4447    // the browsing services
     
    8083    }
    8184
    82     System.out.println("Configuring AbstractBrowse...");
     85    logger.info("Configuring AbstractBrowse...");
    8386    this.config_info = info;
    8487
     
    259262                               name);
    260263        if (node_extra == null) {
    261         System.err.println("GS2REtrieve: haven't found extra info for classifier named "+name);
     264        logger.error("GS2REtrieve: haven't found extra info for classifier named "+name);
    262265        continue;
    263266        }
     
    304307    Element query_node_list = (Element) GSXML.getChildByTagName(request, GSXML.CLASS_NODE_ELEM+GSXML.LIST_MODIFIER);
    305308    if (query_node_list == null) {
    306         System.err.println("AbstractBrowse Error: ClassifierBrowse request specified no doc nodes.\n");
     309        logger.error(" ClassifierBrowse request specified no doc nodes.\n");
    307310        return result;
    308311    }
     
    311314    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    312315    if (param_list == null) {
    313         System.err.println("AbstractBrowse Error: ClassifierBrowse request had no paramList.");
     316        logger.error(" ClassifierBrowse request had no paramList.");
    314317        return result;  // Return the empty result
    315318    }
     
    353356            want_entire_structure = true;
    354357        else
    355             System.err.println("AbstractDocumentRetrieve Warning: Unknown value \"" + p_value + "\".");
     358            logger.error("AbstractDocumentRetrieve Warning: Unknown value \"" + p_value + "\".");
    356359        } else if (p_name.equals(INFO_PARAM)) {
    357360        want_info = true;
     
    485488    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    486489    if (param_list == null) {
    487         System.err.println("AbstractBrowse, ClassifierBrowseMetadataRetrieve Error: missing paramList.\n");
     490        logger.error("AbstractBrowse, ClassifierBrowseMetadataRetrieve Error: missing paramList.\n");
    488491        return result;  // Return the empty result
    489492    }
     
    513516    Element request_node_list = (Element) GSXML.getChildByTagName(request, GSXML.CLASS_NODE_ELEM+GSXML.LIST_MODIFIER);
    514517    if (request_node_list == null) {
    515         System.err.println("AbstractBrowse Error: ClassifierBrowseMetadataRetrieve request had no "+GSXML.CLASS_NODE_ELEM+GSXML.LIST_MODIFIER);
     518        logger.error(" ClassifierBrowseMetadataRetrieve request had no "+GSXML.CLASS_NODE_ELEM+GSXML.LIST_MODIFIER);
    516519        return result;
    517520    }
     
    622625    if (current_node == null) {
    623626        // create a sensible error message
    624         System.err.println("AbstractBrowse Error: there should be a first child.");
     627        logger.error(" there should be a first child.");
    625628        return null;
    626629    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractDocumentRetrieve.java

    r11279 r13124  
    4141import java.util.ArrayList;
    4242
     43
     44import org.apache.log4j.*;
     45
    4346/** Abstract class for Document Retrieval Services
    4447 *
     
    4851public abstract class AbstractDocumentRetrieve
    4952    extends ServiceRack {
     53
     54    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractDocumentRetrieve.class.getName());
    5055
    5156    // the services on offer
     
    9398    }
    9499
    95     System.out.println("Configuring AbstractDocumentRetrieve...");
     100    logger.info("Configuring AbstractDocumentRetrieve...");
    96101    this.config_info = info;
    97102
     
    345350            want_entire_structure = true;
    346351        else
    347             System.err.println("AbstractDocumentRetrieve Warning: Unknown value \"" + p_value + "\".");
     352            logger.error("AbstractDocumentRetrieve Warning: Unknown value \"" + p_value + "\".");
    348353        } else if (p_name.equals(INFO_PARAM)) {
    349354        want_info = true;
     
    483488    Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    484489    if (query_doc_list == null) {
    485         System.err.println("Error: DocumentContentRetrieve request specified no doc nodes.\n");
     490        logger.error("Error: DocumentContentRetrieve request specified no doc nodes.\n");
    486491        return result;
    487492    }
     
    569574    if (current_node == null) {
    570575        // create a sensible error message
    571         System.err.println("AbstractDocumentRetrieve Error: there should be a first child.");
     576        logger.error(" there should be a first child.");
    572577        return null;
    573578    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java

    r11265 r13124  
    4242import java.util.ArrayList;
    4343
     44import org.apache.log4j.*;
     45
    4446/** Implements the generic retrieval and classifier services for GS2
    4547 * collections.
     
    5254    extends AbstractDocumentRetrieve {
    5355
     56      static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractGS2DocumentRetrieve.class.getName());
     57
    5458    //    protected static final String EXTLINK_PARAM = "ext"; here or in base??   
    5559    protected String index_stem = null;
     
    7680    }
    7781   
    78     System.out.println("Configuring AbstractGS2DocumentRetrieve...");
     82    logger.info("Configuring AbstractGS2DocumentRetrieve...");
    7983    //this.config_info = info;
    8084   
     
    8589    }
    8690    if (this.index_stem == null || this.index_stem.equals("")) {
    87         System.err.println("AbstractGS2DocumentRetrieve.configure(): indexStem element not found, stem will default to collection name");
     91        logger.error("AbstractGS2DocumentRetrieve.configure(): indexStem element not found, stem will default to collection name");
    8892        this.index_stem = this.cluster_name;
    8993    }
     
    9296    String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem);
    9397    if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {
    94         System.err.println("AbstractGS2DocumentRetrieve Error: Could not open GDBM database!");
     98        logger.error("Could not open GDBM database!");
    9599        return false;
    96100    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGPPSearch.java

    r11011 r13124  
    3838import java.io.File;
    3939
     40import org.apache.log4j.*;
    4041
    4142/** Partially implements a generic MGPP search service
     
    4748    extends AbstractSearch
    4849{
     50
     51      static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractMGPPSearch.class.getName());
    4952
    5053    // extra services offered by mgpp collections
     
    123126   
    124127    // Do specific configuration
    125     System.out.println("Configuring AbstractMGPPSearch...");
     128    logger.info("Configuring AbstractMGPPSearch...");
    126129
    127130    // do we support any of the extended features?
     
    139142    }
    140143    if (this.index_stem == null || this.index_stem.equals("")) {
    141         System.err.println("AbstractMGPPSearch.configure(): indexStem element not found, stem will default to collection name");
     144        logger.error("AbstractMGPPSearch.configure(): indexStem element not found, stem will default to collection name");
    142145        this.index_stem = this.cluster_name;
    143146    }
     
    186189    }
    187190    if (this.default_level == null || this.default_level.equals("")) {
    188         System.err.println("Error: default level not specified!");
     191        logger.error("default level not specified!");
    189192        return false;
    190193    }
     
    442445    default:
    443446        // should never get here
    444         System.err.println("AbstractMGPPSearch: wrong query type!!");
     447        logger.error("wrong query type!!");
    445448        return null;
    446449    }
     
    454457    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    455458    if (param_list == null) {
    456         System.err.println("Error: TextQuery request had no paramList.");
     459        logger.error("TextQuery request had no paramList.");
    457460        return result;  // Return the empty result
    458461    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractMGSearch.java

    r9966 r13124  
    3737import java.io.File;
    3838
     39import org.apache.log4j.*;
     40
    3941/** Partially implements a generic MG search service
    4042 *
     
    4547    extends AbstractSearch
    4648{
     49
     50    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractMGSearch.class.getName());
    4751    protected static final String CASE_PARAM = "case";
    4852    protected static final String STEM_PARAM = "stem";
     
    99103    }
    100104    if (this.index_stem == null || this.index_stem.equals("")) {
    101         System.err.println("AbstractMGSearch.configure(): indexStem element not found, stem will default to collection name");
     105        logger.error("AbstractMGSearch.configure(): indexStem element not found, stem will default to collection name");
    102106        this.index_stem = this.cluster_name;
    103107    }
     
    118122                               name);
    119123        if (node_extra == null) {
    120             System.err.println("GS2Search: haven't found extra info for index named "+name);
     124            logger.error("haven't found extra info for index named "+name);
    121125            continue;
    122126        }
     
    168172    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    169173    if (param_list == null) {
    170         System.err.println("Error: TextQuery request had no paramList.");
     174        logger.error("TextQuery request had no paramList.");
    171175        return result;  // Return the empty result
    172176    }
     
    207211    Vector docs = mqr.getDocs();
    208212    if (docs.size() == 0) {
    209         System.err.println("GS2MGSearch: Warning: No results found...\n");
     213        logger.error("No results found...\n");
    210214    }
    211215
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/AbstractSearch.java

    r10093 r13124  
    3232import java.util.HashMap;
    3333
     34import org.apache.log4j.*;
     35
    3436/** Partially implements a generic search service
    3537 *
     
    4042    extends ServiceRack
    4143{
     44
     45   static Category logger = Category.getInstance(org.greenstone.gsdl3.service.AbstractSearch.class.getName());
     46
    4247   
    4348    // the search service
     
    9196    }
    9297
    93     System.out.println("Configuring AbstractSearch...");
     98    logger.info("Configuring AbstractSearch...");
    9499   
    95100    this.config_info = info;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/BerryBasket.java

    r12184 r13124  
    4444import javax.swing.Timer;
    4545
     46import org.apache.log4j.*;
     47
    4648public class BerryBasket
    4749    extends ServiceRack {
     50
     51    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.BerryBasket.class.getName());
    4852
    4953    // the services on offer
     
    98102    public boolean configure(Element info, Element extra_info)
    99103    {
    100     System.out.println("Configuring BerryBasket...");
     104    logger.info("Configuring BerryBasket...");
    101105    this.config_info = info;
    102106
     
    204208    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    205209    if (param_list == null) {
    206         System.err.println("BerryBasket Error: AddItem request had no paramList.");
     210        logger.error("BerryBasket Error: AddItem request had no paramList.");
    207211        return result;  // Return the empty result
    208212    }
     
    286290
    287291    if (param_list == null) {
    288         System.err.println("BerryBasket Error: DeleteItem request had no paramList.");
     292        logger.error("BerryBasket Error: DeleteItem request had no paramList.");
    289293        return result;  // Return the empty result
    290294    }
     
    335339
    336340    if (param_list == null) {
    337         System.err.println("BerryBasket Error: DeleteItem request had no paramList.");
     341        logger.error("BerryBasket Error: DeleteItem request had no paramList.");
    338342        return result;  // Return the empty result
    339343    }
     
    489493     
    490494    if (param_list == null) {
    491         System.err.println("BerryBasket Error: SendMail request had no paramList.");
     495        logger.error("BerryBasket Error: SendMail request had no paramList.");
    492496        return result;  // Return the empty result
    493497    }
     
    551555        Transport.send(msg);
    552556       
    553         System.out.println("\nMail was sent successfully.");
     557        logger.info("\nMail was sent successfully.");
    554558            result.appendChild(this.doc.createTextNode("Mail was sent successfully."));
    555559    } catch (Exception e) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/CrossCollectionSearch.java

    r11229 r13124  
    3131import java.util.HashMap;
    3232
     33import org.apache.log4j.*;
    3334
    3435/**
     
    4041    extends ServiceRack {
    4142
     43     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.CrossCollectionSearch.class.getName());
    4244    protected static final String QUERY_PARAM = "query";
    4345    protected static final String COLLECTION_PARAM = "collection";
     
    6062    {
    6163    // any parameters? colls to include??
    62     System.out.println("Configuring CrossCollectionSearch...");
     64    logger.info("Configuring CrossCollectionSearch...");
    6365    // query service
    6466    Element ccs_service = this.doc.createElement(GSXML.SERVICE_ELEM);
     
    118120        }
    119121       
    120         ///ystem.err.println("service description="+this.converter.getPrettyString(ccs_service));
     122        logger.debug("service description="+this.converter.getPrettyString(ccs_service));
    121123        return ccs_service;
    122124    }
     
    141143    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    142144    if (param_list == null) {
    143         System.err.println("Error: TextQuery request had no paramList.");
     145        logger.error("TextQuery request had no paramList.");
    144146        return result;  // Return the empty result
    145147    }
     
    240242    Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", lang, ""); // uid
    241243    coll_list_message.appendChild(coll_list_request);
    242     ///ystem.err.println("coll list request = "+this.converter.getPrettyString(coll_list_request));
     244    logger.debug("coll list request = "+this.converter.getPrettyString(coll_list_request));
    243245    Element coll_list_response = (Element)this.router.process(coll_list_message);
    244246    if (coll_list_response==null) {
    245         System.err.println("PageAction Error: couldn't query the message router!");
     247        logger.error("couldn't query the message router!");
    246248        return false;
    247249    }
    248     ///ystem.err.println("coll list response = "+this.converter.getPrettyString(coll_list_response));
     250    logger.debug("coll list response = "+this.converter.getPrettyString(coll_list_response));
    249251    // second, get some info from each collection. we want the coll name
    250252    // and whether its got a text query service
     
    259261        metadata_message.appendChild(metadata_request);
    260262    }
    261     ///ystem.err.println("metadata request = "+this.converter.getPrettyString(metadata_message));
     263    logger.debug("metadata request = "+this.converter.getPrettyString(metadata_message));
    262264    Element metadata_response = (Element)this.router.process(metadata_message);
    263     ///ystem.err.println("metadata response = "+this.converter.getPrettyString(metadata_response));
     265    logger.debug("metadata response = "+this.converter.getPrettyString(metadata_response));
    264266
    265267    NodeList coll_responses = metadata_response.getElementsByTagName(GSXML.COLLECTION_ELEM);
     
    300302    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    301303    if (param_list == null) {
    302         System.err.println("Error: DocumentMetadataRetrieve request had no paramList.");
     304        logger.error("DocumentMetadataRetrieve request had no paramList.");
    303305        return result;  // Return the empty result
    304306    }
     
    306308    NodeList query_doc_list = request.getElementsByTagName(GSXML.DOC_NODE_ELEM);
    307309    if (query_doc_list.getLength()==0) {
    308        System.err.println("Error: DocumentMetadataRetrieve request had no documentNodes.");
     310       logger.error("DocumentMetadataRetrieve request had no documentNodes.");
    309311        return result;  // Return the empty result
    310312    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Browse.java

    r10651 r13124  
    3838import java.util.Iterator;
    3939
     40import org.apache.log4j.*;
     41
    4042/** Greenstone 2 collection classifier service
    4143 *
     
    4749    extends AbstractBrowse
    4850{
    49    
     51
     52     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2Browse.class.getName());
     53
    5054    protected GDBMWrapper gdbm_src = null;
    5155
     
    6771    }
    6872
    69     System.err.println("Configuring GS2Browse...");
     73    logger.info("Configuring GS2Browse...");
    7074    // the index stem is either specified in the config file or is  the collection name
    7175    Element index_stem_elem = (Element) GSXML.getChildByTagName(info, GSXML.INDEX_STEM_ELEM);
     
    8185    String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, index_stem);
    8286    if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {
    83         System.err.println("GS2Browse Error: Could not open GDBM database!");
     87        logger.error("Could not open GDBM database!");
    8488        return false;
    8589    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r10093 r13124  
    3636import java.util.Locale;
    3737
     38import org.apache.log4j.*;
     39
    3840/**
    3941 * A Services class for building collections
     
    4648    extends ServiceRack {
    4749   
     50     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2Construct.class.getName());
     51
    4852    // services offered
    4953    private static final String NEW_SERVICE = "NewCollection";
     
    166170    GS2PerlListener listener = (GS2PerlListener)this.listeners.get(id);
    167171    if (listener==null) {
    168         System.err.println("somethings gone wrong, couldn't find the listener");
     172        logger.error("somethings gone wrong, couldn't find the listener");
    169173        status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
    170174        return response;
     
    217221    if (get_status_only) {
    218222        // at the moment, delete is synchronous. but it may take ages so should do the command in another thread maybe? in which case we will want to ask for status
    219         System.err.println("had a status request for delete - this shouldn't happen!!");
     223        logger.error("had a status request for delete - this shouldn't happen!!");
    220224        //t = this.doc.createTextNode("");
    221225        //status.appendChild(t);
     
    267271    if (get_status_only) {
    268272        // reload is synchronous - this makes no sense
    269         System.err.println("had a status request for reload - this shouldn't happen!!");
     273        logger.error("had a status request for reload - this shouldn't happen!!");
    270274        //t = this.doc.createTextNode("");
    271275        //status.appendChild(t);
     
    300304        command.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_ACTIVATE);
    301305    } else {
    302         System.err.println("invalid action name passed to systemRequest:"+action_name);
     306        logger.error("invalid action name passed to systemRequest:"+action_name);
    303307        return;
    304308    }
     
    330334    }
    331335
    332     System.out.println("configuring GS2Construct");
     336    logger.info("configuring GS2Construct");
    333337
    334338    Element e = null;
     
    427431        coll_name = (String)params.get(COL_PARAM);
    428432    }
    429     System.err.println("Coll name = "+coll_name);
     433    logger.error("Coll name = "+coll_name);
    430434    // makes a paramList of the relevant params
    431435    Element other_params = extractOtherParams(params, type);
     
    471475    File collectDir = new File(GSFile.collectDir(this.site_home));
    472476    if (!collectDir.exists()) {
    473         System.err.println("couldn't find collect dir: "+collectDir.toString());
     477        logger.error("couldn't find collect dir: "+collectDir.toString());
    474478        return null;
    475479    }
    476     System.out.println("GS2Construct: reading thru directory "+collectDir.getPath()+" to find collections.");
     480    logger.info("GS2Construct: reading thru directory "+collectDir.getPath()+" to find collections.");
    477481    File[] contents = collectDir.listFiles();
    478482    int num_colls=0;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPRetrieve.java

    r10651 r13124  
    3232import java.io.File;
    3333
     34import org.apache.log4j.*;
     35
    3436public class GS2MGPPRetrieve
    3537    extends AbstractGS2DocumentRetrieve
    3638{
     39     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2MGPPRetrieve.class.getName());
     40
    3741     // Parameters used
    3842    private static final String LEVEL_PARAM = "level";
     
    6367
    6468    // Do specific configuration
    65     System.out.println("Configuring GS2MGPPRetrieve...");
     69    logger.info("Configuring GS2MGPPRetrieve...");
    6670
    6771    // Get the default level out of <defaultLevel> (buildConfig.xml)
     
    7175    }
    7276    if (this.default_level == null || this.default_level.equals("")) {
    73         System.err.println("Error: default level not specified!");
     77        logger.error("default level not specified!");
    7478        return false;
    7579    }
    76     // System.out.println("Default level: " + default_level_);
    7780   
    7881    // The location of the MGPP text files
     
    9396    long doc_num = this.gdbm_src.OID2Docnum(doc_id);
    9497    if (doc_num == -1) {
    95         System.err.println("OID "+doc_id +" couldn't be converted to mgpp num");
     98        logger.error("OID "+doc_id +" couldn't be converted to mgpp num");
    9699        return null;
    97100    }
     
    107110        }
    108111    } catch (Exception e) {
    109         System.out.println("exception happended with mgpp_src.getDocument()" + e);
     112        logger.info("exception happended with mgpp_src.getDocument()" + e);
    110113        doc_content = "this is the content for section hash id "+ doc_id+", mgpp doc num "+doc_num+"\n";
    111114
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGPPSearch.java

    r10652 r13124  
    2727import org.w3c.dom.NodeList;
    2828
     29import org.apache.log4j.*;
     30
    2931/**
    3032 *
     
    3739{
    3840    protected GDBMWrapper gdbm_src = null;
     41     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2MGPPSearch.class.getName());
    3942
    4043    /** constructor */
     
    5962    String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem);
    6063    if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {
    61         System.err.println("Error: Could not open GDBM database!");
     64        logger.error("Could not open GDBM database!");
    6265        return false;
    6366    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGRetrieve.java

    r10651 r13124  
    3232import java.io.File;
    3333
     34import org.apache.log4j.*;
     35
    3436public class GS2MGRetrieve
    3537    extends AbstractGS2DocumentRetrieve
    3638{
     39   static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2MGRetrieve.class.getName());
     40
    3741    // Elements used in the config file that are specific to this class
    3842    private static final String DEFAULT_INDEX_ELEM = "defaultIndex";
     
    6064   
    6165    // Do specific configuration
    62     System.out.println("Configuring GS2MGRetrieve...");
    63     // System.out.println("info:\n" + converter_.getString(info));
    64     // System.out.println("extra_info:\n" + converter_.getString(extra_info));
    65 
     66    logger.info("Configuring GS2MGRetrieve...");
     67   
    6668    // Get the default index out of <defaultIndex> (buildConfig.xml)
    6769    Element def = (Element) GSXML.getChildByTagName(info, DEFAULT_INDEX_ELEM);
     
    7072    }
    7173    if (this.default_index == null || this.default_index.equals("")) {
    72         System.err.println("Error: default index not specified!");
     74        logger.error("default index not specified!");
    7375        return false;
    7476    }
    75     // System.out.println("Default index: " + this.default_index);
     77    logger.debug("Default index: " + this.default_index);
    7678
    7779    // The location of the MG index and text files
     
    9395    long doc_num = this.gdbm_src.OID2Docnum(doc_id);
    9496    if (doc_num == -1) {
    95         System.err.println("OID "+doc_id +" couldn't be converted to mg num");
     97        logger.error("OID "+doc_id +" couldn't be converted to mg num");
    9698        return null;
    9799    }
     
    108110        //GSXML.addDocText(this.doc, doc, doc_content);
    109111    } else {
    110         System.err.println("the doc content was null, not getting that section\n");
     112        logger.error("the doc content was null, not getting that section\n");
    111113        doc_content = "couldn't retrieve content for this section\n";
    112114    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/GS2MGSearch.java

    r10651 r13124  
    2727import org.w3c.dom.NodeList;
    2828
     29import org.apache.log4j.*;
     30
    2931/**
    3032 *
     
    3739{
    3840    protected GDBMWrapper gdbm_src = null;
     41    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.GS2MGSearch.class.getName());
     42
    3943
    4044    /** constructor */
     
    5862    String gdbm_db_file = GSFile.GDBMDatabaseFile(this.site_home, this.cluster_name, this.index_stem);
    5963    if (!this.gdbm_src.openDatabase(gdbm_db_file, GDBMWrapper.READER)) {
    60         System.err.println("Error: Could not open GDBM database!");
     64        logger.error(" Could not open GDBM database!");
    6165        return false;
    6266    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/IViaProxy.java

    r10093 r13124  
    2121import java.net.MalformedURLException;
    2222
     23import org.apache.log4j.*;
     24
    2325/**
    2426 *
     
    2931public class IViaProxy
    3032    extends ServiceRack {
     33   
     34     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.IViaProxy.class.getName());
    3135   
    3236    // the services on offer
     
    5458    Element server_elem = (Element)GSXML.getChildByTagName(info, "iViaServer");
    5559    if (server_elem == null) {
    56         System.err.println("IViaProxy.configure error: no iViaServer element found");
     60        logger.error("no iViaServer element found");
    5761        return false;
    5862    }
    5963    ivia_server_url = server_elem.getAttribute("url");
    6064    if (ivia_server_url.equals("")) {
    61         System.err.println("IViaProxy.configure error: no url for the iViaServer element");
     65        logger.error("no url for the iViaServer element");
    6266        return false;
    6367    }
     
    167171    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    168172    if (param_list == null) {
    169         System.err.println("IViaProxy Error:: TextQuery request had no paramList.");
     173        logger.error("TextQuery request had no paramList.");
    170174        return result;  // Return the empty result
    171175    }
     
    203207    String doc_ids = null;
    204208    try {
    205         ///ystem.err.println("IViaProxy, sending "+url_string);
     209        logger.debug("IViaProxy, sending "+url_string);
    206210        BufferedReader reader = makeConnection(url_string);
    207211        results_num = reader.readLine();
     
    209213       
    210214    } catch (Exception e) {
    211         System.err.println("IViaProxy.TextQuery Error: exception happened during query");
     215        logger.error("exception happened during query");
    212216        e.printStackTrace();
    213217        return result;
     
    217221        results_num = results_num.substring(11);
    218222    } else {
    219         System.err.println("IViaProxy.TextQuery Error: badly formatted results line: "+results_num);
     223        logger.error("badly formatted results line: "+results_num);
    220224        return result;
    221225    }
     
    223227        doc_ids = doc_ids.substring(5).trim();
    224228    } else {
    225         System.err.println("IViaProxy.TextQuery Error: badly formatted docs line: "+doc_ids);
     229        logger.error("badly formatted docs line: "+doc_ids);
    226230        return result;
    227231    }
     
    241245        doc_node_list.appendChild(doc_node);
    242246    }
    243     ///ystem.err.println("IViaProxy result:");
    244     ///ystem.err.println(this.converter.getString(result));
     247    logger.debug("IViaProxy result:");
     248    logger.debug(this.converter.getString(result));
    245249    return result;
    246250   
     
    255259    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    256260    if (param_list == null) {
    257         System.err.println("IViaProxy.DocumentMetadataRetrieve Error: missing paramList.\n");
     261        logger.error("missing paramList.\n");
    258262        return result;  // Return the empty result
    259263    }
     
    275279   
    276280    if (field_list.length()==0) {
    277         System.err.println("IViaProxy.DocumentMetadataRetrieve Error: no metadata specified.\n");
     281        logger.error("no metadata specified.\n");
    278282        return result;
    279283    }
     
    282286    Element request_node_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    283287    if (request_node_list == null) {
    284         System.err.println("IViaProxy Error: DocumentMetadataRetrieve request had no "+GSXML.DOC_NODE_ELEM+"List.\n");
     288        logger.error("DocumentMetadataRetrieve request had no "+GSXML.DOC_NODE_ELEM+"List.\n");
    285289        return result;
    286290    }
     
    329333        }
    330334    } catch (Exception e) {
    331         System.err.println("IViaProxy Error:exception happened");
     335        logger.error("exception happened");
    332336        e.printStackTrace();
    333337    }
    334     ///ystem.out.println("IViaProxy: returning result: ");
    335     ///ystem.out.println(this.converter.getPrettyString(result));
     338    logger.debug("IViaProxy: returning result: ");
     339    logger.debug(this.converter.getPrettyString(result));
    336340    return result;
    337341 
     
    346350    Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    347351    if (query_doc_list == null) {
    348         System.err.println("IViaProxy Error: DocumentContentRetrieve request specified no doc nodes.\n");
     352        logger.error("DocumentContentRetrieve request specified no doc nodes.\n");
    349353        return result;
    350354    }
     
    381385       
    382386    } catch (Exception e) {
    383         System.err.println("IViaProxy Error:exception happened");
     387        logger.error("exception happened");
    384388        e.printStackTrace();
    385389    }
     
    414418        doc_node.appendChild(this.doc.importNode(content_element, true));
    415419    } else {
    416         System.err.println("IViaProxy.getDocument Error: Couldn't parse the node content");
     420        logger.error("Couldn't parse the node content");
    417421    }
    418422    return doc_node;
     
    495499    } catch (java.net.MalformedURLException e) {
    496500
    497         System.err.println("IViaProxy Error: Malformed URL: "+url_string);
     501        logger.error("Malformed URL: "+url_string);
    498502    } catch (java.io.IOException e) {
    499         System.err.println("IViaProxy Error: An error occurred during IO to url "+url_string);
     503        logger.error("An error occurred during IO to url "+url_string);
    500504    }
    501505    return reader;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/IViaRetrieve.java

    r9874 r13124  
    2323import java.net.MalformedURLException;
    2424
     25import org.apache.log4j.*;
     26
    2527/**
    2628 *
     
    3234public class IViaRetrieve
    3335    extends AbstractDocumentRetrieve {
    34    
     36
     37      static Category logger = Category.getInstance(org.greenstone.gsdl3.service.IViaRetrieve.class.getName());
     38   
     39
    3540    protected String ivia_server_url = null;
    3641   
     
    4853    Element server_elem = (Element)GSXML.getChildByTagName(info, "iViaServer");
    4954    if (server_elem == null) {
    50         System.err.println("IViaRetrieve.configure error: no iViaServer element found");
     55        logger.error("no iViaServer element found");
    5156        return false;
    5257    }
    5358    ivia_server_url = server_elem.getAttribute("url");
    5459    if (ivia_server_url.equals("")) {
    55         System.err.println("IViaRetrieve.configure error: no url for the iViaServer element");
     60        logger.error("no url for the iViaServer element");
    5661        return false;
    5762    }
     
    103108    Document content_doc = this.converter.getDOM(processed_content.toString());
    104109    if (content_doc == null) {
    105         System.err.println("IViaRetrieve.getNodeContent Error: Couldn't parse node content");
    106         System.err.println(processed_content.toString());
     110        logger.error("Couldn't parse node content");
     111        logger.error(processed_content.toString());
    107112        return null;
    108113    }
     
    181186    int p = oid.lastIndexOf('.');
    182187    if (p != oid.length()-3) {
    183         System.out.println("translateoid error: '.' is not the third to last char!!");
     188        logger.info("translateoid error: '.' is not the third to last char!!");
    184189        return oid;
    185190    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/IViaSearch.java

    r10194 r13124  
    1616import java.net.Authenticator;
    1717
     18import org.apache.log4j.*;
     19
    1820/**
    1921 *
     
    2527    extends AbstractSearch {
    2628   
     29
     30     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.IViaSearch.class.getName());
     31 
    2732    // have standard gs param names for hits per page, and start page
    2833    // these need to be mapped to iVia params
     
    4550    Element server_elem = (Element)GSXML.getChildByTagName(info, "iViaServer");
    4651    if (server_elem == null) {
    47         System.err.println("IViaSearch.configure error: no iViaServer element found");
     52        logger.error("no iViaServer element found");
    4853        return false;
    4954    }
    5055    ivia_server_url = server_elem.getAttribute("url");
    5156    if (ivia_server_url.equals("")) {
    52         System.err.println("IViaSearch.configure error: no url for the iViaServer element");
     57        logger.error("no url for the iViaServer element");
    5358        return false;
    5459    }
     
    7782    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    7883    if (param_list == null) {
    79         System.err.println("IViaSearch Error:: TextQuery request had no paramList.");
     84        logger.error("TextQuery request had no paramList.");
    8085        return result;  // Return the empty result
    8186    }
     
    115120    BufferedReader reader = null;
    116121    try {
    117         ///system.err.println("IViaSearch, sending "+url_string);
     122        logger.debug("sending "+url_string);
    118123        reader = Misc.makeHttpConnection(url_string);
    119124        results_num = reader.readLine();
     
    132137
    133138    } else {
    134         System.err.println("IViaSearch.TextQuery Error: badly formatted results:");
     139        logger.error("badly formatted results:");
    135140        StringBuffer result_string = new StringBuffer();
    136141        result_string.append("Error: badly formatted result from IVia server:\n ");
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/LuceneSearch.java

    r9874 r13124  
    2424
    2525import java.io.File;
     26
     27import org.apache.log4j.*;
     28
    2629/**
    2730 *
     
    3235public class LuceneSearch
    3336    extends AbstractSearch {
     37
     38     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.LuceneSearch.class.getName());
    3439
    3540    protected static final String INDEX_ELEM = "index";
     
    7176    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    7277    if (param_list == null) {
    73         System.err.println("LuceneSearch Error: TextQuery request had no paramList.");
     78        logger.error("TextQuery request had no paramList.");
    7479        GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", "0");
    7580        return result;  // Return the empty result
     
    8287    String query_string = (String) params.get(QUERY_PARAM);
    8388    if (query_string == null || query_string.equals("")) {
    84         System.err.println("LuceneSearch Error: TextQuery request had no query string.");
     89        logger.error("TextQuery request had no query string.");
    8590        GSXML.addMetadata(this.doc, metadata_list, "numDocsMatched", "0");
    8691        return result;  // Return the empty result
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/MapRetrieve.java

    r10093 r13124  
    2222import javax.swing.tree.DefaultMutableTreeNode;
    2323
    24 /**
    25  */
     24import org.apache.log4j.*;
    2625
    2726public class MapRetrieve
    2827    extends ServiceRack {
     28
     29    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.MapRetrieve.class.getName());
    2930
    3031    // the services on offer
     
    5960    }
    6061
    61     System.out.println("Configuring MapRetrieve...");
     62    logger.info("Configuring MapRetrieve...");
    6263    this.config_info = info;
    6364
     
    186187    String uid = request.getAttribute(GSXML.USER_ID_ATT);
    187188    if (uid.equals("")) {
    188         System.out.println("in metadata retrieve, uid = ''\n"+converter.getPrettyString(request));
     189        logger.info("in metadata retrieve, uid = ''\n"+converter.getPrettyString(request));
    189190    }
    190191    result.setAttribute(GSXML.FROM_ATT, DOCUMENT_METADATA_RETRIEVE_SERVICE);
     
    194195    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    195196    if (param_list == null) {
    196         System.err.println("MapRetrieve Error: missing paramList.\n");
     197        logger.error("missing paramList.\n");
    197198        return result;  // Return the empty result
    198199    }
     
    223224    Element request_node_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    224225    if (request_node_list == null) {
    225         System.err.println("Error: DocumentMetadataRetrieve request had no "+GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
     226        logger.error(" DocumentMetadataRetrieve request had no "+GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    226227        return result;
    227228    }
     
    365366    Element query_doc_list = (Element) GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    366367    if (query_doc_list == null) {
    367         System.err.println("Error: DocumentContentRetrieve request specified no doc nodes.\n");
     368        logger.error("DocumentContentRetrieve request specified no doc nodes.\n");
    368369        return result;
    369370    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/MapSearch.java

    r9874 r13124  
    4343import java.lang.ClassNotFoundException;
    4444
     45import org.apache.log4j.*;
     46
    4547/**
    4648 *
     
    4951public class MapSearch
    5052    extends AbstractSearch {
     53
     54
     55    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.MapSearch.class.getName());
    5156
    5257    protected String files_home_dir = null;
     
    7176        return false;
    7277    }
    73     System.out.println("Configuring MapSearch...");
     78    logger.info("Configuring MapSearch...");
    7479
    7580    // set the files_home_dir variable for this collection
     
    164169    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    165170    if (param_list == null) {
    166         System.err.println("Error: TextQuery request had no paramList.");
     171        logger.error("TextQuery request had no paramList.");
    167172        return result;  // Return the empty result
    168173    }
     
    249254
    250255        if((nameArray = (Object[])hashNames.get(terms[k].toLowerCase())) != null){
    251         //System.out.println(hashNames.get(terms[k].toLowerCase()));
     256        logger.debug(hashNames.get(terms[k].toLowerCase()));
    252257       
    253258        nameArraySize = Arrays.asList(nameArray).size();
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ModuleWrapper.java

    r10066 r13124  
    4141import java.security.SecureRandom;
    4242
     43import org.apache.log4j.*;
     44
    4345/**
    4446 * A classes for logging and checking all traffic to and from a ModuleInterface
     
    5759  implements ModuleInterface
    5860{
     61
     62    static Category logger = Category.getInstance(org.greenstone.gsdl3.service. ModuleWrapper.class.getName());
     63
    5964  /** the module we're wrapping */
    6065  protected ModuleInterface inner = null;
     
    138143    writer.write(xmlIn);
    139144      } catch (IOException e) {
    140     System.err.println("ModuleWrapper: caught exception: " +e );
     145    logger.error("caught exception: " +e );
    141146      }
    142147    }
     
    149154      writer.write(xmlOut);
    150155    } catch (IOException e) {
    151       System.err.println("ModuleWrapper: caught exception: " +e );
     156      logger.error("caught exception: " +e );
    152157    }
    153158    return xmlOut;
     
    179184    parser.setFeature("http://apache.org/xml/features/warn-on-duplicate-entitydef", true);
    180185      } catch (Exception a) {
    181     System.err.println("unable to set feature:" +a);
     186    logger.error("unable to set feature:" +a);
    182187    a.printStackTrace();
    183188      }
     
    188193    parser.parse(xml_source);
    189194      } catch (Exception e){ 
    190     System.err.println("parsing error:" +e);
     195    logger.error("parsing error:" +e);
    191196    e.printStackTrace();
    192197    return "<response> <error class=\"ModuleWrapper\" code=1> Error: supplied string contained the parse error: " + e + " </error> </response>";
     
    200205    parser.parse(xmlResult);
    201206      } catch (Exception e){ 
    202     System.err.println("parsing error:" +e);
     207    logger.error("parsing error:" +e);
    203208    e.printStackTrace();
    204209    return "<response> <error class=\"ModuleWrapper\" code=2> Error: returned string contained the parse error: " + e + "</error></response>";
     
    208213
    209214    } catch (Exception e){ 
    210       System.err.println("other error:" +e);
     215      logger.error("other error:" +e);
    211216      e.printStackTrace();
    212217      return "<response> <error class=\"ModuleWrapper\" code=3>Error: Unknown error or warning: " + e + " </error></response>";
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/PhindPhraseBrowse.java

    r10093 r13124  
    3030import java.util.HashMap;
    3131import java.io.File;
     32
     33import org.apache.log4j.*;
     34
    3235/**
    3336 * PhindServices - the phind phrase browsing service
     
    3942    extends ServiceRack {
    4043   
     44     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.PhindPhraseBrowse.class.getName());
     45
    4146    // the services on offer
    4247    private static final String PHIND_SERVICE = "PhindApplet";
     
    7378    }
    7479
    75     System.out.println("configuring PhindPhraseBrowse");
     80    logger.info("configuring PhindPhraseBrowse");
    7681
    7782    // set up short_service_info_ - for now just has name and type
     
    100105    Document dom = this.converter.getDOM(app_info);
    101106    if (dom==null) {
    102         System.err.println("PhindPhraseBrowse.configure Error: Couldn't parse applet info");
     107        logger.error("Couldn't parse applet info");
    103108        return false;
    104109    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r11266 r13124  
    4141import java.lang.reflect.Method;
    4242
     43import org.apache.log4j.*;
     44
    4345/**
    4446 * ServiceRack - abstract base class for services
     
    5860{
    5961
     62     static Category logger = Category.getInstance(org.greenstone.gsdl3.service.ServiceRack.class.getName());
     63
    6064    /** the absolute address of the site home */
    6165    protected String site_home =null;
     
    155159    Document doc = this.converter.getDOM(xml_in);
    156160    if (doc == null) {
    157         System.err.println("ServiceRack.process(String) Error: Couldn't parse request");
    158         System.err.println(xml_in);
     161        logger.error("Couldn't parse request");
     162        logger.error(xml_in);
    159163        return null;
    160164    }
     
    217221                c = c.getSuperclass();
    218222            } catch (SecurityException e) {
    219                 System.err.println("ServiceRack.process: security exception for finding method "+method_name);
     223                logger.error("security exception for finding method "+method_name);
    220224                error_string.append("ServiceRack.process: security exception for finding method "+method_name);
    221225            }
     
    227231               
    228232            } catch (Exception e) {
    229                 System.err.println("ServiceRack.process: Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
    230                 error_string.append("ServiceRack.process: Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
     233                logger.error("Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
     234                error_string.append("Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
    231235            }
    232236            } else {
    233             System.err.println("ServiceRack.process: method "+method_name+" not found for class "+this.getClass().getName());
     237            logger.error("method "+method_name+" not found for class "+this.getClass().getName());
    234238            error_string.append("ServiceRack.process: method "+method_name+" not found for class "+this.getClass().getName());
    235239            }
    236240           
    237241        } catch (ClassNotFoundException e) {
    238             System.err.println("ServiceRack error: Element class not found");
    239             error_string.append("ServiceRack error: Element class not found");
     242            logger.error("Element class not found");
     243            error_string.append("Element class not found");
    240244        }
    241245        if (response !=null) {
     
    243247        } else {
    244248            // add in a dummy response
    245             System.err.println("adding in an error element\n");
     249            logger.error("adding in an error element\n");
    246250            response = this.doc.createElement(GSXML.RESPONSE_ELEM);
    247251            GSXML.addError(this.doc, response, error_string.toString());
     
    321325    }
    322326    // else no format info
    323     System.err.println("ServiceRack describe request: no format info for "+to+".");
     327    logger.error("ServiceRack describe request: no format info for "+to+".");
    324328    return response;
    325329    }   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/XMLRetrieve.java

    r10093 r13124  
    1919import java.util.HashMap;
    2020
     21import org.apache.log4j.*;
    2122
    2223public class XMLRetrieve extends ServiceRack {
    2324
     25      static Category logger = Category.getInstance(org.greenstone.gsdl3.service.XMLRetrieve.class.getName());
    2426    protected static final String CONTENT_SERVICE = "DocumentContentRetrieve";
    2527    protected static final String METADATA_SERVICE = "DocumentMetadataRetrieve";
     
    4143        return false;
    4244    }
    43     System.out.println("configuring XMLRetrieve...");
     45    logger.info("configuring XMLRetrieve...");
    4446    // look for the parameters
    4547    Element param_list = (Element)GSXML.getChildByTagName(info, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
     
    167169    Element doc_list = (Element)GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    168170    if (doc_list == null) {
    169         System.err.println("XMLRetrieve.DocumentStructureRetrieve: no documents specified in the request. ");
     171        logger.error("no documents specified in the request. ");
    170172        return result;
    171173    }
     
    180182    }
    181183    if (!stylesheet.exists()) {
    182         System.err.println("XMLRetrieve.DocumentStructureRetrieve: couldn't find the stylesheet file to produce the table of contents:"+stylesheet.getPath());
     184        logger.error("couldn't find the stylesheet file to produce the table of contents:"+stylesheet.getPath());
    183185        return result;
    184186    }
     
    202204       
    203205        if (!doc_file.exists()) {
    204         System.err.println("XMLRetrieve.DocumentStructureRetrieve: couldn't find file in coll "+this.cluster_name +", file "+doc_name+".xml");
     206        logger.error("couldn't find file in coll "+this.cluster_name +", file "+doc_name+".xml");
    205207        } else {
    206208        try {
     
    208210            structure.appendChild(this.doc.importNode(toc, true));
    209211        } catch (Exception e) {
    210             System.err.println("XMLRetrieve.DocumentStructureRetrieve: couldn't transform the document to get the toc");
     212            logger.error("couldn't transform the document to get the toc");
    211213        }
    212214        }
     
    227229    Element doc_list = (Element)GSXML.getChildByTagName(request, GSXML.DOC_NODE_ELEM+GSXML.LIST_MODIFIER);
    228230    if (doc_list == null) {
    229         System.err.println("XMLRetrieve.DocumentMetadataRetrieve: no documents in the request");
     231        logger.error("no documents in the request");
    230232        return result;
    231233    }
     
    236238    Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER);
    237239    if (param_list == null) {
    238         System.err.println("XMLRetrieve.DocumentMetadataRetrieve: no metadata in the request");
     240        logger.error("no metadata in the request");
    239241        return result;
    240242    }
     
    275277       
    276278    if (!doc_file.exists()) {
    277         System.out.println("XMLRetrieve.loadDocument: couldn't find file in coll "+this.cluster_name +", file "+doc_name+".xml");
     279        logger.info("couldn't find file in coll "+this.cluster_name +", file "+doc_name+".xml");
    278280        return null;
    279281    }
     
    283285        the_doc = this.converter.getDOM(doc_file, this.document_encoding);
    284286    } catch (Exception e) {
    285         System.err.println("XMLRetrieve.loadDocument: couldn't create a DOM from file "+doc_file.getPath());
     287        logger.error("couldn't create a DOM from file "+doc_file.getPath());
    286288        return null;
    287289    }
     
    295297    String [] bits = node_id.split("\\.");
    296298    if (bits.length > 4) {
    297         System.err.println("XMLRetrieve.getSection: badly formatted node id ("+node_id +"), cant retrieve the section");
     299        logger.error("badly formatted node id ("+node_id +"), cant retrieve the section");
    298300        return null;
    299301    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/XSLTServices.java

    r10093 r13124  
    4646import java.net.URLDecoder;
    4747
     48import org.apache.log4j.*;
     49
    4850/**
    4951 * A ServiceRack class for XSLT query.
     
    6264  extends ServiceRack {
    6365 
     66    static Category logger = Category.getInstance(org.greenstone.gsdl3.service.XSLTServices.class.getName());
     67
    6468  // these strings must match what is found in the properties file
    6569  // the services on offer
     
    106110    }
    107111
    108       System.out.println("configuring XSLTServices");
     112      logger.info("configuring XSLTServices");
    109113      this.config_info = info;
    110114    try {
    111       System.out.println("XSLTService::configure() called with:");
     115      logger.info("called with:");
    112116      TransformerFactory transformerFactory = TransformerFactory.newInstance();
    113117      Element doc = (Element)info.getFirstChild();
     
    117121      transformer.transform(source,result);
    118122    } catch (Throwable t) {
    119       System.err.println("Error printing XML in XSLTService::configure()");
     123      logger.error("Error printing XML in XSLTService::configure()");
    120124    }
    121125    return true;   
     
    145149    response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
    146150   
    147     System.err.println("XSLTServices:should never get here. service type wrong:"+service);
     151    logger.error("should never get here. service type wrong:"+service);
    148152    GSXML.addError(this.doc, response,"XSLTServices:should never get here. service type wrong:"+service);
    149153    return response;
     
    172176
    173177    if (param_elem==null) {
    174     System.err.println("bad query request");
     178    logger.error("bad query request");
    175179    GSXML.addError(this.doc, response,"bad query request in XSLTServices");
    176180    return response;
     
    228232                       Character.MAX_VALUE);
    229233    } else {
    230       System.err.println("XSLTServices: bad alphabet name : "+ alphabet);
     234      logger.error("bad alphabet name : "+ alphabet);
    231235      GSXML.addError(this.doc, response,"XSLTServices: bad alphabet name : "+ alphabet);
    232236      stream = new GeneratedDocumentStream();
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/Dictionary.java

    r10941 r13124  
    2323import java.util.Enumeration;
    2424
     25import org.apache.log4j.*;
     26
    2527public class Dictionary {
     28
     29    static Category logger = Category.getInstance(org.greenstone.gsdl3.util.Dictionary.class.getName());
    2630
    2731    /** The locale of this dictionary. */
     
    4751        this.raw = ResourceBundle.getBundle(this.resource, this.locale);
    4852    } catch (Exception e) {
    49         //System.err.println("Dictionary: couldn't locate a resource bundle for "+resource);
     53        logger.debug("Dictionary: couldn't locate a resource bundle for "+resource);
    5054    }
    5155    }
     
    5761        this.raw = ResourceBundle.getBundle(this.resource, this.locale);
    5862    } catch (Exception e) {
    59         //System.err.println("Dictionary: couldn't locate a resource bundle for "+resource);
     63        logger.debug("Dictionary: couldn't locate a resource bundle for "+resource);
    6064    }
    6165    }
     
    8084        this.raw = ResourceBundle.getBundle(this.resource, this.locale);
    8185    } catch (Exception ex) {
    82         //System.err.println("Dictionary: couldn't locate a resource bundle for "+resource);
     86        logger.debug("Dictionary: couldn't locate a resource bundle for "+resource);
    8387    }
    8488   
     
    139143    }
    140144    catch (Exception e) {
    141         //System.err.println("Dictionary Error: couldn't find string for key:" + key +" in resource "+this.resource);
     145        logger.debug("Dictionary Error: couldn't find string for key:" + key +" in resource "+this.resource);
    142146        return null;
    143147    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GDBMWrapper.java

    r11278 r13124  
    55import au.com.pharos.gdbm.GdbmException;
    66
     7import org.apache.log4j.*;
     8
    79/** java wrapper class for gdbm - uses Java-GDBM written by Martin Pool
    810 * replaces gdbmclass in the old version
     
    1012
    1113public class GDBMWrapper {
     14
     15      static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GDBMWrapper.class.getName());
     16
    1217
    1318    // Values must match those from gdbm.h - uses the definitions from GdbmFile !
     
    3944        db_ = new GdbmFile(filename, mode);
    4045    } catch ( GdbmException e) { // the database wasn't opened or created
    41         System.err.println("GDBMWrapper: couldn't open database "+filename);
     46        logger.error("couldn't open database "+filename);
    4247        return false;
    4348    }
     
    5661    } catch (GdbmException e) {
    5762        // should never get here - close never actually throws an exception
    58         System.err.println("GDBMWrapper: error on close()");
     63        logger.error("error on close()");
    5964    }
    6065    }
     
    7277        s_info = (String)db_.fetch(main_key);
    7378    } catch (GdbmException e) {
    74         System.err.println("GDBMWrapper: couldn't get record");
     79        logger.error("couldn't get record");
    7580        return null;
    7681    }
    7782    if (s_info==null) {
    7883        // record not present
    79         System.err.println("GDBMWrapper: key "+main_key+" not present in db");
     84        logger.error("key "+main_key+" not present in db");
    8085        return null;
    8186    }
     
    8691    String value;
    8792    for (int i=0; i<lines.length; i++) {
    88         //System.out.println("line:"+lines[i]);
     93        logger.debug("line:"+lines[i]);
    8994        int a = lines[i].indexOf('<');
    9095        int b= lines[i].indexOf('>');
    9196        if (a==-1 || b==-1) {
    92         System.err.println("error: bad format in db");
     97        logger.error("bad format in db");
    9398        }
    9499        else {
    95100        key=lines[i].substring(a+1, b);
    96101        value=lines[i].substring(b+1);
    97         //System.out.println("key="+key+", val="+value);
     102        logger.debug("key="+key+", val="+value);
    98103        info.addInfo(key, value);
    99104
     
    165170    int p = oid.lastIndexOf('.');
    166171    if (p != oid.length()-3) {
    167         System.out.println("translateoid error: '.' is not the third to last char!!");
     172        logger.info("translateoid error: '.' is not the third to last char!!");
    168173        return oid;
    169174    }
     
    240245    DBInfo info = getInfo(doc_id);
    241246    if (info==null) {
    242         System.out.println("info is null!!");
     247        logger.info("info is null!!");
    243248        return top;
    244249    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSEntityResolver.java

    r10087 r13124  
    77import java.net.URL;
    88
     9import org.apache.log4j.*;
     10
    911// uses a class loader to find entities
    1012// The class loader to use can be set by setClassLoader(), otherwise it will use the class loader that loaded itself. For the Tomcat webapp, this will be the webapp class loader, not the system class loader. the webapp classloader knows about the classes in the WEB-INF/classes dir, the system classloader knows about the ones on the classpath. The system class loader is a parent to web app classloader, so this will be used as well.
     
    1416    ClassLoader class_loader = null;
    1517   
     18     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GSEntityResolver.class.getName());
     19
    1620    public void setClassLoader(ClassLoader loader) {
    1721    this.class_loader = loader;
     
    2024    public InputSource resolveEntity (String public_id, String system_id) {
    2125   
    22     //System.out.println("entity resolver for "+system_id);
     26    logger.debug("entity resolver for "+system_id);
    2327    String temp_id = system_id;
    2428    if (temp_id.startsWith("file://")) {
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r10899 r13124  
    3232import java.util.ArrayList;
    3333
     34import org.apache.log4j.*;
     35
    3436/**
    3537 * GSFile - utility class for Greenstone.
     
    4446
    4547public class GSFile {
     48
     49     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GSFile.class.getName());
    4650
    4751    /**  site config file path */
     
    312316        data = readFile(in_filename);
    313317    } catch (Exception e) {
    314         System.err.println("GSFile.base64EncodeFromFile: couldn't read the file");
     318        logger.error("couldn't read the file");
    315319    }
    316320    String encodedString = Base64.encode(data);
     
    326330       
    327331    } catch (Exception e) {
    328         System.err.println("GSFile.base64DecodeToFile: file opening/closing errors"+e.getMessage());
     332        logger.error("file opening/closing errors"+e.getMessage());
    329333        return false;
    330334    }
     
    369373    public static boolean copyFile(File source, File destination) {
    370374    if (!source.isFile()) {
    371         System.err.println("GSFile.copyFile(): "+source.getPath()+" is not a file!");
     375        logger.error(source.getPath()+" is not a file!");
    372376        return false;
    373377    }
     
    383387        out.close();
    384388    } catch (Exception e) {
    385         System.err.println("GSFile.copyFile(): something went wrong copying "+source.getPath()+" to "+destination.getPath());
    386         System.err.println("Exception: "+e.getMessage());
     389        logger.error("something went wrong copying "+source.getPath()+" to "+destination.getPath());
     390        logger.error("Exception: "+e.getMessage());
    387391        return false;
    388392    }
     
    428432            input[i].delete();
    429433        } catch (Exception e) {
    430             System.err.println("GSFile.moveDirectory: exception: "+e.getMessage());
     434            logger.error("exception: "+e.getMessage());
    431435            return false;
    432436        }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r11009 r13124  
    1717//import java.util.Locale;
    1818
     19import org.apache.log4j.*;
     20
    1921/** various functions for extracting info out of GS XML */
    2022public class GSXML {
     23
     24    static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GSXML.class.getName());
    2125
    2226    // greenstone xml elements
     
    210214
    211215    if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) {
    212         System.err.println("GSXML:paramList element should have been passed to extractParams, instead it was "+xml.getNodeName());
     216        logger.error("paramList element should have been passed to extractParams, instead it was "+xml.getNodeName());
    213217        return null;
    214218    }
     
    649653    for (int i=0; i<children.getLength(); i++) {
    650654        Node child = children.item(i);
    651         ///ystem.out.println("getnamed elem, node nmae="+child.getNodeName());
     655        logger.debug("getnamed elem, node nmae="+child.getNodeName());
    652656        if (child.getNodeName().equals(node_name)) {
    653657        if (((Element)child).getAttribute(attribute_name).equals(attribute_value))
     
    799803    if (e.getNodeType() == Node.TEXT_NODE){
    800804        System.out.println("text") ;
    801         //System.out.println(e.getNodeValue()) ;
     805        logger.debug(e.getNodeValue()) ;
    802806        return ;
    803807    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GlobalProperties.java

    r10677 r13124  
    55import java.io.InputStream;
    66
     7import org.apache.log4j.*;
     8
    79/** holds some global properties for the application. Read from a properties file */
    810public class GlobalProperties {
    911
     12
     13     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.GlobalProperties.class.getName());
    1014    private static Properties properties = null;
    1115    private static String properties_filename = "global.properties";
     
    4448        InputStream in = Class.forName("org.greenstone.gsdl3.util.GlobalProperties").getClassLoader().getResourceAsStream(properties_filename);
    4549        if (in != null) {
    46         System.err.println("loading global properties");
     50        logger.error("loading global properties");
    4751        properties.load(in);
    4852        in.close();
    4953        } else {
    50         System.err.println("couldn't load gloabl properties!");
     54        logger.error("couldn't load gloabl properties!");
    5155        }
    5256        gsdl3_home = properties.getProperty("gsdl3.home");
     
    5660        gsdl3_web_address = "http://"+ properties.getProperty("tomcat.server")+":"+ properties.getProperty("tomcat.port")+"/"+properties.getProperty("tomcat.context");
    5761    } catch (Exception e) {
    58         System.err.println("Exception trying to reload global.properties: "+e);
     62        logger.error("Exception trying to reload global.properties: "+e);
    5963    }
    6064   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/Processing.java

    r8437 r13124  
    33import java.io.InputStreamReader;
    44
     5import org.apache.log4j.*;
     6
    57public class Processing {
    68
     9      static Category logger = Category.getInstance(org.greenstone.gsdl3.util.Processing.class.getName());
     10 
    711      /** Determine if the given process is still executing. It does this by attempting to throw an exception - not the most efficient way, but the only one as far as I know
    812     * @param process the Process to test
     
    2630    static public int runProcess(String  command) {
    2731   
    28     System.err.println("executing command "+command);
     32    logger.error("executing command "+command);
    2933    int exit_value = -1;
    3034    try {
     
    7478       
    7579        // do something with the messages
    76         System.err.println("err>"+error_buffer.toString());
    77         System.err.println("out>"+output_buffer.toString());
     80        logger.error("err>"+error_buffer.toString());
     81        logger.error("out>"+output_buffer.toString());
    7882        // Ensure that any messages still remaining in the string buffers are fired off.
    7983        // Now display final message based on exit value
     
    8791        exit_value =  prcs.exitValue();
    8892    } catch (Exception e) {
    89         System.err.println("runProcess ERROR: "+e);
     93        logger.error(e);
    9094        return 1;
    9195    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/XMLConverter.java

    r10202 r13124  
    3737import java.io.FileReader;
    3838
     39import org.apache.log4j.*;
     40
    3941/** XMLConverter - utility class for greenstone
    4042 *
     
    4850 */
    4951public class XMLConverter {
     52
     53     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.XMLConverter.class.getName());
    5054
    5155    /** xerces parser */
     
    6771        this.parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
    6872    } catch (Exception e) {
    69         System.err.println("XMLConverter:exception "+e.getMessage());
     73        logger.error("exception "+e.getMessage());
    7074    }
    7175    }
     
    8993       
    9094    } catch (Exception e) {
    91         System.err.println("XMLConverter.getDOM(String): exception "+e.getMessage());
     95        logger.error("exception "+e.getMessage());
    9296    }
    9397    return null;
     
    107111
    108112    } catch (Exception e) {
    109         System.err.println("XMLConverter.getDOM(File): exception "+e.getMessage());
     113        logger.error("exception "+e.getMessage());
    110114        e.printStackTrace();
    111115    }
     
    126130
    127131    } catch (Exception e) {
    128         System.err.println("XMLConverter.getDOM(File): exception "+e.getMessage());
     132        logger.error("exception "+e.getMessage());
    129133    }
    130134    return null;
     
    268272        }
    269273        else {
    270         System.err.println("XMLConverter.getString(): Warning: Unhandled processing instruction " + nodeName);
     274        logger.error("Unhandled processing instruction " + nodeName);
    271275        }
    272276    }
     
    283287    // A type of node that is not handled yet
    284288    else {
    285         System.err.println("XMLConverter.getString(): Warning: Unknown node type: " + nodeType+" "+getNodeTypeString(nodeType));
     289        logger.error("Warning: Unknown node type: " + nodeType+" "+getNodeTypeString(nodeType));
    286290    }
    287291
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java

    r5663 r13124  
    4242import java.util.Map;
    4343import java.util.Iterator;
     44
     45import org.apache.log4j.*;
     46
    4447/** XMLTransformer - utility class for greenstone
    4548 *
     
    5053 */
    5154public class XMLTransformer {
     55
     56    static Category logger = Category.getInstance(org.greenstone.gsdl3.util.XMLTransformer.class.getName());
    5257
    5358  /** The transformer factory we're using */
     
    6974
    7075    } catch (Exception e) {
    71         System.err.println("XMLTransformer() exception "+e.getMessage());
     76        logger.error("exception "+e.getMessage());
    7277    }
    7378    }
     
    9499        return output.toString();
    95100    } catch (TransformerConfigurationException e) {
    96         System.err.println("XMLTransformer: couldn't create transformer object: "+e.getMessageAndLocation());
    97         System.err.println(e.getLocationAsString()); 
     101        logger.error("couldn't create transformer object: "+e.getMessageAndLocation());
     102        logger.error(e.getLocationAsString()); 
    98103        return "";
    99104    } catch (TransformerException e) {
    100         System.err.println("XMLTransformer: couldn't transform the source: " + e.getMessage());
     105        logger.error("couldn't transform the source: " + e.getMessage());
    101106        return "";
    102107    }   
     
    129134        return output.toString();
    130135    } catch (TransformerConfigurationException e) {
    131         System.err.println("XMLTransformer: couldn't create transformer object: "+e.getMessageAndLocation());
    132         System.err.println(e.getLocationAsString()); 
     136        logger.error("couldn't create transformer object: "+e.getMessageAndLocation());
     137        logger.error(e.getLocationAsString()); 
    133138        return "";
    134139    } catch (TransformerException e) {
    135         System.err.println("XMLTransformer: couldn't transform the source: " + e.getMessage());
     140        logger.error("couldn't transform the source: " + e.getMessage());
    136141        return "";
    137142    }   
     
    160165        return result.getNode().getFirstChild();
    161166    } catch (TransformerConfigurationException e) {
    162         System.err.println("XMLTransformer: couldn't create transformer object: "+e.getMessageAndLocation());
    163         System.err.println(e.getLocationAsString()); 
     167        logger.error("couldn't create transformer object: "+e.getMessageAndLocation());
     168        logger.error(e.getLocationAsString()); 
    164169        return null;
    165170    } catch (TransformerException e) {
    166         System.err.println("XMLTransformer: couldn't transform the source: " + e.getMessage());
     171        logger.error("couldn't transform the source: " + e.getMessage());
    167172        return null;
    168173    }   
     
    180185        return result.getNode().getFirstChild();
    181186    } catch (TransformerConfigurationException e) {
    182         System.err.println("XMLTransformer: couldn't create transformer object: "+e.getMessageAndLocation());
    183         System.err.println(e.getLocationAsString()); 
     187        logger.error("couldn't create transformer object: "+e.getMessageAndLocation());
     188        logger.error(e.getLocationAsString()); 
    184189        return null;
    185190    } catch (TransformerException e) {
    186         System.err.println("XMLTransformer: couldn't transform the source: " + e.getMessage());
     191        logger.error("couldn't transform the source: " + e.getMessage());
    187192        return null;
    188193    }   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r10783 r13124  
    55import java.text.SimpleDateFormat;
    66
     7import org.apache.log4j.*;
     8
    79/** a class to contain various static methods that are used by the xslt
    810 * stylesheets
    911 */
    1012public class XSLTUtil {
     13
     14     static Category logger = Category.getInstance(org.greenstone.gsdl3.util.XSLTUtil.class.getName());
    1115
    1216    /* some tests */
     
    5761    }
    5862    catch (Exception e){
    59         System.err.println("XSLTUtil.toUTF8: unsupported encoding");
     63        logger.error("unsupported encoding");
    6064        return orig.getBytes();
    6165    }
Note: See TracChangeset for help on using the changeset viewer.