Ignore:
Timestamp:
2012-10-16T21:12:31+13:00 (12 years ago)
Author:
ak19
Message:
  1. When purging documents from the fedora repository during import and buildcol, these documents are also removed from the Fedora GSearch index. Likewise, when documents are ingested into the Fedora repository during buildcol, these documents are also indexed by Fedora GSearch. 2. Added methods in g2futil.pm to be able to do this
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/g2f-buildcol.pl

    r26322 r26324  
    208208    # => Ingest individually!
    209209
     210    # set up fedoragsearch for updating the index upon ingesting documents
     211    my $fedoragsearch_webapp = &g2futil::gsearch_webapp_folder();   
     212
     213    # need the username and password preset in order to run fedoraGSearch's RESTClient script
     214    # this assumes that the fedoragsearch authentication details are the same as for fedora
     215    if (defined $fedoragsearch_webapp) {   
     216    $ENV{'fgsUserName'} = $options->{'username'};
     217    $ENV{'fgsPassword'} = $options->{'password'};
     218    }
     219
    210220    if (opendir(DIR, $export_dir)) {
    211221    closedir DIR;
     
    227237       
    228238        if ($dsinfo_status == 0) {
    229             print "  $pid being updated.\n";       
     239            # first remove the doc from the gsearch index before removing it from the fedora repository
     240            print "  deleting $pid from GSearch index\n";
     241            &g2futil::run_delete_from_index($fedoragsearch_webapp,$pid,$options) if defined $fedoragsearch_webapp;
     242
     243            print "  $pid being updated.\n";
    230244            &g2futil::run_purge($pid,$options);
    231245        }
     
    242256        print "Ingesting $docmets_filename\n";
    243257
    244         &g2futil::run_ingest($docmets_filename,$options);
     258        my $status = &g2futil::run_ingest($docmets_filename,$options);
     259
     260        # if the document was ingested into Fedora successfully, index it with GSearch next
     261        if($status == 0) {
     262        if(defined $hash_id) {
     263            my $pid = "$pid_namespace:$gs_col-$hash_id";
     264            # now update the fedoragsearch index with the newly ingested document
     265            &g2futil::run_update_index($fedoragsearch_webapp,$pid,$options) if defined $fedoragsearch_webapp;
     266        }
     267        }
     268
    245269        print STDERR "</Build>\n" if $gli;
    246270
Note: See TracChangeset for help on using the changeset viewer.