[21294] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # PharosImagePlugin - an ImagePlugin that can also do pharos related tasks.
|
---|
| 4 | #
|
---|
| 5 | # A component of the Greenstone digital library software
|
---|
| 6 | # from the New Zealand Digital Library Project at the
|
---|
| 7 | # University of Waikato, New Zealand.
|
---|
| 8 | #
|
---|
| 9 | # Copyright (C) 2008 New Zealand Digital Library Project
|
---|
| 10 | #
|
---|
| 11 | # This program is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # This program is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with this program; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | #
|
---|
| 25 | ###########################################################################
|
---|
| 26 | package PharosImagePlugin;
|
---|
| 27 |
|
---|
| 28 | use ImagePlugin;
|
---|
| 29 | use PharosImageIndexer;
|
---|
| 30 |
|
---|
| 31 | use strict;
|
---|
| 32 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
| 33 |
|
---|
| 34 | use gsprintf 'gsprintf';
|
---|
| 35 |
|
---|
| 36 | BEGIN {
|
---|
| 37 | @PharosImagePlugin::ISA = ('ImagePlugin', 'PharosImageIndexer');
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | my $arguments = [
|
---|
| 41 | ];
|
---|
| 42 |
|
---|
| 43 | my $options = { 'name' => "PharosImagePlugin",
|
---|
| 44 | 'desc' => "{PharosImagePlugin.desc}",
|
---|
| 45 | 'abstract' => "no",
|
---|
| 46 | 'inherits' => "yes",
|
---|
| 47 | 'args' => $arguments };
|
---|
| 48 |
|
---|
| 49 | sub new {
|
---|
| 50 | my ($class) = shift (@_);
|
---|
| 51 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 52 | push(@$pluginlist, $class);
|
---|
| 53 |
|
---|
| 54 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 55 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
| 56 |
|
---|
| 57 | new PharosImageIndexer($pluginlist, $inputargs, $hashArgOptLists);
|
---|
| 58 | my $self = new ImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | return bless $self, $class;
|
---|
| 62 |
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | # needs to be called after BasePlugin init, so that outhandle is set up.
|
---|
| 66 | sub init {
|
---|
| 67 | my $self = shift(@_);
|
---|
| 68 | my ($verbosity, $outhandle, $failhandle) = @_;
|
---|
| 69 |
|
---|
| 70 | $self->SUPER::init(@_);
|
---|
| 71 | $self->PharosImageIndexer::init();
|
---|
| 72 |
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[21304] | 75 | sub remove_all {
|
---|
[21294] | 76 | my $self = shift (@_);
|
---|
| 77 | my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
|
---|
| 78 |
|
---|
[21304] | 79 | $self->SUPER::remove_all(@_);
|
---|
| 80 | $self->PharosImageIndexer::remove_all(@_);
|
---|
[21294] | 81 |
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[21304] | 84 | sub remove_one {
|
---|
| 85 | my $self = shift (@_);
|
---|
[21316] | 86 | my ($file, $oids, $archivedir) = @_;
|
---|
| 87 | return undef if (!$self->can_process_this_file($file));
|
---|
| 88 |
|
---|
[21304] | 89 | $self->PharosImageIndexer::remove_one(@_);
|
---|
[21316] | 90 | return $self->SUPER::remove_one(@_);
|
---|
| 91 |
|
---|
| 92 |
|
---|
[21304] | 93 | }
|
---|
| 94 |
|
---|
[21294] | 95 | sub post_process_doc_obj {
|
---|
| 96 | my $self = shift (@_);
|
---|
| 97 | # options??
|
---|
| 98 | my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
|
---|
| 99 | $self->pharos_index_image(&util::filename_cat($base_dir, $file), $doc_obj);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | 1;
|
---|