Support proxying bulk Read API requests for access rights
authorDan Scott <dan@coffeecode.net>
Thu, 2 Jun 2011 17:03:22 +0000 (13:03 -0400)
committerDan Scott <dan@coffeecode.net>
Fri, 3 Jun 2011 15:40:27 +0000 (11:40 -0400)
Using IP-based access right determination runs into problems with a pure
JavaScript API, as users may be accessing the API from any location in
the world. Proxying the requests via the library system server ensures
that the access rights for users of those libraries are properly
displayed.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm

index 522caa4..ccdc3b9 100644 (file)
@@ -28,7 +28,8 @@ use Data::Dumper;
 
 my $AC = 'OpenILS::WWW::AddedContent';
 
-my $blank_img = 'http://images.concat.ca/opac/images/blank.png';
+# This should work for most setups
+my $blank_img = 'http://localhost/opac/images/blank.png';
 
 # This URL is always the same for OpenLibrary, so there's no advantage to
 # pulling from opensrf.xml
@@ -240,6 +241,16 @@ sub send_html {
     return { content_type => 'text/html', content => $HTML };
 }
 
+# proxy OpenLibrary requests so that the IP address of the library
+# can be used to determine access rights to materials
+sub proxy_json {
+    my( $self, $key ) = @_;
+
+    my $url = $read_api . $key;
+    $self->send_json($AC->get_url($url)->content());
+}
+
+
 # returns the HTTP response object from the URL fetch
 sub fetch_response {
     my( $self, $key ) = @_;