1 package C4
::Search
::PazPar2
;
3 # Copyright (C) 2007 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 #use warnings; FIXME - Bug 2505
30 C4::Search::PazPar2 - implement client for PazPar2
32 [Note: may rename to Net::PazPar2 or somesuch if decide to put on CPAN separate
48 $self->{'endpoint'} = $endpoint;
49 $self->{'session'} = '';
50 $self->{'ua'} = LWP
::UserAgent
->new;
59 my $uri = URI
->new($self->{'endpoint'});
60 $uri->query_param(command
=> 'init');
61 my $response = $self->{'ua'}->get($uri);
62 if ($response->is_success) {
63 my $message = XMLin
($response->content);
64 if ($message->{'status'} eq 'OK') {
65 $self->{'session'} = $message->{'session'};
68 warn $response->status_line;
76 my $uri = URI
->new($self->{'endpoint'});
77 $uri->query_param(command
=> 'search');
78 $uri->query_param(session
=> $self->{'session'});
79 $uri->query_param(query
=> $query);
80 my $response = $self->{'ua'}->get($uri);
81 if ($response->is_success) {
82 #print $response->content, "\n";
84 warn $response->status_line;
92 my $uri = URI
->new($self->{'endpoint'});
93 $uri->query_param(command
=> 'stat');
94 $uri->query_param(session
=> $self->{'session'});
95 my $response = $self->{'ua'}->get($uri);
96 if ($response->is_success) {
97 return $response->content;
99 warn $response->status_line;
110 my $uri = URI
->new($self->{'endpoint'});
111 $uri->query_param(command
=> 'show');
112 $uri->query_param(start
=> $start);
113 $uri->query_param(num
=> $count);
114 $uri->query_param(block
=> 1);
115 $uri->query_param(session
=> $self->{'session'});
116 $uri->query_param(sort => $sort);
117 my $response = $self->{'ua'}->get($uri);
118 if ($response->is_success) {
119 return $response->content;
121 warn $response->status_line;
132 my $uri = URI
->new($self->{'endpoint'});
133 $uri->query_param(command
=> 'record');
134 $uri->query_param(id
=> $id);
135 $uri->query_param(offset
=> $offset);
136 $uri->query_param(binary
=> 1);
137 $uri->query_param(session
=> $self->{'session'});
138 my $response = $self->{'ua'}->get($uri);
139 if ($response->is_success) {
140 return $response->content;
142 warn $response->status_line;
151 my $uri = URI
->new($self->{'endpoint'});
152 $uri->query_param(command
=> 'termlist');
153 $uri->query_param(name
=> $name);
154 $uri->query_param(session
=> $self->{'session'});
155 my $response = $self->{'ua'}->get($uri);
156 if ($response->is_success) {
157 return $response->content;
159 warn $response->status_line;
169 Koha Development Team <http://koha-community.org/>
171 Galen Charlton <galen.charlton@liblime.com>