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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
46 $self->{'endpoint'} = $endpoint;
47 $self->{'session'} = '';
48 $self->{'ua'} = LWP::UserAgent->new;
57 my $uri = URI->new($self->{'endpoint'});
58 $uri->query_param(command => 'init');
59 my $response = $self->{'ua'}->get($uri);
60 if ($response->is_success) {
61 my $message = XMLin($response->content);
62 if ($message->{'status'} eq 'OK') {
63 $self->{'session'} = $message->{'session'};
66 warn $response->status_line;
74 my $uri = URI->new($self->{'endpoint'});
75 $uri->query_param(command => 'search');
76 $uri->query_param(session => $self->{'session'});
77 $uri->query_param(query => $query);
78 my $response = $self->{'ua'}->get($uri);
79 if ($response->is_success) {
80 #print $response->content, "\n";
82 warn $response->status_line;
90 my $uri = URI->new($self->{'endpoint'});
91 $uri->query_param(command => 'stat');
92 $uri->query_param(session => $self->{'session'});
93 my $response = $self->{'ua'}->get($uri);
94 if ($response->is_success) {
95 return $response->content;
97 warn $response->status_line;
108 my $uri = URI->new($self->{'endpoint'});
109 $uri->query_param(command => 'show');
110 $uri->query_param(start => $start);
111 $uri->query_param(num => $count);
112 $uri->query_param(block => 1);
113 $uri->query_param(session => $self->{'session'});
114 $uri->query_param(sort => $sort);
115 my $response = $self->{'ua'}->get($uri);
116 if ($response->is_success) {
117 return $response->content;
119 warn $response->status_line;
130 my $uri = URI->new($self->{'endpoint'});
131 $uri->query_param(command => 'record');
132 $uri->query_param(id => $id);
133 $uri->query_param(offset => $offset);
134 $uri->query_param(binary => 1);
135 $uri->query_param(session => $self->{'session'});
136 my $response = $self->{'ua'}->get($uri);
137 if ($response->is_success) {
138 return $response->content;
140 warn $response->status_line;
149 my $uri = URI->new($self->{'endpoint'});
150 $uri->query_param(command => 'termlist');
151 $uri->query_param(name => $name);
152 $uri->query_param(session => $self->{'session'});
153 my $response = $self->{'ua'}->get($uri);
154 if ($response->is_success) {
155 return $response->content;
157 warn $response->status_line;
167 Koha Development Team <http://koha-community.org/>
169 Galen Charlton <galen.charlton@liblime.com>