Changeset 25891

Show
Ignore:
Timestamp:
03.07.2012 16:28:22 (7 years ago)
Author:
sjm84
Message:

Fixed a bug that wiped out doc.xml files if metadata was changed at the root level

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/metadataaction.pm

    r25558 r25891  
    725725    my $metaname = $parser->{'parameters'}->{'metaname'}; 
    726726    my $metamode = $parser->{'parameters'}->{'metamode'}; 
     727     
     728    print STDERR "**** IN METADATA \n"; 
    727729     
    728730    my $opt_doc_secnum = $parser->{'parameters'}->{'secnum'}; 
     
    763765                $parser->{'parameters'}->{'metamode'} = "done"; 
    764766            } 
    765             elsif(defined $parser->{'parameters'}->{'prevmetavalue'} && $parser->{'parameters'}->{'prevmetavalue'} == $attrHash->{'_content'}) 
     767            elsif(defined $parser->{'parameters'}->{'prevmetavalue'} && $parser->{'parameters'}->{'prevmetavalue'} eq $attrHash->{'_content'}) 
    766768            { 
    767769                my $metavalue = $parser->{'parameters'}->{'metavalue'}; 
     
    782784    my $metamode = $parser->{'parameters'}->{'metamode'}; 
    783785 
     786    print STDERR "**** IN DESCRIPTION! \n"; 
     787     
    784788    # Accumulate the metadata 
    785789    # NOTE: This appends new metadata element to all description fields. 
    786790    # If there are multiple Sections/SubSections, the new metadata block will get appended to all of them 
    787     if (($metamode eq "accumulate") || ($metamode eq "override")) { 
     791    if (($metamode eq "accumulate")) { 
     792        print STDERR "**** ACCUMULATE! \n"; 
    788793        # If get to here and metamode is override, the this means there  
    789794        # was no existing value to overide => treat as an append operation 
     
    802807        my $description_content = $attrHash->{'_content'}; 
    803808     
    804         ##  print STDERR "**** appending to doc.xml\n"; 
     809        print STDERR "**** appending to doc.xml\n"; 
    805810 
    806811        if (ref($description_content)) { 
     
    815820        $parser->{'parameters'}->{'metamode'} = "done"; 
    816821    } 
     822    else { 
     823        print STDERR "**** NOT ACCUMULATE?!? \n"; 
     824    } 
    817825 
    818826    # RAW is [$tagname => $attrHash] not $tagname => $attrHash!! 
     
    827835    my $new_depth = scalar(@$contextArray); 
    828836 
     837    print STDERR "**** START SECTION \n"; 
     838     
    829839    if ($new_depth == 1) { 
    830840    $parser->{'parameters'}->{'curr_section_depth'} = 1; 
     
    856866    $parser->{'parameters'}->{'curr_section_depth'} = $new_depth; 
    857867    $parser->{'parameters'}->{'curr_section_num'}   = $new_secnum; 
     868     
     869    1; 
    858870} 
    859871 
     
    904916    my ($gsdl_cgi, $doc_xml_filename, $metaname, $metavalue, $metapos, $metamode, $opt_secnum, $prevmetavalue) = @_; 
    905917 
     918    $gsdl_cgi->generate_ok_message("IN EDIT DOC XML\n****************************\n"); 
     919    $gsdl_cgi->generate_ok_message("doc_xml_filename = $doc_xml_filename\n"); 
     920    $gsdl_cgi->generate_ok_message("metaname = $metaname\n"); 
     921    $gsdl_cgi->generate_ok_message("metavalue = $metavalue\n"); 
     922    $gsdl_cgi->generate_ok_message("metapos = $metapos\n"); 
     923    $gsdl_cgi->generate_ok_message("metamode = $metamode\n"); 
     924    $gsdl_cgi->generate_ok_message("opt_secnum = $opt_secnum\n"); 
     925    $gsdl_cgi->generate_ok_message("prevmetavalue = $prevmetavalue\n"); 
     926     
    906927    # To monitor which section/subsection number we are in 
    907928    my @start_rules =  
     
    932953{ 
    933954    my $self = shift @_; 
    934     my ($gsdl_cgi,$archive_dir, $collect_dir,$collect, $infodbtype,$docid,$metaname,$metapos,$metavalue,$metamode,$prevmetavalue) = @_; 
     955    my ($gsdl_cgi, $archive_dir, $collect_dir, $collect, $infodbtype, $docid, $metaname, $metapos, $metavalue, $metamode, $prevmetavalue) = @_; 
     956     
     957    $gsdl_cgi->generate_ok_message("IN SET ARCHIVES METADATA ENTRY\n****************************\n"); 
     958    $gsdl_cgi->generate_ok_message("archive_dir = $archive_dir\n"); 
     959    $gsdl_cgi->generate_ok_message("collect_dir = $collect_dir\n"); 
     960    $gsdl_cgi->generate_ok_message("collect = $collect\n"); 
     961    $gsdl_cgi->generate_ok_message("infodbtype = $infodbtype\n"); 
     962    $gsdl_cgi->generate_ok_message("docid = $docid\n"); 
     963    $gsdl_cgi->generate_ok_message("metaname = $metaname\n"); 
     964    $gsdl_cgi->generate_ok_message("metapos = $metapos\n"); 
     965    $gsdl_cgi->generate_ok_message("metavalue = $metavalue\n"); 
     966    $gsdl_cgi->generate_ok_message("metamode = $metamode\n"); 
     967    $gsdl_cgi->generate_ok_message("prevmetavalue = $prevmetavalue\n"); 
    935968     
    936969    # Obtain the doc.xml path for the specified docID