Ignore:
Timestamp:
2019-02-28T22:00:57+13:00 (5 years ago)
Author:
ak19
Message:

Second and final part of fixing up OAI stuff so that there's no lock on the index db by OAI servlet side when a collection is being rebuilt. The bug was that the OAI servlet side would still keep a filelock on the db (index col db and etc oai-inf db, to be precise) when a collection was deactivated before moving build to index during the activate.pl stage. That's because the OAIMessageRouter does not responde to (de)activate messages sent to the regular library servlet's MessageRouter. This commit: Getting servercontrol.pm of activate.pl to send a request to (de)activate a collection to the OAIMessageRouter was far more involved: although OAIMessageRouter inherits from MessageRouter, it did not recognise the (de)activate query params because it specifically only recognises OAI verbs like Identify and the special case of 'reset' sent to the OAIMessageRouter. So added in pathways for activate and deactivate to be recognised and processed. Now servercontrol.pm will send (de)activate requests to both the MessageRouter and the OAIMessageRouter. And there's further support for if a collection is not an OAICollection (not part of the list of collections maintained by OAIReceptionist). What I don't have working, is that the collection is still enumerated by ListSets of the OAI servlet whereas attempting to view records and identifiers of the deactivated set fails. This misbehaviour doesn't impact rebuilding with activate.pl since it both deactivates then activates a collection, so a collection is not meant to remain in the deactivated state. The fix may be more complicated than removing the collection from OAIReceptionist's list of sets, since the OAI side deals with supercollections etc when it first loads OAICollections. So any fix has to take that into account.

File:
1 edited

Legend:

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

    r31915 r32830  
    297297    logger.info("*** configure response = "+XMLConverter.getPrettyString(response));
    298298  }
     299 
     300  protected boolean activateOrDeactivateCollection(String collName, int activationState) {
     301    // Send a request like: a=s&sa=<a|d>&st=collection&sn=<collName>
     302    Document doc = XMLConverter.newDOM();
     303    Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
     304    Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, "", null);
     305    mr_request_message.appendChild(mr_request);
     306   
     307    Element system = doc.createElement(GSXML.SYSTEM_ELEM);
     308    mr_request.appendChild(system);
     309    if(activationState == OAIXML.ACTIVATION) {
     310        system.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_ACTIVATE);
     311    } else {
     312        system.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_DEACTIVATE);
     313    }
     314    system.setAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT, GSXML.COLLECTION_ELEM);
     315    system.setAttribute(GSXML.SYSTEM_MODULE_NAME_ATT, collName);
     316
     317    Element response = (Element) this.mr.process(mr_request_message);
     318    logger.info("*** (de)activate response = "+XMLConverter.getPrettyString(response));
     319   
     320    boolean success = false;
     321    NodeList elements = response.getElementsByTagName(GSXML.STATUS_ELEM);
     322    if(elements.getLength() <= 0) {
     323        logger.error("***** No result status");
     324        return false;
     325    }
     326   
     327    String result = GSXML.getNodeText((Element)elements.item(0));
     328    if(result.contains("could not be")) { // could not be (de)activated
     329        return false;
     330    } else {
     331        return true;
     332    }
     333  }
     334 
    299335  /** process using strings - just calls process using Elements */
    300336  public String process(String xml_in) {
     
    337373    }
    338374
     375    // Special cases: certain non-OAI commands/non-verbs are recognised
    339376    // special case, reset=true for reloading the MR and recept data
    340377    String reset = request.getAttribute("reset");
     
    344381      return OAIXML.createResetResponse(true);
    345382    }
    346 
     383   
     384    // special case 2: activate=<collname> or deactivate=<collname> can be passed to oaiserver servlet too
     385    if (request.hasAttribute(GSXML.SYSTEM_TYPE_ACTIVATE)) {     
     386        String collname = request.getAttribute(GSXML.SYSTEM_TYPE_ACTIVATE);
     387        // don't bother activating if it's not an OAI collection
     388        if (!this.set_set.contains(collname)) {
     389            return OAIXML.createDeActivationOfNonOAICollResponse(OAIXML.ACTIVATION, collname);
     390        }
     391        boolean success = activateOrDeactivateCollection(collname, OAIXML.ACTIVATION);
     392        return OAIXML.createActivationStateResponse(success, OAIXML.ACTIVATION, collname);
     393    } else if (request.hasAttribute(GSXML.SYSTEM_TYPE_DEACTIVATE)) {
     394        String collname = request.getAttribute(GSXML.SYSTEM_TYPE_DEACTIVATE);
     395        // don't bother deactivating if it's not an OAI collection
     396        if (!this.set_set.contains(collname)) {
     397            return OAIXML.createDeActivationOfNonOAICollResponse(OAIXML.DEACTIVATION, collname);
     398        }
     399        boolean success = activateOrDeactivateCollection(collname, OAIXML.DEACTIVATION);
     400        return OAIXML.createActivationStateResponse(success, OAIXML.DEACTIVATION, collname);
     401    }
    347402   
    348403    //At this stage, the value of 'to' attribute of the request must be the 'verb'
Note: See TracChangeset for help on using the changeset viewer.