| 1 | # $Id: fulltext.pm,v 1.3 2007-07-19 16:11:55 mike Exp $ | ||
| 2 | |||
| 3 | package Keystone::Resolver::plugins::ServiceType::fulltext; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | |||
| 9 | ### A nice big comment is required describing the plugin interface. | ||
| 10 | |||
| 11 | # Returns undef if the service does not have the requested journal, or | ||
| 12 | # if its coverage does not include the requested volume/issue. | ||
| 13 | # | ||
| 14 | sub handle { | ||
| 15 | my $class = shift(); | ||
| 16 | my($openURL, $service) = @_; | ||
| 17 | |||
| 18 | my($serial, $errmsg) = $openURL->_serial(); | ||
| 19 | if (!defined $serial) { | ||
| 20 | # Serial not supported at all, first time of asking | ||
| 21 | return (undef, $errmsg, 1); | ||
| 22 | } elsif (!$serial) { | ||
| 23 | # Serial not supported at all, but we already knew that so | ||
| 24 | # there's no need to generate another message | ||
| 25 | return undef; | ||
| 26 | } | ||
| 27 | |||
| 28 | if (!$openURL->db()->service_has_serial($service, $serial)) { | ||
| 29 | # Journal not covered by this service: quiet failure, no error | ||
| 30 | $openURL->log(Keystone::Resolver::LogLevel::CHITCHAT, | ||
| 31 | , $service->render(), " lacks ", $serial->render()); | ||
| 32 | return undef; | ||
| 33 | } | ||
| 34 | $openURL->log(Keystone::Resolver::LogLevel::CHITCHAT, | ||
| 35 | $service->render(), " has ", $serial->render()); | ||
| 36 | |||
| 37 | # If a recipe is provided, then we use it to construct the URI. | ||
| 38 | # If not, then we take the service's tag as the name of a plugin, | ||
| 39 | # and invoke that to do the resolution. | ||
| 40 | my $recipe = $service->url_recipe(); | ||
| 41 | return $openURL->_makeURI($recipe) | ||
| 42 | if $recipe; | ||
| 43 | |||
| 44 | my $tag = $service->tag(); | ||
| 45 | eval { | ||
| 46 | require "Keystone/Resolver/plugins/Service/$tag.pm"; | ||
| 47 | }; if ($@) { | ||
| 48 | $openURL->warn("can't load service plugin '$tag': $@"); | ||
| 49 | return (undef, "service plug-in '$tag' not defined", 1); | ||
| 50 | } | ||
| 51 | |||
| 52 | return "Keystone::Resolver::plugins::Service::$tag"->uri($openURL); | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | 1; |