Ignore:
Timestamp:
07/29/09 13:24:48 (11 years ago)
Author:
kjdon
Message:

tidied up the file

File:
1 edited

Legend:

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

    r20097 r20101  
    2424###########################################################################
    2525
    26 # reads in a collection configuration file
     26# reads/writes the collection configuration files:
     27# collect.cfg/collectionConfig.xml and build.cfg/buildConfig.xml
    2728
    2829package colcfg;
     
    7475#                                               ->mi->maori demo
    7576
    76 sub read_collect_cfg {
    77     my ($filename) = @_;
    78 
    79     return &cfgread::read_cfg_file ($filename,
    80                     q/^(infodbtype|creator|public|defaultindex|importdir|/ .
    81                     q/archivedir|cachedir|builddir|removeold|/ .
    82                     q/textcompress|buildtype|no_text|keepold|gzip|/ .
    83                     q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/ .
    84                     q/groupsize|maxdocs|debug|mode|saveas|/ .
    85                     q/sortmeta|removesuffix|removeprefix|create_images|/ .
    86                     q/maxnumeric|languagemetadata|/ .
    87                     q/no_strip_html|index|sections_index_document_metadata|/ .
    88                     q/store_metadata_coverage)$/,
    89                     q/(maintainer|languages|indexsubcollections|/ .
    90                        q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
    91                        q/searchtype|searchtypes)$/,
    92                     q/^(subcollection|format)$/,
    93                     q/^(acquire|plugin|classify)$/,
    94                     q/^(collectionmeta)$/);
    95 }
    96 
    97 sub read_collection_cfg_xml {
    98     my ($filename) = @_;
    99 
    100     return &collConfigxml::read_cfg_file ($filename);
    101 }
    102 
     77# convenience method for reading in either collect.cfg/collectionConfig.xml
    10378sub read_collection_cfg {
    10479    my ($filename,$gs_mode) = @_;
     
    11994}
    12095
    121 
    122 
    123 sub write_collection_cfg_xml {
    124  
    125 }
    126 
    127 sub write_build_cfg_xml {
    128     my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
    129 
    130     return &buildConfigxml::write_build_cfg_file ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI);
    131 }
    132 
    133 sub write_collect_cfg {
    134     my ($filename, $data) = @_;
    135    
    136     &cfgread::write_cfg_file($filename, $data,
    137                  q/^(infodbtype|creator|public|defaultindex|importdir|/ .
    138                  q/archivedir|cachedir|builddir|removeold|/ .
    139                  q/textcompress|buildtype|no_text|keepold|gzip|/ .
    140                  q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/.
    141                  q/groupsize|maxdocs|debug|mode|saveas|/ .
    142                  q/sortmeta|removesuffix|removeprefix|create_images|/ .
    143                  q/maxnumeric|language_metadata/ .
    144                  q/no_strip_html|index|sections_index_document_metadata)$/,
    145                  q/^(maintainer|languages|indexsubcollections|/ .
    146                  q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
    147                  q/searchtype|searchtypes)$/,
    148                  q/^(subcollection|format)$/,
    149                  q/^(acquire|plugin|classify)$/,
    150                  q/^(collectionmeta)$/);
    151 }
    152 
    153 
     96# convenience method for writing out either collect.cfg/collectionConfig.xml
     97# is this ever used??
     98sub write_collection_cfg {
     99     my ($filename, $collectcfg_data, $gs_mode) = @_;
     100   
     101    if ($gs_mode eq "gs2") {
     102    &colcfg::write_collect_cfg ($filename, $collectcfg_data );
     103    } elsif ($gs_mode eq "gs3") {
     104    &colcfg::write_collection_cfg_xml ($filename, $collectcfg_data);
     105    }
     106    else {
     107    print STDERR "Failed to write collection configuration file\n";
     108    print STDERR "  Unrecognized mode: $gs_mode\n";
     109    }
     110}
     111   
    154112# the build configuration file data is stored in the form
    155113#
     
    171129# {'textlevel'}->string
    172130# {'levelmap'} -> array of strings in the form "level->shortname"
     131
     132# convenience method for reading in either build.cfg/buildConfig.xml
     133sub read_building_cfg {
     134    my ($filename,$gs_mode) = @_;
     135   
     136    my $buildcfg = undef;
     137
     138    if ($gs_mode eq "gs2") {
     139    $buildcfg = &colcfg::read_build_cfg ($filename);
     140    } elsif ($gs_mode eq "gs3") {
     141    $buildcfg = &colcfg::read_build_cfg_xml ($filename);
     142    }
     143    else {
     144    print STDERR "Failed to read building configuration file\n";
     145    print STDERR "  Unrecognized mode: $gs_mode\n";
     146    }
     147
     148    return $buildcfg;
     149}
     150
     151# convenience method for writing out either build.cfg/buildConfig.xml
     152# haven't got one, as gs3 version needs extra parameters
     153#sub write_building_cfg {}
     154
     155##############################
     156### gs2/gs3 specific methods
     157###############################
     158
     159#####################################
     160### collect.cfg/collectionConfig.xml
     161#####################################
     162
     163# gs2 read in collect.cfg
     164sub read_collect_cfg {
     165    my ($filename) = @_;
     166
     167    return &cfgread::read_cfg_file ($filename,
     168                    q/^(infodbtype|creator|public|defaultindex|importdir|/ .
     169                    q/archivedir|cachedir|builddir|removeold|/ .
     170                    q/textcompress|buildtype|no_text|keepold|gzip|/ .
     171                    q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/ .
     172                    q/groupsize|maxdocs|debug|mode|saveas|/ .
     173                    q/sortmeta|removesuffix|removeprefix|create_images|/ .
     174                    q/maxnumeric|languagemetadata|/ .
     175                    q/no_strip_html|index|sections_index_document_metadata|/ .
     176                    q/store_metadata_coverage)$/,
     177                    q/(maintainer|languages|indexsubcollections|/ .
     178                       q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|plugout|/ .
     179                       q/searchtype|searchtypes)$/,
     180                    q/^(subcollection|format)$/,
     181                    q/^(acquire|plugin|classify)$/,
     182                    q/^(collectionmeta)$/);
     183}
     184
     185# gs2 write out collect.cfg
     186sub write_collect_cfg {
     187    my ($filename, $data) = @_;
     188   
     189    &cfgread::write_cfg_file($filename, $data,
     190                 q/^(infodbtype|creator|public|defaultindex|importdir|/ .
     191                 q/archivedir|cachedir|builddir|removeold|/ .
     192                 q/textcompress|buildtype|no_text|keepold|gzip|/ .
     193                 q/verbosity|remove_empty_classifications|OIDtype|OIDmetadata|/.
     194                 q/groupsize|maxdocs|debug|mode|saveas|/ .
     195                 q/sortmeta|removesuffix|removeprefix|create_images|/ .
     196                 q/maxnumeric|language_metadata/ .
     197                 q/no_strip_html|index|sections_index_document_metadata)$/,
     198                 q/^(maintainer|languages|indexsubcollections|/ .
     199                 q/indexes|indexoptions|dontbuild|dontgdbm|mirror|levels|/.
     200                 q/searchtype|searchtypes)$/,
     201                 q/^(subcollection|format)$/,
     202                 q/^(acquire|plugin|classify)$/,
     203                 q/^(collectionmeta)$/);
     204}
     205
     206# gs3 read in collectionConfig.xml
     207sub read_collection_cfg_xml {
     208    my ($filename) = @_;
     209
     210    return &collConfigxml::read_cfg_file ($filename);
     211}
     212
     213# gs3 write out collectionConfig.xml
     214sub write_collection_cfg_xml {
     215 
     216}
     217
     218#####################################
     219### build.cfg/buildConfig.xml
     220######################################
     221
     222# gs2 read build.cfg
    173223sub read_build_cfg {
    174224    my ($filename) = @_;
     
    180230}
    181231
     232# gs2 write build.cfg
    182233sub write_build_cfg {
    183234    my ($filename, $data) = @_;
     
    188239}
    189240
     241# gs3 read buildConfig.xml
     242sub read_build_cfg_xml {
     243
     244    my ($filename) = @_;
     245   
     246    return &buildConfigxml::read_cfg_file($filename);
     247}
     248
     249# gs3 write buildConfig.xml
     250sub write_build_cfg_xml {
     251    my ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI) = @_;
     252
     253    return &buildConfigxml::write_cfg_file ($buildoutfile, $buildcfg, $collectcfg, $disable_OAI);
     254}
     255
     256
     257# method to check for filename of collect.cfg, and gs mode.
    190258sub get_collect_cfg_name {
    191259    my ($out) = @_;
Note: See TracChangeset for help on using the changeset viewer.