Changeset 21367


Ignore:
Timestamp:
12/16/09 14:43:55 (11 years ago)
Author:
kjdon
Message:

escape [] in metadata, otherwise it will screw up greenstone. instead of ignoring all dc.description metadata, only ignore dc.description.provenance as this is the only one used internally by DSpace. Patch thanks to
Pongtawat Chippimolchai
KIDS-D Project
Asian Institute of Technology

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/DSpacePlugin.pm

    r19746 r21367  
    365365    my $metaname = $_{'element'};
    366366    my $qualifier = $_{'qualifier'}||"";
    367     if ($metaname ne "description") {
     367    if ($metaname ne "description" || $qualifier ne "provenance") {
    368368        $metaname .= "^$qualifier" if ($qualifier ne "none" && $qualifier ne "");
    369369        $self->{'metaname'} = "dc.\u$metaname";
     
    384384    # $_ == Metadata content
    385385    my $mname = $self->{'metaname'};
     386    my $mvalue = prepareMetadataValue($_);
    386387    if (defined $self->{'saved_metadata'}->{$mname}) {
    387388        # accumulate - add value to existing value(s)
    388389        if (ref ($self->{'saved_metadata'}->{$mname}) eq "ARRAY") {
    389         push (@{$self->{'saved_metadata'}->{$mname}}, $_);
     390        push (@{$self->{'saved_metadata'}->{$mname}}, $mvalue);
    390391        } else {
    391392        $self->{'saved_metadata'}->{$mname} =
    392             [$self->{'saved_metadata'}->{$mname}, $_];
     393            [$self->{'saved_metadata'}->{$mname}, $mvalue];
    393394        }
    394395    } else {
    395396        # accumulate - add value into (currently empty) array
    396         $self->{'saved_metadata'}->{$mname} = [$_];
    397     }
    398 
    399     }
    400 }
    401 
     397        $self->{'saved_metadata'}->{$mname} = [$mvalue];
     398    }
     399
     400    }
     401}
     402
     403# Prepare DSpace metadata for using with Greenstone.
     404# Some value must be escaped.
     405sub prepareMetadataValue {
     406    my ($value) = @_;
     407   
     408    $value =~ s/\[/[/g;
     409    $value =~ s/\]/]/g;
     410   
     411    return $value;
     412 }
    402413# This Char function overrides the one in XML::Parser::Stream to overcome a
    403414# problem where $expat->{Text} is treated as the return value, slowing
Note: See TracChangeset for help on using the changeset viewer.