Project

General

Profile

« Previous | Next » 

Revision 5021

Added by Duane Costa over 15 years ago

Bug 3835: Design and implement OAI-PMH compliant harvest subsystem. Develop harvester component of the OAI-PMH harvester/provider pair. * Terminate harvest if login failed. * Add runHarvester.sh shell script

View differences:

lib/oaipmh/runHarvester.sh
1
METACAT_CLASSES=$METACAT_HOME/build/classes
2
METACAT_LIB=$METACAT_HOME/lib
3
JDBC=$METACAT_HOME/build/war/lib/jdbc.jar:$METACAT_LIB/postgresql-8.0-312.jdbc3.jar
4
LIB_JARS=$METACAT_LIB/xercesImpl.jar:$METACAT_LIB/utilities.jar:$METACAT_LIB/log4j-1.2.12.jar:$METACAT_LIB/xalan.jar
5
export CLASSPATH=$METACAT_CLASSES:$JDBC:$LIB_JARS
6
cd $METACAT_CLASSES
7
java edu.ucsb.nceas.metacat.oaipmh.harvester.OaipmhHarvester $*
src/edu/ucsb/nceas/metacat/oaipmh/harvester/OaipmhHarvester.java
552 552
   * @param  ldapDN   the LDAP distinguished name, e.g.
553 553
   *                  "uid=dryad,o=LTER,dc=ecoinformatics,dc=org"
554 554
   * @param  ldapPwd  the corresponding LDAP password string
555
   * 
556
   * @return  loginSuccess, true if login succeeded, else false
555 557
   */
556
  private static void metacatLogin(String ldapDN, String ldapPwd) {
557
      try {
558
        logger.info("Logging in to Metacat: " + ldapDN);
559
        String response = metacatClient.login(ldapDN, ldapPwd);
560
        logger.info("Metacat login response: " + response);
561
      } 
562
      catch (MetacatInaccessibleException e) {
563
        logger.error("Metacat login failed." + e.getMessage());
564
      } 
565
      catch (Exception e) {
566
        logger.error("Metacat login failed." + e.getMessage());
567
      }
558
  private static boolean metacatLogin(String ldapDN, String ldapPwd) {
559
    boolean loginSuccess = false;
560
    
561
    try {
562
      logger.info("Logging in to Metacat: " + ldapDN);
563
      String response = metacatClient.login(ldapDN, ldapPwd);
564
      logger.info("Metacat login response: " + response);
565
      loginSuccess = true;
566
    } 
567
    catch (MetacatInaccessibleException e) {
568
      logger.error("Metacat login failed." + e.getMessage());
569
    } 
570
    catch (Exception e) {
571
      logger.error("Metacat login failed." + e.getMessage());
572
    }
573
    
574
    return loginSuccess;
568 575
  }
569 576
  
570 577
  
......
774 781
  {
775 782
    logger.info("Starting OAI-PMH Harvester.");
776 783
    if ((dn != null) && (password != null)) {
777
      metacatLogin(dn, password);
784
      boolean loginSuccess = metacatLogin(dn, password);
785
      
786
      // Terminate harvester execution if login failed
787
      if (!loginSuccess) { 
788
        logger.warn("Terminating OAI-PMH Harvester execution due to login failure.");
789
        return; 
790
      } 
778 791
    }
779 792
    else {
780 793
      logger.error("Distinguished name (-dn) and/or password (-password) " +
......
818 831
    }
819 832

  
820 833
    metacatLogout();
821
    logger.info("Shutting down OAI-PMH Harvester.");
834
    logger.info("Harvest completed. Shutting down OAI-PMH Harvester.");
822 835
  }
823 836
  
824 837
  

Also available in: Unified diff