Ignore:
Timestamp:
2012-05-11T22:10:15+12:00 (12 years ago)
Author:
ak19
Message:

SystemAction now supports pinging on a collection with ?a=s&sa=ping&st=collection&sn=colName

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r25571 r25580  
    570570  }
    571571 
     572  // testing whether a collection (or more generally, a module) is active
     573  protected boolean pingModule(String name) {
     574    // module (including collection) would have been added to module_map
     575    // if activated, and removed from map if deactivated.
     576    // The this.collection_list Element would contain the collection too,
     577    // but the following check seems to be more generally useful
     578    return this.module_map.containsKey(name);   
     579  }
     580 
    572581  /** creates and configures a new collection
    573582      if this is done for a reconfigure, the collection should be deactivated first.
     
    835844    return false;
    836845  }
    837  
     846   
    838847  protected boolean deactivateModule(String type, String name) {
    839848   
     
    974983        Element elem = (Element)commands.item(i);
    975984        String action = elem.getAttribute(GSXML.TYPE_ATT);
    976         if (action.equals(GSXML.SYSTEM_TYPE_PING)) {
    977             Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM,  "Ping succeeded.");
     985       
     986        if (action.equals(GSXML.SYSTEM_TYPE_PING)) { // ?a=s&sa=ping or ?a=s&sa=ping(&st=collection)&sn=colname
     987                       
     988            String message = ""; // will be creating the same messages as in GS2's recept/pingaction.cpp
     989            String module_name = elem.getAttribute(GSXML.SYSTEM_MODULE_NAME_ATT);
     990            String module_type = elem.getAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT);           
     991           
     992            if(module_name.equals("")) { // server-level ping               
     993                message = "Ping succeeded.";
     994            } else { // ping at collection level
     995                if(pingModule(module_name)) {                   
     996                    message = "Ping for " + module_name + " succeeded.";
     997                } else {
     998                    message = "Ping for " + module_name + " did not succeed.";
     999                }
     1000            }
     1001            Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, message);
    9781002            response.appendChild(s);
    9791003        }
    980         //if (action.equals(GSXML.SYSTEM_TYPE_ISPERSISTENT)) {
     1004        //else if (action.equals(GSXML.SYSTEM_TYPE_ISPERSISTENT)) {
    9811005        //  Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM,  "Persistent: true.");
    9821006        //  response.appendChild(s);
Note: See TracChangeset for help on using the changeset viewer.