Changeset 31912


Ignore:
Timestamp:
2017-08-21T18:03:37+12:00 (7 years ago)
Author:
ak19
Message:

Now GS3 tries to obtain the _earliesttimestamp entry of the oai-inf.db for each collection to, work out the earliest among them to be the earliest timestamp of the repository. For each collection, if there is no such entry or the oai-inf db doesn't exist or can't be accessed, the collection falls back to using the value in the build config file as before. Also as before, if that doesn't exist either, it uses the lastmod date of the collection (I think also taken from build config) as the next fallback value.

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/OAICollection.java

    r29265 r31912  
    150150      // pass the xml node to the service for configuration
    151151      if (this.oai_service_rack.configure(oai_service_xml, extra_info)) {
     152
     153          // once we've configured the OAIPMH service, we can use the OAIPMH service to
     154          // retrieve the earliest timestamp of the collection from the oai-inf db and
     155          // overwrite Collection.earliestDatestamp with it.
     156          long earliestTimestamp = this.oai_service_rack.getEarliestTimestamp();
     157          if(earliestTimestamp == -1) {
     158          //this.earliestDatestamp = -1;
     159          logger.warn("No OAI timestamp for collection " + this.cluster_name
     160                  + ". Falling back to using its earliestDatestamp from build config: " + this.earliestDatestamp);
     161          } else {
     162          this.earliestDatestamp = earliestTimestamp; // milliseconds
     163          }
     164         
    152165       
    153166        // find out the supported service types for this service module
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/OAIReceptionist.java

    r31229 r31912  
    239239    // send to MR
    240240    msg_node = mr.process(message);
    241     logger.info("*** " + XMLConverter.getPrettyString(msg_node));
     241    //logger.info("*** " + XMLConverter.getPrettyString(msg_node));
    242242    NodeList response_list =  ((Element)msg_node).getElementsByTagName(GSXML.RESPONSE_ELEM);
    243243    for (int c=0; c<response_list.getLength(); c++) {
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/OAIPMH.java

    r31911 r31912  
    233233  }
    234234
     235    /**
     236     * @return the associated OAICollection's OAI_EARLIEST_TIMESTAMP_OID record's
     237     * OAI_INF_TIMESTAMP field from the collection's oai-inf.db IN MILLISECONDS
     238     */
     239    public long getEarliestTimestamp() {
     240    long timestamp = -1;
     241   
     242    DBInfo oai_info = null;
     243    if(oaiinf_db != null) {
     244        // get internal record containing the earliest timestamp of the collection
     245        oai_info = this.oaiinf_db.getInfo(OAIXML.OAI_EARLIEST_TIMESTAMP_OID);
     246        if (oai_info == null) {
     247        logger.warn("Can't get collection " + this.cluster_name + "'s earliest timestamp from oai-inf db. No entry for 'OID' " + OAIXML.OAI_EARLIEST_TIMESTAMP_OID + " in the db.");       
     248        } else {
     249        timestamp = Long.parseLong(oai_info.getInfo(OAIXML.OAI_INF_TIMESTAMP)) * 1000; // stored in seconds, so x1000 to  convert to milliseconds
     250        //logger.info("@@@ found earliest OAI timestamp for collection " + this.coll_name + ": " + timestamp + " (ms)");
     251        }
     252    }
     253    return timestamp;
     254    }
     255   
    235256  protected Element findNamedMetadataFormat(Element list_meta_formats, String prefix) {
    236257    NodeList formats = list_meta_formats.getElementsByTagName(OAIXML.METADATA_FORMAT);
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/OAIResumptionToken.java

    r28880 r31912  
    161161    if (token.indexOf(":") != -1) {
    162162      token = token.substring(0, token.indexOf(":"));
    163       logger.error("looking up "+token);
     163      logger.info("looking up "+token);
    164164    }
    165165    if (stored_tokens.containsKey(token)) {
     
    174174    if (token.indexOf(":") != -1) {
    175175      base_name = token.substring(0, token.indexOf(":"));
    176       logger.error("getting data for "+base_name);
     176      logger.info("getting data for "+base_name);
    177177    }
    178178    HashMap<String, String> data = new HashMap<String, String>(stored_tokens.get(base_name));
    179179    if (data == null) {
    180       logger.error("data was null!!");
     180      logger.warn("data was null!!");
    181181      return null;
    182182    }
     
    211211    Iterator<Map.Entry<String,Long>> i = token_set.iterator();
    212212    int size = expiration_data.size();
    213     logger.error("start tokens "+size);
     213    logger.info("start tokens "+size);
    214214    Long time_now = System.currentTimeMillis();
    215215    while (i.hasNext()==true) {
     
    218218      Long exp = entry.getValue();
    219219      if (exp < time_now) {
    220     logger.error("token "+key+" is expired, "+ OAIXML.getTime(exp));
     220    logger.info("token "+key+" is expired, "+ OAIXML.getTime(exp));
    221221    i.remove();
    222222    // also remove the token from the stored tokens
     
    225225    }
    226226    size = expiration_data.size();
    227     logger.error("end tokens "+size);
     227    logger.info("end tokens "+size);
    228228  }
    229229
     
    242242      }
    243243    } catch (Exception e) {
    244       logger.error("couldn't find or ResumptionToken.xml "+e.getMessage());
     244      logger.error("couldn't find or work with ResumptionToken.xml "+e.getMessage());
    245245    }
    246246    // if we have got here, have't managed to load file via class loader -
     
    287287    clearExpiredTokens();
    288288    if (resumption_token_file == null) {
    289       logger.error("no available resumption token file, not storing tokens");
     289      logger.warn("no available resumption token file, not storing tokens");
    290290      return false;
    291291    }
Note: See TracChangeset for help on using the changeset viewer.