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 $path = $apache->path_info;
43 my ($id,$type,$format,$command) = reverse split '/', $path;
45 print "Content-type: application/xml; charset=utf-8\n";
47 if ( $path =~ m{^/?$}o ) {
50 my $uri = $cgi->param('uri') || '';
53 $format = $cgi->param('format');
54 ($id,$type) = ('','');
57 if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
60 $type = 'metarecord' if ($1 =~ /^m/o);
63 ->request("open-ils.supercat.$type.formats")
73 <type>text/html</type>
79 <type>application/xml</type>
86 $apache->custom_response( 300, $body);
90 ->request("open-ils.supercat.record.formats")
94 ->request("open-ils.supercat.metarecord.formats")
98 my %hash = map { ($_ => $_) } @$list;
99 $list = [ sort keys %hash ];
104 <type>text/html</type>
108 "<format><name>$_</name><type>text/xml</type></format>"
111 return Apache2::Const::OK;
116 if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
119 $type = 'metarecord' if ($1 =~ /^m/o);
120 $command = 'retrieve';
123 if ($format eq 'opac') {
124 print "Location: $base/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
125 if ($type eq 'metarecord');
126 print "Location: $base/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
127 if ($type eq 'record');
131 } elsif ( $path =~ m{^/formats/([^\/]+)$}o ) {
133 ->request("open-ils.supercat.$1.formats")
139 "<format><name>$_</name><type>text/xml</type></format>"
142 return Apache2::Const::OK;
145 print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
147 return Apache2::Const::OK;