1 package OpenILS::WWW::SuperCat;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK REDIRECT DECLINED :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache2::RequestRec ();
9 use Apache2::RequestIO ();
10 use Apache2::RequestUtil;
14 use OpenSRF::EX qw(:try);
16 use OpenSRF::AppSession;
19 use OpenILS::Utils::Fieldmapper;
22 # set the bootstrap config when this module is loaded
23 my ($bootstrap, $supercat);
32 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
33 $supercat = OpenSRF::AppSession->create('open-ils.supercat');
39 return Apache2::Const::DECLINED if (-e $apache->filename);
41 (my $isbn = $apache->path_info) =~ s{^.*?([^/]+)$}{$1}o;
44 ->request("open-ils.supercat.oisbn", $isbn)
47 print "Content-type: application/xml; charset=utf-8\n\n";
48 print "<?xml version='1.0' encoding='UTF-8' ?>\n";
50 unless (exists $$list{metarecord}) {
52 return Apache2::Const::OK;
55 print "<idlist metarecord='$$list{metarecord}'>\n";
57 for ( keys %{ $$list{record_list} } ) {
58 (my $o = $$list{record_list}{$_}) =~s/^(\S+).*?$/$1/o;
59 print " <isbn record='$_'>$o</isbn>\n"
64 return Apache2::Const::OK;
70 return Apache2::Const::DECLINED if (-e $apache->filename);
72 print "Content-type: application/xml; charset=utf-8\n";
76 my $uri = $cgi->param('uri') || '';
79 my $format = $cgi->param('format');
80 my ($id,$type,$command) = ('','','');
83 if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
86 $type = 'metarecord' if ($1 =~ /^m/o);
89 ->request("open-ils.supercat.$type.formats")
99 <type>text/html</type>
105 <type>application/xml</type>
112 $apache->custom_response( 300, $body);
116 ->request("open-ils.supercat.record.formats")
121 ->request("open-ils.supercat.metarecord.formats")
125 my %hash = map { ($_ => $_) } @$list;
126 $list = [ sort keys %hash ];
131 <type>text/html</type>
135 "<format><name>$_</name><type>text/xml</type></format>"
138 return Apache2::Const::OK;
143 if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
146 $type = 'metarecord' if ($1 =~ /^m/o);
147 $command = 'retrieve';
150 if ($format eq 'opac') {
151 print "Location: $base/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
152 if ($type eq 'metarecord');
153 print "Location: $base/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
154 if ($type eq 'record');
158 print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
160 return Apache2::Const::OK;
166 return Apache2::Const::DECLINED if (-e $apache->filename);
168 my $path = $apache->path_info;
170 my ($id,$type,$format,$command) = reverse split '/', $path;
172 print "Content-type: application/xml; charset=utf-8\n";
174 if ( $path =~ m{^/formats(?:/([^\/]+))?$}o ) {
177 ->request("open-ils.supercat.$1.formats")
182 <type>text/html</type>".
185 "<format><name>$_</name><type>text/xml</type></format>"
189 return Apache2::Const::OK;
193 ->request("open-ils.supercat.record.formats")
198 ->request("open-ils.supercat.metarecord.formats")
202 my %hash = map { ($_ => $_) } @$list;
203 $list = [ sort keys %hash ];
208 <type>text/html</type>
212 "<format><name>$_</name><type>text/xml</type></format>"
215 return Apache2::Const::OK;
218 print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
220 return Apache2::Const::OK;