1 | ##########################################################################
|
---|
2 | #
|
---|
3 | # docextractaction.pm --
|
---|
4 | # A component of the Greenstone digital library software
|
---|
5 | # from the New Zealand Digital Library Project at the
|
---|
6 | # University of Waikato, New Zealand.
|
---|
7 | #
|
---|
8 | # Copyright (C) 2009 New Zealand Digital Library Project
|
---|
9 | #
|
---|
10 | # This program is free software; you can redistr te it and/or modify
|
---|
11 | # it under the terms of the GNU General Public License as published by
|
---|
12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
13 | # (at your option) any later version.
|
---|
14 | #
|
---|
15 | # This program is distributed in the hope that it will be useful,
|
---|
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | # GNU General Public License for more details.
|
---|
19 | #
|
---|
20 | # You should have received a copy of the GNU General Public License
|
---|
21 | # along with this program; if not, write to the Free Software
|
---|
22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | #
|
---|
24 | ###########################################################################
|
---|
25 |
|
---|
26 | package docextractaction;
|
---|
27 |
|
---|
28 | use strict;
|
---|
29 |
|
---|
30 | use cgiactions::baseaction;
|
---|
31 |
|
---|
32 | use dbutil;
|
---|
33 | use ghtml;
|
---|
34 |
|
---|
35 | use JSON;
|
---|
36 |
|
---|
37 |
|
---|
38 | BEGIN {
|
---|
39 | require XML::Rules;
|
---|
40 | }
|
---|
41 |
|
---|
42 | @docextractaction::ISA = ('baseaction');
|
---|
43 |
|
---|
44 | my $action_table =
|
---|
45 | {
|
---|
46 | "extract-archives-doc" => { # where param can be ONE of: index (default), import, archives, live
|
---|
47 | 'compulsory-args' => [ "d", "json-sections" ],
|
---|
48 | 'optional-args' => [ "json-metadata" ],
|
---|
49 | # 'optional-args' => [ "where" ],
|
---|
50 | 'help-string' => [
|
---|
51 | 'document-extract.pl?a=extract-archives-doc&c=demo&d=HASH0123456789ABC&json-sections=["1.2","1.3.2","2.1","2.2"]&json-metadata=[{"metaname":"dc.Title","metavalue":"All Black Rugy Success","metamode":"accumulate"]'
|
---|
52 | ."\n\n Add site=xxxx if a Greenstone3 installation"
|
---|
53 | ]}
|
---|
54 |
|
---|
55 | };
|
---|
56 |
|
---|
57 |
|
---|
58 | sub new
|
---|
59 | {
|
---|
60 | my $class = shift (@_);
|
---|
61 | my ($gsdl_cgi,$iis6_mode) = @_;
|
---|
62 |
|
---|
63 | # Treat metavalue specially. To transmit this through a GET request
|
---|
64 | # the Javascript side has url-encoded it, so here we need to decode
|
---|
65 | # it before proceeding
|
---|
66 |
|
---|
67 | # my $url_encoded_metavalue = $gsdl_cgi->param("metavalue");
|
---|
68 | # my $url_decoded_metavalue = &unicode::url_decode($url_encoded_metavalue,1);
|
---|
69 | # my $unicode_array = &unicode::utf82unicode($url_decoded_metavalue);
|
---|
70 |
|
---|
71 | # $url_decoded_metavalue = join("",map(chr($_),@$unicode_array));
|
---|
72 | # $gsdl_cgi->param("metavalue",$url_decoded_metavalue);
|
---|
73 |
|
---|
74 | my $self = new baseaction($action_table,$gsdl_cgi,$iis6_mode);
|
---|
75 |
|
---|
76 | return bless $self, $class;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | # JSON version that will get the requested metadata values
|
---|
81 | # from the requested source (index, import, archives or live)
|
---|
82 | # One of the params is a JSON string and the return value is JSON too
|
---|
83 | # http://forums.asp.net/t/1844684.aspx/1 - Web api method return json in string
|
---|
84 | sub extract_archives_doc
|
---|
85 | {
|
---|
86 | my $self = shift @_;
|
---|
87 |
|
---|
88 | # my $where = $self->{'where'};
|
---|
89 | # if (!$where) {
|
---|
90 | # $where = "index"; # default behaviour is to get the values from index
|
---|
91 | # }
|
---|
92 |
|
---|
93 | # Only when setting metadata do we perform authentication and do we lock the collection,
|
---|
94 | # not when getting metadata
|
---|
95 |
|
---|
96 | # for get_meta_array, the where param can only be ONE of import, archives, index, live
|
---|
97 | # if($where =~ m/index/) {
|
---|
98 | # $self->_get_index_metadata_array(@_);
|
---|
99 | # }
|
---|
100 | # elsif($where =~ m/archives/) {
|
---|
101 | # $self->_get_archives_metadata_array(@_);
|
---|
102 | # }
|
---|
103 | # elsif($where =~ m/import/) {
|
---|
104 | # $self->_get_import_metadata_array(@_);
|
---|
105 | # }
|
---|
106 | # elsif($where =~ m/live/) {
|
---|
107 | # $self->_get_live_metadata_array(@_);
|
---|
108 | # }
|
---|
109 | }
|
---|
110 |
|
---|
111 |
|
---|
112 | 1;
|
---|