unapi r1 complete!; using (fake) info uris
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Feb 2006 23:37:19 +0000 (23:37 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Feb 2006 23:37:19 +0000 (23:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3173 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm

index d4ae0ba..d229b67 100644 (file)
@@ -238,7 +238,7 @@ sub retrieve_metarecord_mods {
                ->ownerDocument
                ->createElement("mods:recordIdentifier");
 
-       $recordIdentifier->setAttribute( source => 'oils:/metabib-metarecord/' );
+       $recordIdentifier->setAttribute( source => 'info:oils/metabib-metarecord/' );
 
        my $id = $mr->id;
        $recordIdentifier->appendTextNode( $id );
@@ -307,7 +307,7 @@ sub retrieve_metarecord_mods {
                        ->ownerDocument
                        ->createElement("mods:recordIdentifier");
 
-               $subRecordIdentifier->setAttribute( source => 'oils:/biblio-record_entry/' );
+               $subRecordIdentifier->setAttribute( source => 'info:oils/biblio-record_entry/' );
 
                my $subid = $map->source;
                $subRecordIdentifier->appendTextNode( $subid );
index 6099c87..eee3beb 100644 (file)
@@ -42,18 +42,19 @@ sub handler {
 
        my ($id,$type,$format,$command) = reverse split '/', $path;
 
-       print "Content-type: text/xml; charset=utf-8\n\n";
+       print "Content-type: application/xml; charset=utf-8\n";
        
        if ( $path =~ m{^/?$}o ) {
                my $cgi = new CGI;
 
                my $uri = $cgi->param('uri') || '';
+               my $base = $cgi->url;
 
                $format = $cgi->param('format');
                ($id,$type) = ('','');
 
                if (!$format) {
-                       if ($uri =~ m{^oils:/([^\/]+)/(\d+)}o) {
+                       if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
                                $id = $2;
                                $type = 'record';
                                $type = 'metarecord' if ($1 =~ /^m/o);
@@ -62,12 +63,27 @@ sub handler {
                                        ->request("open-ils.supercat.$type.formats")
                                        ->gather(1);
 
-                               print '<formats>'.
+                               print "\n";
+
+                               my $body =
+                                       "<formats>
+                                        <uri>$uri</uri>
+                                          <format>
+                                            <name>opac</name>
+                                            <type>text/html</type>
+                                          </format>".
+
                                        join('',
-                                               map { 
-                                                       "<format><name>$_</name><type>text/xml</type></format>" 
+                                               map { "  <format>
+                                                          <name>$_</name>
+                                                          <type>application/xml</type>
+                                                        </format>" 
                                                } @$list
-                                       ).'</formats>';
+                                       ).
+                                       
+                                       '</formats>';
+
+                               $apache->custom_response( 300, $body);
                                return 300;
                        } else {
                                my $list = $supercat
@@ -82,7 +98,11 @@ sub handler {
                                my %hash = map { ($_ => $_) } @$list;
                                $list = [ sort keys %hash ];
 
-                               print '<formats>'.
+                               print "\n<formats>
+                                          <format>
+                                            <name>opac</name>
+                                            <type>text/html</type>
+                                          </format>".
                                        join('',
                                                map { 
                                                        "<format><name>$_</name><type>text/xml</type></format>" 
@@ -93,19 +113,27 @@ sub handler {
                }
 
                
-               if ($uri =~ m{^oils:/([^\/]+)/(\d+)}o) {
+               if ($uri =~ m{^info:oils/([^\/]+)/(\d+)}o) {
                        $id = $2;
                        $type = 'record';
                        $type = 'metarecord' if ($1 =~ /^m/o);
                        $command = 'retrieve';
                }
 
+               if ($format eq 'opac') {
+                       print "Location: $base/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
+                               if ($type eq 'metarecord');
+                       print "Location: $base/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
+                               if ($type eq 'record');
+                       return 302;
+               }
+
        } elsif ( $path =~ m{^/formats/([^\/]+)$}o ) {
                my $list = $supercat
                        ->request("open-ils.supercat.$1.formats")
                        ->gather(1);
 
-               print '<formats>'.
+               print "\n<formats>".
                        join('',
                                map { 
                                        "<format><name>$_</name><type>text/xml</type></format>" 
@@ -114,9 +142,7 @@ sub handler {
                return Apache2::Const::OK;
        }
 
-       print $supercat
-               ->request("open-ils.supercat.$type.$format.$command",$id)
-               ->gather(1);
+       print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
 
        return Apache2::Const::OK;
 }