Changeset 8079


Ignore:
Timestamp:
2004-08-26T16:54:42+12:00 (20 years ago)
Author:
davidb
Message:

docsave.pm had been saving both GA and METS format. if-statement added to
choose one or other based on -saveas flag.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/docsave.pm

    r7902 r8079  
    123123        my $short_mets_doc_file=&util::filename_cat ($doc_dir, "docmets.xml");
    124124   
    125 
    126     if (!open (OUTDOC, ">$doc_file")) {
    127         print $outhandle "docsave::process could not write to file $doc_file\n";
     125    my $save_as = $self->{'saveas'};
     126
     127    if ($save_as eq "GA") {
     128        if (!open (OUTDOC, ">$doc_file")) {
     129        print $outhandle "docsave::process could not write to file $doc_file\n";
     130        return;
     131        }
     132       
     133        # save this document
     134        $self->output_xml_header('docsave::OUTDOC');
     135        $doc_obj->output_section('docsave::OUTDOC', $doc_obj->get_top_section());
     136        $self->output_xml_footer('docsave::OUTDOC');
     137
     138        close OUTDOC;
     139    }
     140    elsif ($save_as eq "METS") {
     141        # save the document without metadata:doctxt.xml
     142
     143        if (!open(OUTDOC_TXT, ">$doc_txt_file")){
     144        print $outhandle "docsave::process could not write to file $doc_mets_file\n";
     145        return;
     146        }
     147
     148        $self->output_txt_xml_header('docsave::OUTDOC_TXT');
     149        $doc_obj->output_txt_section('docsave::OUTDOC_TXT', $doc_obj->get_top_section());
     150        #$self->output_txt_xml_footer('docsave::OUTDOC_TXT');
     151               
     152        # Convert doctxt.xml file to docmets.xml
     153        if (!open(OUTDOC_METS,">$doc_mets_file")){
     154        print $outhandle "docsave::process could not write to file $doc_mets_file\n";
     155        return;
     156        }
     157       
     158        $self->output_mets_xml_header('docsave::OUTDOC_METS', $OID);
     159        $doc_obj->output_mets_section('docsave::OUTDOC_METS',$doc_obj->get_top_section(), $working_dir);
     160        $self->output_mets_xml_footer('docsave::OUTDOC_METS');
     161
     162        close OUTDOC_TXT;
     163        close OUTDOC_METS;
     164    }
     165    else {
     166        print $outhandle "docsave::process unrecognised saveas type, $save_as\n";
    128167        return;
    129168    }
    130 
    131     # save this document
    132     $self->output_xml_header('docsave::OUTDOC');
    133     $doc_obj->output_section('docsave::OUTDOC', $doc_obj->get_top_section());
    134     $self->output_xml_footer('docsave::OUTDOC');
    135 
    136         #***save the document without metadata:doctxt.xml: Chi-Yu Huang
    137 
    138     if (!open(OUTDOC_TXT, ">$doc_txt_file")){
    139             print $outhandle "docsave::process could not write to file $doc_mets_file\n";
    140             return;
    141         }
    142 
    143         $self->output_txt_xml_header('docsave::OUTDOC_TXT');
    144         $doc_obj->output_txt_section('docsave::OUTDOC_TXT', $doc_obj->get_top_section());
    145     #$self->output_txt_xml_footer('docsave::OUTDOC_TXT');
    146                
    147         #***Convert doctxt.xml file to docmets.xml: Chi-Yu Huang
    148         if (!open(OUTDOC_METS,">$doc_mets_file")){
    149         print $outhandle "docsave::process could not write to file $doc_mets_file\n";
    150             return;
    151     }
    152          
    153         $self->output_mets_xml_header('docsave::OUTDOC_METS', $OID);
    154         $doc_obj->output_mets_section('docsave::OUTDOC_METS',$doc_obj->get_top_section(), $working_dir);
    155         $self->output_mets_xml_footer('docsave::OUTDOC_METS');
    156 
    157         close OUTDOC;
    158         close OUTDOC_TXT;
    159     close OUTDOC_METS;
    160169
    161170    if ($self->{'gzip'}) {
Note: See TracChangeset for help on using the changeset viewer.