Changeset 28885


Ignore:
Timestamp:
2014-03-10T13:52:30+13:00 (10 years ago)
Author:
kjdon
Message:

handle reset request - reconfigure the message router and then reload the set info - which queries the message router to find out what stes (collections0 are available

File:
1 edited

Legend:

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

    r28882 r28885  
    7676  /** a hash of super set-> collection list */
    7777  protected HashMap<String, Vector<String>> super_coll_map = null;
     78  /** store the super coll elements for convenience */
     79  HashMap<String, Element> super_coll_data = null;
    7880  /** The identify response */
    7981  protected Element identify_response = null;
     
    119121   
    120122    repository_id = getRepositoryIdentifier();
     123    configureSuperSetInfo();
    121124    if (!configureSetInfo()) {
    122125      // there are no sets
     
    134137  // assuming that sets are static. If collections change then the servlet
    135138  // should be restarted.
    136   private boolean configureSetInfo() {
     139  private boolean configureSuperSetInfo() {
    137140    // do we have any super colls listed in web/WEB-INF/classes/OAIConfig.xml?
    138141    // Will be like
     
    145148    // whether they are part of the super set or not.
    146149    NodeList super_coll_list = this.oai_config.getElementsByTagName(OAIXML.OAI_SUPER_SET);
    147     HashMap<String, Element> super_coll_data = new HashMap<String, Element>();
     150    this.super_coll_data = new HashMap<String, Element>();
    148151    if (super_coll_list.getLength() > 0) {
    149152      this.has_super_colls = true;
     
    154157      String name = GSXML.getNodeText(set_spec);
    155158      if (!name.equals("")) {
    156         super_coll_data.put(name, super_coll);
     159        this.super_coll_data.put(name, super_coll);
    157160        logger.error("adding in super coll "+name);
    158161      }
     
    160163      }
    161164   
    162       if (super_coll_data.size()==0) {
     165      if (this.super_coll_data.size()==0) {
    163166    this.has_super_colls = false;
    164167      }
     
    167170      this.super_coll_map = new HashMap<String, Vector<String>>();
    168171    }
     172    return true;
     173   
     174  }
     175  private boolean configureSetInfo() {
    169176    this.set_set = new HashSet<String>();
    170177
    171     // next, we get a list of all the OAI enabled collections
     178    // First, we get a list of all the OAI enabled collections
    172179    // We get this by sending a listSets request to the MR
    173180    Document doc = this.converter.newDOM();
     
    251258      logger.error("found super coll, "+set_spec);
    252259      // check that it is a valid one from config
    253       if (this.has_super_colls == true && super_coll_data.containsKey(set_spec)) {
     260      if (this.has_super_colls == true && this.super_coll_data.containsKey(set_spec)) {
    254261        Vector <String> subcolls = this.super_coll_map.get(set_spec);
    255262        if (subcolls == null) {
     
    260267          this.super_coll_map.put(set_spec, subcolls);
    261268          // the first time a supercoll is mentioned, add into the set list
    262           logger.error("finding the set info "+this.converter.getPrettyString(super_coll_data.get(set_spec)));
    263           listsets_element.appendChild(GSXML.duplicateWithNewName(listsets_doc, super_coll_data.get(set_spec), OAIXML.SET, true));
     269          logger.error("finding the set info "+this.converter.getPrettyString(this.super_coll_data.get(set_spec)));
     270          listsets_element.appendChild(GSXML.duplicateWithNewName(listsets_doc, this.super_coll_data.get(set_spec), OAIXML.SET, true));
    264271        }
    265272        // add this collection to the list for the super coll
     
    276283  }
    277284
     285  protected void resetMessageRouter() {
     286    // we just need to send a configure request to MR
     287    Document doc = this.converter.newDOM();
     288    Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
     289    Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, "", null);
     290    mr_request_message.appendChild(mr_request);
     291   
     292    Element system = doc.createElement(GSXML.SYSTEM_ELEM);
     293    mr_request.appendChild(system);
     294    system.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_CONFIGURE);
     295
     296    Element response = (Element) this.mr.process(mr_request_message);
     297    logger.error("configure response = "+this.converter.getPrettyString(response));
     298  }
    278299  /** process using strings - just calls process using Elements */
    279300  public String process(String xml_in) {
     
    315336      return OAIXML.createErrorMessage(OAIXML.BAD_ARGUMENT, "Internal messaging error");
    316337    }
     338
     339    // special case, reset=true for reloading the MR and recept data
     340    String reset = request.getAttribute("reset");
     341    if (!reset.equals("")) {
     342      resetMessageRouter();
     343      configureSetInfo();
     344      return OAIXML.createResetResponse(true);
     345    }
     346
     347   
    317348    //At this stage, the value of 'to' attribute of the request must be the 'verb'
    318349    //The only thing that the oai receptionist can be sure is that these verbs are valid, nothing else.
     
    844875    if (this.identify_response != null) {
    845876      // we have already created it
    846       return this.identify_response;
     877      return getMessage(this.identify_response.getOwnerDocument(), this.identify_response);
    847878    }
    848879    Document doc = this.converter.newDOM();
Note: See TracChangeset for help on using the changeset viewer.