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
Location:
main/trunk/greenstone2/bin/script
Files:
2 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
  • main/trunk/greenstone2/bin/script/g2f-import.pl

    r26183 r26324  
    209209    print "* Updating existing Greenstone $gs_col objects from Fedora $pid_namespace\n";
    210210        print "***\n";
     211
     212    # set up fedoragsearch for updating the index upon ingesting documents
     213    my $fedoragsearch_webapp = &g2futil::gsearch_webapp_folder();
     214   
     215    # need the username and password preset in order to run fedoraGSearch's RESTClient script
     216    # this assumes that the fedoragsearch authentication details are the same as for fedora
     217    if (defined $fedoragsearch_webapp) {   
     218        $ENV{'fgsUserName'} = $options->{'username'};
     219        $ENV{'fgsPassword'} = $options->{'password'};
     220    }
    211221
    212222    # readdir
     
    243253
    244254        if ($dsinfo_status == 0) {
     255            # first remove the doc from the gsearch index before removing it from the fedora repository
     256            print "  deleting $pid from GSearch index\n";
     257            &g2futil::run_delete_from_index($fedoragsearch_webapp,$pid,$options) if defined $fedoragsearch_webapp;
     258
    245259            print "  $pid being updated.\n";       
    246260            &g2futil::run_purge($pid,$options);
Note: See TracChangeset for help on using the changeset viewer.