Changeset 28802 for gs2-extensions


Ignore:
Timestamp:
2014-01-30T15:11:04+13:00 (10 years ago)
Author:
ak19
Message:

Removed 'die' statements in favour of rint to STDERR to allow the perl process to continue, rather than stopping abruptly.

Location:
gs2-extensions/apache-jena/trunk/src/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/apache-jena/trunk/src/perllib/jenaTDBBuilder.pm

    r28410 r28802  
    9898
    9999    }
    100 
     100   
    101101    # Run the docs through the jenaTDB document processor
    102102
    103103    $self->{'buildproc'}->set_mode ('text');
    104104    $self->{'buildproc'}->reset();
     105
     106    # If '-removeold' in effect (i.e. *not* keepold), then clear out
     107    # the triple-store graph for this collection
     108
     109    if (!$self->{'keepold'}) {
     110    my $collection = $self->{'collection'};
     111    my $cmd = "gs-triplestore-reset $collection";
     112       
     113    my $status = system($cmd);
     114    if ($status == 0) {
     115        print $outhandle "    => removeold: Deleting triplestore graph for $collection\n";
     116    }
     117    else {
     118        print STDERR "Error: failed to run:\n  $cmd\n$!\n";
     119        print STDERR "       Graph has not been deleted\n";
     120    }
     121    }
     122
    105123    &plugin::begin($self->{'pluginfo'}, $self->{'source_dir'},
    106124           $self->{'buildproc'}, $self->{'maxdocs'});
  • gs2-extensions/apache-jena/trunk/src/perllib/jenaTDBBuildproc.pm

    r28488 r28802  
    148148    }
    149149   
    150     open(*XMLWRITER, $cmd)
    151     or die "can't open pipe to xslt: $!";
    152    
    153     $self->{'xslt_writer'} = *XMLWRITER;
    154 
    155     print XMLWRITER "<?DocStart?>\n";       
    156     print XMLWRITER "$output_file_name\n";
    157  
     150    if (!open(*XMLWRITER, $cmd)) {
     151    print STDERR "Can't open pipe to xslt: $!";
     152    print STDERR "Command was:\n  $cmd\n";
     153    $self->{'xslt_writer'} = undef;
     154    }
     155    else {
     156    $self->{'xslt_writer'} = *XMLWRITER;
     157   
     158    print XMLWRITER "<?DocStart?>\n";       
     159    print XMLWRITER "$output_file_name\n";
     160    }
    158161  }
    159162 
     
    163166  my $self = shift @_;
    164167
    165  
    166168  return unless defined $self->{'xslt_writer'} ;
    167169   
     
    203205    $self->open_xslt_pipe($tmp_doc_filename_cc, $xslt_filename); # stops with error if not able to open pipe
    204206
    205     my $outhandler = $self->{'xslt_writer'};
    206     binmode($outhandler,":utf8");
    207 
    208     my $section_text = &docprint::get_section_xml($doc_obj,$doc_obj->get_top_section());
     207    my $xml_outhandler = $self->{'xslt_writer'};
     208
     209    if (defined $xml_outhandler) {
     210    binmode($xml_outhandler,":utf8");
     211
     212    my $section_text = &docprint::get_section_xml($doc_obj,$doc_obj->get_top_section());
    209213
    210214#    $section_text =~ s/[\r\n]+$//s; # remove very last newline char
     
    229233#    exit -1;
    230234
    231     $section_text =~ s/(<Metadata[^>]*>)(.*?)(<\/Metadata>)/&make_ttl_safe($1,$2,$3)/gse;
     235    $section_text =~ s/(<Metadata[^>]*>)(.*?)(<\/Metadata>)/&make_ttl_safe($1,$2,$3)/gse;
    232236
    233237## $1&make_ttl_safe($2)$3
     
    236240
    237241
    238     print $outhandler $section_text;
     242    print $xml_outhandler $section_text;
     243    }
    239244
    240245    $self->close_xslt_pipe();
    241246
    242     # now feed to generated file to jena's (TDB) tripple store
     247    # now feed the generated file to jena's (TDB) tripple store
    243248
    244249    my $outhandle = $self->{'outhandle'};
Note: See TracChangeset for help on using the changeset viewer.