Ignore:
Timestamp:
2008-06-05T09:29:32+12:00 (16 years ago)
Author:
kjdon
Message:

plugin overhaul: plugins renamed to xxPlugin, and in some cases the names are made more sensible. They now use the new base plugins. Hopefully we have better code reuse. Some of the plugins still need work done as I didn't want to spend another month doing this before committing it. Alos, I haven't really tested anything yet...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/DSpacePlugin.pm

    r15865 r15872  
    22###########################################################################
    33#
    4 # DSpacePlug.pm -- plugin for import the collection from DSpace
     4# DSpacePlugin.pm -- plugin for importing a collection from DSpace
    55#
    66# A component of the Greenstone digital library software
     
    88# University of Waikato, New Zealand.
    99#
    10 # Copyright (C) 1999 New Zealand Digital Library Project
     10# Copyright (C) 2004 New Zealand Digital Library Project
    1111#
    1212# This program is free software; you can redistribute it and/or modify
     
    2626###########################################################################
    2727
    28 # DSpace Plug - 10/2004
    29 #
    30 #
     28
    3129# This plugin takes "contents" and dublin_core.xml file, which contain
    3230# Metadata and lists of associated files for a particular document
     
    4745#
    4846
    49 package DSpacePlug;
    50 
    51 use BasPlug;
     47package DSpacePlugin;
     48
     49use BasePlugin;
    5250use plugin;
    53 #use ghtml;
    5451use XMLParser;
    5552use strict;
     
    5754
    5855sub BEGIN {
    59     @DSpacePlug::ISA = ('BasPlug');
     56    @DSpacePlugin::ISA = ('BasePlugin');
    6057}
    6158
    6259my $arguments =
    6360    [ { 'name' => "process_exp",
    64     'desc' => "{BasPlug.process_exp}",
     61    'desc' => "{BasePlugin.process_exp}",
    6562    'type' => "string",
    6663    'deft' => &get_default_process_exp(),
    6764    'reqd' => "no" },
    6865      { 'name' => "only_first_doc",
    69     'desc' => "{DSpacePlug.only_first_doc}",
     66    'desc' => "{DSpacePlugin.only_first_doc}",
    7067    'type' => "flag",
    7168    'reqd' => "no" },
    7269      { 'name' => "first_inorder_ext",
    73     'desc' => "{DSpacePlug.first_inorder_ext}",
     70    'desc' => "{DSpacePlugin.first_inorder_ext}",
    7471    'type' => "string",
    7572    'reqd' => "no" },
    7673      { 'name' => "first_inorder_mime",
    77     'desc' => "{DSpacePlug.first_inorder_mime}",
     74    'desc' => "{DSpacePlugin.first_inorder_mime}",
    7875    'type' => "flag",
    7976    'reqd' => "no" },
    8077      { 'name' => "block_exp",
    81     'desc' => "{BasPlug.block_exp}",
     78    'desc' => "{BasePlugin.block_exp}",
    8279    'type' => "regexp",
    8380    'deft' => &get_default_block_exp(),
     
    8582
    8683
    87 my $options = { 'name'     => "DSpacePlug",
    88         'desc'     => "{DSpacePlug.desc}",
     84my $options = { 'name'     => "DSpacePlugin",
     85        'desc'     => "{DSpacePlugin.desc}",
    8986        'inherits' => "yes",
    9087        'abstract' => "no",
     
    104101    push(@$pluginlist, $class);
    105102
    106     if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
    107     if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
    108 
    109     $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
    110    
     103    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
     104    push(@{$hashArgOptLists->{"OptList"}},$options);
     105
     106    $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
     107   
     108    if ($self->{'info_only'}) {
     109    # don't worry about creating the XML parser as all we want is the
     110    # list of plugin options
     111    return bless $self, $class;
     112    }
     113
    111114    #create XML::Parser object for parsing dublin_core.xml files
    112115    my $parser = new XML::Parser('Style' => 'Stream',
     
    252255    }
    253256   
    254     print $outhandle "DSpacePlug: extracting metadata from $file\n"
     257    print $outhandle "DSpacePlugin: extracting metadata from $file\n"
    255258    if $self->{'verbosity'} > 1;
    256259   
     
    262265   
    263266    if ($@) {
    264     die "DSpacePlug: ERROR $filename is not a well formed dublin_core.xml file ($@)\n";
     267    die "DSpacePlugin: ERROR $filename is not a well formed dublin_core.xml file ($@)\n";
    265268    }
    266269
     
    287290
    288291    # Temporarily store associate file info in metadata table
    289     # This will be removed in 'extra_metadata' in BasPlug and used
     292    # This will be removed in 'extra_metadata' in BasePlugin and used
    290293    # to perform the actual file association (once the doc obj has
    291294    # been formed
     
    313316
    314317
    315 # The DSpacePlug read() function. This function does all the right things
    316 # to make general options work for a given plugin. It calls the process()
    317 # function which does all the work specific to a plugin (like the old
    318 # read functions used to do). Most plugins should define their own
    319 # process() function and let this read() function keep control.
    320 #
    321 # DSpace overrides read() because there is no need to read the actual
    322 # text of the file in, because the contents of the file is not text...
    323 #
    324 # Return number of files processed, undef if can't process
    325 # Note that $base_dir might be "" and that $file might
    326 # include directories
    327 
     318# The DSpacePlugin read() function. We are not actually reading any documents
     319# here, just blocking ones that have been processed by metadata read.
     320#
     321# Returns 0 for a file its blocking, undef for any other
    328322sub read {
    329323    my $self = shift (@_);
     
    340334    return 0 if (defined $self->{'extra_blocks'}->{$filename});
    341335    return undef;
    342 }
    343 
    344 # do plugin specific processing of doc_obj
    345 sub process {
    346     my $self = shift (@_);
    347     my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj) = @_;
    348     my $outhandle = $self->{'outhandle'};
    349    
    350     return 1;
    351336}
    352337
Note: See TracChangeset for help on using the changeset viewer.