From 86c50a6fa4dc6f6efda7c872472ba5785374464e Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 16 Jun 2010 19:41:27 +0000
Subject: [PATCH] split registration of authority browse urls out from record;
 add authority formats ML method

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16735 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../src/perlmods/OpenILS/Application/SuperCat.pm   | 37 ++++++++++++++++++++
 Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm      | 39 +++++++++++++++++++---
 2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
index f250198dce..ccca539364 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
@@ -1789,6 +1789,43 @@ Returns the list of valid metarecord formats that supercat understands.
 );
 
 
+sub list_authority_formats {
+	my @list = (
+		{ marcxml =>
+			{ namespace_uri	  => 'http://www.loc.gov/MARC21/slim',
+			  docs		  => 'http://www.loc.gov/marcxml/',
+			  schema_location => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd',
+			}
+		}
+	);
+
+#	for my $type ( keys %record_xslt ) {
+#		push @list,
+#			{ $type => 
+#				{ namespace_uri	  => $record_xslt{$type}{namespace_uri},
+#				  docs		  => $record_xslt{$type}{docs},
+#				  schema_location => $record_xslt{$type}{schema_location},
+#				}
+#			};
+#	}
+#
+	return \@list;
+}
+__PACKAGE__->register_method(
+	method    => 'list_authority_formats',
+	api_name  => 'open-ils.supercat.authority.formats',
+	api_level => 1,
+	argc      => 0,
+	signature =>
+		{ desc     => <<"		  DESC",
+Returns the list of valid authority formats that supercat understands.
+		  DESC
+		  'return' =>
+		  	{ desc => 'The format list',
+			  type => 'array' }
+		}
+);
+
 sub list_record_formats {
 	my @list = (
 		{ marcxml =>
diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
index 3c6bd2cdf7..95b34e6cbc 100644
--- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
+++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
@@ -147,7 +147,7 @@ sub child_init {
     $list = [ map { (keys %$_)[0] } @$list ];
     push @$list, 'htmlholdings','html', 'marctxt', 'ris';
 
-    for my $browse_axis ( qw/title author subject topic series item-age authority.title authority.author authority.subject authority.topic/ ) {
+    for my $browse_axis ( qw/title author subject topic series item-age/ ) {
         for my $record_browse_format ( @$list ) {
             {
                 my $__f = $record_browse_format;
@@ -163,8 +163,7 @@ sub child_init {
                 	my $site = shift;
 
 			$log->info("Creating record feed with params [$real_format, $record_list, $unapi, $site]");
-                	my $bib_or_authority = $__a =~ /^authority/ ? 'authority' : 'record';
-                	my $feed = create_record_feed( $bib_or_authority, $real_format, $record_list, $unapi, $site, $real_format =~ /(-full|-uris)$/o ? 1 : 0 );
+                	my $feed = create_record_feed( 'record', $real_format, $record_list, $unapi, $site, $real_format =~ /(-full|-uris)$/o ? 1 : 0 );
                 	$feed->root( "$base/../" );
                 	$feed->lib( $site );
                 	$feed->link( next => $next => $feed->type );
@@ -178,6 +177,36 @@ sub child_init {
             }
         }
     }
+
+    for my $browse_axis ( qw/authority.title authority.author authority.subject authority.topic/ ) {
+        for my $record_browse_format ( qw/marcxml/ ) {
+            {
+                my $__f = $record_browse_format;
+                my $__a = $browse_axis;
+
+                $browse_types{$__a}{$__f} = sub {
+                	my $record_list = shift;
+                	my $prev = shift;
+                	my $next = shift;
+                	my $real_format = shift || $__f;
+                	my $unapi = shift;
+                	my $base = shift;
+                	my $site = shift;
+
+			$log->info("Creating record feed with params [$real_format, $record_list, $unapi, $site]");
+                	my $feed = create_record_feed( 'authority', $real_format, $record_list, $unapi, $site, 0 );
+                	$feed->root( "$base/../" );
+                	$feed->link( next => $next => $feed->type );
+                	$feed->link( previous => $prev => $feed->type );
+
+                	return (
+                        "Content-type: ". $feed->type ."; charset=utf-8\n\n",
+                        $feed->toString
+                    );
+                };
+            }
+        }
+    }
 }
 
 =head2 parse_feed_type($type)
@@ -341,6 +370,7 @@ sub unapi {
 			$lib = uc($4);
 			$type = 'record';
 			$type = 'metarecord' if ($1 =~ /^m/o);
+			$type = 'authority' if ($1 =~ /^authority/o);
 
 			my $list = $supercat
 				->request("open-ils.supercat.$type.formats")
@@ -380,7 +410,7 @@ sub unapi {
 
 		} else {
 			my $list = $supercat
-				->request("open-ils.supercat.record.formats")
+				->request("open-ils.supercat.$type.formats")
 				->gather(1);
 				
 			push @$list,
@@ -434,6 +464,7 @@ sub unapi {
 		$type = 'acp' if ($1 =~ /^asset-copy/o);
 		$type = 'acn' if ($1 =~ /^asset-call_number/o);
 		$type = 'auri' if ($1 =~ /^asset-uri/o);
+		$type = 'authority' if ($1 =~ /^authority/o);
 		$command = 'retrieve';
 		$command = 'browse' if ($type eq 'call_number');
 	}
-- 
2.11.0