/usr/share/perl5/SRU/Server.pm is in libsru-perl 1.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | package SRU::Server;
{
$SRU::Server::VERSION = '1.01';
}
#ABSTRACT: Respond to SRU requests via CGI::Application
use base qw( CGI::Application Class::Accessor );
use strict;
use warnings;
use SRU::Request;
use SRU::Response;
use SRU::Response::Diagnostic;
use CQL::Parser 1.12;
use constant ERROR => -1;
use constant DEFAULT => 0;
my @modes = qw( explain scan searchRetrieve error_mode );
my @accessors = qw( request response cql );
__PACKAGE__->mk_accessors( @accessors );
sub setup {
my $self = shift;
$self->run_modes( \@modes );
$self->start_mode( $modes[ DEFAULT ] );
$self->mode_param( 'operation' );
}
sub cgiapp_prerun {
my $self = shift;
my $mode = shift;
$CGI::USE_PARAM_SEMICOLONS = 0;
$self->request( SRU::Request->newFromURI( $self->query->url( -query => 1 ) ) );
$self->response( SRU::Response->newFromRequest( $self->request ) );
my $cql;
if ( $mode eq 'scan' ) {
$cql = $self->request->scanClause;
}
elsif ( $mode eq 'searchRetrieve' ) {
$cql = $self->request->query;
}
if( defined $cql ) {
$cql = CQL::Parser->new->parseSafe( $cql );
if (ref $cql) {
$self->cql( $cql );
} else {
$self->prerun_mode( $modes[ ERROR ] );
$self->response->addDiagnostic( SRU::Response::Diagnostic->newFromCode( $cql ) );
}
}
unless( $self->can( $mode ) ) {
$self->prerun_mode( $modes[ ERROR ] );
$self->response->addDiagnostic( SRU::Response::Diagnostic->newFromCode( 4 ) );
}
}
sub cgiapp_postrun {
my $self = shift;
my $output_ref = shift;
$self->header_add( -type => 'text/xml' );
$$output_ref = $self->response->asXML;
}
sub error_mode {
}
1;
__END__
=pod
=head1 NAME
SRU::Server - Respond to SRU requests via CGI::Application
=head1 SYNOPSIS
package MySRU;
use base qw( SRU::Server );
sub explain {
my $self = shift;
# $self->request isa SRU::Request::Explain
# $self->response isa SRU::Response::Explain
}
sub scan {
my $self = shift;
# $self->request isa SRU::Request::Scan
# $self->response isa SRU::Response::Scan
# $self->cql is the root node of a CQL::Parser-parsed query
}
sub searchRetrieve {
my $self = shift;
# $self->request isa SRU::Request::SearchRetrieve
# $self->response isa SRU::Response::SearchRetrieve
# $self->cql is the root node of a CQL::Parser-parsed query
}
package main;
MySRU->new->run;
=head1 DESCRIPTION
This module brings together all of the SRU verbs (explain, scan
and searchRetrieve) under a sub-classable object based on CGI::Application.
=cut
=head1 METHODS
=head2 explain
This method is used to return an explain response. It is the default
method.
=head2 scan
This method returns a scan response.
=head2 searchRetrieve
This method returns a searchRetrieve response.
=cut
=head1 CGI::APPLICATION METHODS
=head2 setup
Sets the C<run_modes>, C<mode_param> and the default runmode (explain).
=cut
=head2 cgiapp_prerun
Parses the incoming SRU request and if needed, checks the CQL query.
=cut
=head2 cgiapp_postrun
Sets the content type (text/xml) and serializes the response.
=cut
=head2 error_mode
Stub error runmode.
=cut
=head1 AUTHORS
=over 4
=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
=item * Ed Summers E<lt>ehs@pobox.comE<gt>
=item * Jakob Voss E<lt>voss@gbv.deE<gt>
=back
=cut
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Ed Summers.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|