Changeset 20825

Show
Ignore:
Timestamp:
19.10.2009 15:25:35 (10 years ago)
Author:
kjdon
Message:

check that the values of the partition_types_within_level option are valid

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/classify/List.pm

    r20679 r20825  
    5353      { 'name' => "none", 
    5454    'desc' => "{List.level_partition.none}" } ]; 
     55 
     56# following used to check types later on 
     57my $valid_partition_types = { 'per_letter' => 1, 
     58                  'constant_size' => 1, 
     59                  'per_letter_fixed_size' => 1, 
     60                  'none' => 1}; 
    5561 
    5662my $bookshelf_type_list =  
     
    166172    } else { 
    167173    my @partition_type_within_levellist = split(/\//, $self->{'partition_type_within_level'});   
     174         
     175    my $first = 1; 
    168176    foreach my $metadata_group (@metadata_groups) { 
    169177        my $partition_type_within_levelelem = shift(@partition_type_within_levellist); 
    170         if (defined($partition_type_within_levelelem)) { 
     178        if (defined($partition_type_within_levelelem) && defined $valid_partition_types->{$partition_type_within_levelelem}) { 
    171179        $self->{$metadata_group . ".partition_type_within_level"} = $partition_type_within_levelelem; 
    172180        } 
    173181        else { 
    174         $self->{$metadata_group . ".partition_type_within_level"} = $self->{$metadata_groups[0] . ".partition_type_within_level"}; 
    175         } 
    176     } 
    177     } 
    178  
     182        if ($first) { 
     183            $self->{$metadata_group . ".partition_type_within_level"} = "none"; 
     184            $first = 0; 
     185        } else { 
     186            $self->{$metadata_group . ".partition_type_within_level"} = $self->{$metadata_groups[0] . ".partition_type_within_level"}; 
     187        } 
     188        if (defined($partition_type_within_levelelem)) { 
     189            # ie invalid entry 
     190            print STDERR "invalid partition type for level $metadata_group: $partition_type_within_levelelem, defaulting to ". $self->{$metadata_group . ".partition_type_within_level"} ."\n"; 
     191        } 
     192        } 
     193    } 
     194    } 
     195     
    179196    # The number of items in each partition 
    180197    if (!$self->{'partition_size_within_level'}) { 
     
    812829     
    813830    # Sort leaf nodes and add to list 
    814     my @sort_leaf_nodes_usingmetadata_groups = @{$self->{'sort_leaf_nodes_using_metadata_groups'}}; 
    815     foreach my $sort_leaf_nodes_usingmetaelem (reverse @sort_leaf_nodes_usingmetadata_groups) { 
     831    my @sort_leaf_nodes_using_metadata_groups = @{$self->{'sort_leaf_nodes_using_metadata_groups'}}; 
     832    foreach my $sort_leaf_nodes_usingmetaelem (reverse @sort_leaf_nodes_using_metadata_groups) { 
    816833    my $OID_to_metadata_values_hash_ref = $self->{$sort_leaf_nodes_usingmetaelem . ".list"}; 
    817834    # Force a stable sort (Perl 5.6's sort isn't stable)