OpenILS::Application::Search::AddedContent is now just a dummy file
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Dec 2005 19:42:33 +0000 (19:42 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Dec 2005 19:42:33 +0000 (19:42 +0000)
that returns empty sets for all methods.

The real added content code now lives in the Evergreen tree in
vendor-specific modules (only ContentCafe for now)

The added content handler is defined in the config file.  If not defined
the default is used

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2551 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/Makefile
Open-ILS/examples/openils.xml.example
Open-ILS/src/perlmods/OpenILS/Application/Search.pm
Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm
Open-ILS/web/opac/common/js/added_content.js

index cfe31c1..97124b1 100644 (file)
@@ -26,6 +26,11 @@ xul:
        find local_staff_client/ -type f -exec sed -i s/gapines.org/${NEW_OPAC_URL}/g {} \;
        make -C local_staff_client package
 
+perl-install:
+       @echo $@
+       mkdir -p $(PERLDIR)
+       cp -r src/perlmods/* $(PERLDIR)
+
 circ-install:
        @echo $@
        mkdir -p $(CIRCRULESDIR)
index 56c1f25..15631c7 100644 (file)
@@ -147,6 +147,19 @@ For non-core config info, see the inline documentation within this file
                                        <memcache>127.0.0.1:10101</memcache>
                                        <max_cache_time>3600</max_cache_time>
                                        <marc_html_xsl>oilsMARC21slim2HTML.xsl</marc_html_xsl>
+                                       <added_content>
+                                               <!-- 
+                                                       Example added content handler.  If this is not defined, the default
+                                                       content handler is used, which returns empty sets for all methods       
+                                               -->
+                                               <!--
+                                               <implementation>Evergreen::Application::Search::AddedContent::ContentCafe</implementation>
+                                               <host>MY_CONTENT_HOST</host>
+                                               <username>MY_CONTENT_USERNAME</username>
+                                               <password>MY_CONTENT_PASSWORD</password>
+                                               -->
+                                       </added_content>
+
                                </app_settings>
 
                        </open-ils.search>
index 1d2dc50..87652f9 100644 (file)
@@ -2,6 +2,7 @@ package OpenILS::Application::Search;
 use base qw/OpenSRF::Application/;
 use strict; use warnings;
 use JSON;
+use OpenSRF::Utils::Logger qw(:logger);
 
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Utils::ModsParser;
@@ -14,7 +15,7 @@ use OpenILS::Application::Search::Biblio;
 use OpenILS::Application::Search::Authority;
 use OpenILS::Application::Search::Actor;
 use OpenILS::Application::Search::Z3950;
-use OpenILS::Application::Search::AddedContent;
+
 
 use OpenILS::Application::AppUtils;
 
@@ -28,7 +29,23 @@ use Text::Aspell; # spell checking...
 
 sub initialize {
        OpenILS::Application::Search::Z3950->initialize();
-       OpenILS::Application::Search::AddedContent->initialize();
+
+       # try to load the added content handler
+       my $conf = OpenSRF::Utils::SettingsClient->new;
+       my $implementation = $conf->config_value(                                       
+               "apps", "open-ils.search","app_settings", "added_content", "implementation" );
+
+       if($implementation) {
+               eval "use $implementation";
+               if($@) {        
+                       $logger->error("Unable to load Added Content handler: $@"); 
+                       return; 
+               }
+               $implementation->initialize();
+
+       } else { #if none is defined, use the default which returns empty sets
+               eval "use OpenILS::Application::Search::AddedContent";
+       }
 }
 
 sub filter_search {
index 75981a3..6c5ec17 100644 (file)
 package OpenILS::Application::Search::AddedContent;
 use base qw/OpenSRF::Application/;
 use strict; use warnings;
-use OpenILS::Application::AppUtils;
-use OpenSRF::Utils::SettingsClient;
-my $apputils = "OpenILS::Application::AppUtils";
-use XML::LibXML;
-use LWP::UserAgent;
-use OpenSRF::EX qw(:try);
-
-my $host;
-my $username;
-my $password;
-my $enabled = 0;
-my $urlbase = "ContentCafe";
-my $types = {
-       toc                     => "TOC.asmx",
-       review          => "Review.asmx",
-       annotation      => "Annotation.asmx",
-       member          => "Member.asmx",
-       };
-
-sub initialize {
-       my $conf = OpenSRF::Utils::SettingsClient->new;
-       $host = $conf->config_value(                                    
-               "apps", "open-ils.search","app_settings", "added_content", "host");
-       $username = $conf->config_value(                                        
-               "apps", "open-ils.search","app_settings", "added_content", "username");
-       $password = $conf->config_value(                                        
-               "apps", "open-ils.search","app_settings", "added_content", "password");
-
-       $enabled = 1 if ($host and $username and $password);
-}
-
-
-
-# Fetches the added content and returns the data as a string.
-# If not data is retrieved (or timeout occurs), undef is returned
-sub retrieve_added_content {
-       my( $type, $isbn, $summary ) = @_;
-       return undef unless ( $isbn && $isbn ne "" );
-
-       my $func = "fnDetailByItemKey";
-       if($summary) { $func = "fnContentByItemKey"; }
-
-       my $url = "$host/$urlbase/" . $types->{$type} . 
-               "/$func?UserId=$username&Password=$password&ItemKey=$isbn";
 
 
-       warn "Added Content URL: $url\n";
-
-       my $data = undef;
-       try {
-               alarm(15);
-               $data = LWP::UserAgent->new->get($url)->content;
-               alarm(0);
-       } catch Error with {
-               alarm(0);
-       };
-       alarm(0);
-
-#      warn "received content data:\n$data\n";
-       return $data;
-}
-
 __PACKAGE__->register_method(
        method  => "summary",
        api_name        => "open-ils.search.added_content.summary.retrieve",
        notes           => <<"  NOTE");
                Returns an object like so:
                        {
-                               Review : true/false,
-                               Inventory : true/false,
-                               Annotation : true/false,
-                               Jacket : true/false
-                               TOC : true/false
-                               Product : true/false
+                               Review          : true/false
+                               Inventory       : true/false
+                               Annotation      : true/false
+                               Jacket          : true/false
+                               TOC                     : true/false
+                               Product         : true/false
                        }
                This object indicates the existance of each type of added content for the given ISBN
                PARAMS( ISBN ),
        NOTE
 
 sub summary {
-       my( $self, $client, $isbn ) = @_;
-
-       if(!$enabled) {
-               return { 
-                       Review          => "false",
-                       Inventory       => "false",
-                       Annotation      => "false",
-                       Jacket          => "false",
-                       TOC                     => "false",
-                       Product         => "false",
-               };
-       }
-
-       my $data = retrieve_added_content( "member", $isbn, 1 );
-       return {} unless $data;
-       my $doc = XML::LibXML->new->parse_string($data);
-       my $summary = {};
-       return $summary unless $doc;
-
-       for my $node ( $doc->getDocumentElement->childNodes ) {
-               if( $node->localName ) {
-                       $summary->{$node->localName} = $node->textContent;      
-               }
-       }
-       return $summary;
+       return { 
+               Review          => "false",
+               Inventory       => "false",
+               Annotation      => "false",
+               Jacket          => "false",
+               TOC                     => "false",
+               Product         => "false",
+       };
 }
 
 
-
-
-
 __PACKAGE__->register_method(
        method  => "reviews",
        api_name        => "open-ils.search.added_content.review.retrieve.random",
@@ -128,44 +48,7 @@ __PACKAGE__->register_method(
                PARAMS( ISBN ),
        NOTE
 
-sub reviews {
-       my( $self, $client, $isbn ) = @_;
-
-       my $ret = [];
-       return $ret unless $enabled;
-       my $data = retrieve_added_content( "review", $isbn );
-       return $ret unless $data;
-       my $doc = XML::LibXML->new->parse_string($data);
-
-
-       if(!$doc) {
-               if( $self->api_name =~ /random/ ) { return undef; }
-               return $ret;
-       }
-
-       my $reviews = $doc->findnodes("//*[local-name()='Review']");
-
-       for my $rev ( $reviews->get_nodelist() ) {
-               my $revobj = {};
-               for my $node ($rev->childNodes) {
-
-                       if( $node->localName ) {
-                               if( $node->localName eq "ReviewText" ) {
-                                       $revobj ->{'text'} = $node->textContent;
-                               }
-                               if( $node->localName eq "ReviewLiteral" ) {
-                                       $revobj->{'info'} = $node->textContent;
-                               }
-
-                       }
-               }
-
-               if( $self->api_name =~ /random/ ) { return $revobj; }
-               push( @$ret, $revobj );
-       }
-
-       return $ret;
-}
+sub reviews { return []; }
 
 
 __PACKAGE__->register_method(
@@ -176,21 +59,7 @@ __PACKAGE__->register_method(
                PARAMS( ISBN ),
        NOTE
 
-sub toc {
-       my( $self, $client, $isbn ) = @_;
-
-       my $data = retrieve_added_content( "toc", $isbn );
-       return undef unless $data;
-       my $doc = XML::LibXML->new->parse_string($data);
-
-       my @nodes =  $doc->findnodes("//*[local-name()='TOCText']")->get_nodelist();
-               
-       if($nodes[0]) {
-               return $nodes[0]->textContent;
-       }
-
-       return "";
-}
+sub toc { return ""; }
 
 
 1;
index 5ec7d1e..5bc352e 100644 (file)
@@ -1,5 +1,8 @@
-// This example function uses amazon to get cover art
+/**
+* This function should return a URL which points to the book cover image based on ISBN.
+* Ideally, this should point to some type of added content service.
+* The example below uses Amazon... *use at own risk*
+*/
 function buildISBNSrc(isbn) {
        return "http://images.amazon.com/images/P/" + isbn + ".01._SCMZZZZZZZ_.jpg";
-}
-
+}