1 package OpenILS::Application::Search::AddedContent;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
4 use OpenILS::Application::AppUtils;
5 use OpenSRF::Utils::SettingsClient;
6 my $apputils = "OpenILS::Application::AppUtils";
9 use OpenSRF::EX qw(:try);
15 my $urlbase = "ContentCafe";
18 review => "Review.asmx",
19 annotation => "Annotation.asmx",
23 my $conf = OpenSRF::Utils::SettingsClient->new;
24 $host = $conf->config_value(
25 "apps", "open-ils.search","app_settings", "added_content", "host");
26 $username = $conf->config_value(
27 "apps", "open-ils.search","app_settings", "added_content", "username");
28 $password = $conf->config_value(
29 "apps", "open-ils.search","app_settings", "added_content", "password");
34 __PACKAGE__->register_method(
35 method => "added_content",
36 api_name => "open-ils.search.added_content.retrieve",
38 Returns a list values based on the added content type.
39 types include: toc, review, annotation
44 my( $self, $client, $isbn, $type ) = @_;
46 my $url = "$host/$urlbase/" . $types->{$type} .
47 "/fnDetailByItemKey?UserId=$username&Password=$password&ItemKey=$isbn";
49 warn "Added Content URL: $url\n";
54 $data = LWP::UserAgent->new->get($url)->content;
62 warn "received content data:\n$data\n";
64 return $data if(ref($data));
66 return _parse_content($type, $data);
70 my( $type, $data ) = @_;
72 my $doc = XML::LibXML->new->parse_string($data);
74 return $ret unless $doc;
76 if( $type eq "review" ) {
79 warn $doc->toString(1) . "\n";
82 my $nodelist = $doc->findnodes("//*[local-name()='ReviewText']");
83 for my $rev ( $nodelist->get_nodelist() ) {
84 push( @$ret, $rev->textContent );