[open-ils-commits] [GIT] Evergreen ILS branch master updated. 8c3f0f89c62b094a12b426b965376ca5dbbd474a
Evergreen Git
git at git.evergreen-ils.org
Thu Jan 5 12:05:29 EST 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 8c3f0f89c62b094a12b426b965376ca5dbbd474a (commit)
via 9815279a598e7997a4bff907beae0f1da4ebc2f5 (commit)
via 48dc6f2010807f87edd6ac757ffb7e0430d7bff3 (commit)
via 692ccb6288e24041a91ffb4617562fa95449c65e (commit)
via e64c8643fedc3bf121d618aaf595d03cd3d685fd (commit)
from b5929b75fc408387140ef70feab7429d9919c952 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8c3f0f89c62b094a12b426b965376ca5dbbd474a
Merge: b5929b7 9815279
Author: Dan Scott <dscott at laurentian.ca>
Date: Thu Jan 5 12:01:27 2012 -0500
Merge remote-tracking branch 'working/user/artunit/resolver_resolver_timeout_2012_01_05' into dbs/resolver_resolver_timeout_2012_01_05
commit 9815279a598e7997a4bff907beae0f1da4ebc2f5
Author: Dan Scott <dscott at laurentian.ca>
Date: Thu Dec 22 17:42:03 2011 -0500
Resolver: Fix method signature for deleting cache entries
The order of arguments was incorrect and also contained an unnecessary
entry for the open-ils.resolver.delete_cached_holdings method signature.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Art <artrhyno at uwindsor.ca>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
index 81d1662..2a276dc 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
@@ -477,22 +477,18 @@ __PACKAGE__->register_method(
Deletes the cached value of the full-text holdings for a given ISBN or ISSN
DESC
'params' => [ {
+ name => 'url_base',
+ desc => 'The base URL for the resolver and instance',
+ type => 'string'
+ }, {
name => 'id_type',
desc => 'The type of identifier ("issn" or "isbn")',
- type => 'string'
+ type => 'string'
}, {
name => 'id_value',
desc => 'The identifier value',
type => 'string'
- }, {
- name => 'url_base',
- desc => 'The base URL for the resolver and instance',
- type => 'string'
- }, {
- name => 'request_timeout',
- desc => 'The timeout for the HTTP request',
- type => 'string'
- },
+ }
],
'return' => {
desc => 'Deletes the cached value of the full-text holdings for a given ISBN or ISSN',
diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2
index 51798fb..f081747 100644
--- a/Open-ILS/src/templates/opac/parts/record/summary.tt2
+++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2
@@ -52,7 +52,7 @@
</div>
[%- IF openurl.enabled == 'true';
- openurls = []
+ openurls = [];
FOREACH issn IN args.issns;
NEXT IF issn == '';
openurls = openurls.import(ResolverResolver.resolve_issn(issn, openurl.baseurl));
commit 48dc6f2010807f87edd6ac757ffb7e0430d7bff3
Author: Dan Scott <dscott at laurentian.ca>
Date: Thu Dec 22 17:13:29 2011 -0500
OpenURL resolution in TPAC - further cleanup
We appear to be getting one null or empty value in the args.issns array,
which was causing spurious lookups of null ISSNs, so skip the entry if
it is an empty string.
Also, switch from the product-specific "sfx" variable name to the
product-neutral "openurls" as we have CUFTS in the mix these days.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Art <artrhyno at uwindsor.ca>
diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2
index e21b086..51798fb 100644
--- a/Open-ILS/src/templates/opac/parts/record/summary.tt2
+++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2
@@ -52,17 +52,18 @@
</div>
[%- IF openurl.enabled == 'true';
- sfx = []
- FOR issn IN args.issns;
- sfx = sfx.import(ResolverResolver.resolve_issn(issn, openurl.baseurl));
+ openurls = []
+ FOREACH issn IN args.issns;
+ NEXT IF issn == '';
+ openurls = openurls.import(ResolverResolver.resolve_issn(issn, openurl.baseurl));
END;
- IF sfx.size && sfx.0 != '';
+ IF openurls.size && openurls.0 != '';
%]
<div id='rdetail_openurl'>
<strong class='rdetail_openurl_title'>[% l("Electronic resources") %]</strong>
<table><tbody>
[%-
- FOR res IN sfx;
+ FOREACH res IN openurls;
%]
<tr>
<td class='rdetail_openurl_entry'><a href="[% res.target_url %]">[% res.public_name %]</a></td>
@@ -71,7 +72,7 @@
[%- END %]
</tbody></table>
[%- END %]
-[%- IF sfx.size && sfx.0 != '' %]
+[%- IF openurls.size && openurls.0 != '' %]
</div>
[%- END %]
[%- merged_uris = args.uris.merge(args.online_res);
diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2
index a5a9ea3..8312379 100644
--- a/Open-ILS/src/templates/opac/parts/result/table.tt2
+++ b/Open-ILS/src/templates/opac/parts/result/table.tt2
@@ -91,9 +91,10 @@
</tr>
[% END %]
[%- IF openurl.enabled == 'true';
- FOR issn IN args.issns;
- sfx = ResolverResolver.resolve_issn(issn, openurl.baseurl);
- FOR res IN sfx;
+ FOREACH issn IN args.issns;
+ NEXT IF issn == '';
+ res_urls = ResolverResolver.resolve_issn(issn, openurl.baseurl);
+ FOREACH res IN res_urls;
%]
<tr name="results_issn_tr">
<td valign="top">
commit 692ccb6288e24041a91ffb4617562fa95449c65e
Author: Dan Scott <dscott at laurentian.ca>
Date: Thu Dec 22 16:08:07 2011 -0500
Make resolver HTTP timeout setting implementation neutral
Rather than exposing the underlying mechanism (LWP) for the HTTP
request via the "lwp_timeout" setting, use "request_timeout" so that if
we switch to a different HTTP library the setting name doesn't
contradict it.
Also, add an example setting to opensrf.xml.example.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Art <artrhyno at uwindsor.ca>
diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example
index 2fea59d..eabd6fc 100644
--- a/Open-ILS/examples/opensrf.xml.example
+++ b/Open-ILS/examples/opensrf.xml.example
@@ -1106,6 +1106,7 @@ vim:et:ts=4:sw=4:
</unix_config>
<app_settings>
<cache_timeout>86400</cache_timeout>
+ <request_timeout>10</request_timeout>
<default_url_base>http://path/to/sfx_or_cufts</default_url_base>
<resolver_type>sfx</resolver_type>
</app_settings>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
index df99fac..81d1662 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
@@ -84,7 +84,7 @@ my $cache;
my $cache_timeout;
my $default_url_base; # Default resolver location
my $resolver_type; # Default resolver type
-my $default_lwp_timeout; # Default browser timeout
+my $default_request_timeout; # Default browser timeout
our ($ua, $parser);
@@ -99,8 +99,8 @@ sub initialize {
$resolver_type = $sclient->config_value(
"apps", "open-ils.resolver", "app_settings", "resolver_type") || 'sfx';
# We set a browser timeout
- $default_lwp_timeout = $sclient->config_value(
- "apps", "open-ils.resolver", "app_settings", "lwp_timeout" ) || 60;
+ $default_request_timeout = $sclient->config_value(
+ "apps", "open-ils.resolver", "app_settings", "request_timeout" ) || 60;
}
sub child_init {
@@ -119,7 +119,7 @@ sub resolve_holdings {
my $id_type = shift; # keep it simple for now, either 'issn' or 'isbn'
my $id_value = shift; # the normalized ISSN or ISBN
my $url_base = shift || $default_url_base;
- my $lwp_timeout = shift || $default_lwp_timeout;
+ my $request_timeout = shift || $default_request_timeout;
if (!$id_type) {
$logger->warn("Resolver was not given an ID type to resolve");
@@ -131,7 +131,7 @@ sub resolve_holdings {
}
# Need some sort of timeout in case resolver is unreachable
- $ua->timeout($lwp_timeout);
+ $ua->timeout($request_timeout);
if ($resolver_type eq 'cufts') {
return cufts_holdings($self,$conn,$id_type,$id_value,$url_base);
@@ -397,8 +397,8 @@ Returns a list of "rhr" objects representing the full-text holdings for a given
desc => 'The base URL for the resolver and instance',
type => 'string'
}, {
- name => 'lwp_timeout',
- desc => 'The timeout for the LWP request',
+ name => 'request_timeout',
+ desc => 'The timeout for the HTTP request',
type => 'string'
},
],
@@ -431,8 +431,8 @@ Returns a list of raw JSON objects representing the full-text holdings for a giv
desc => 'The base URL for the resolver and instance',
type => 'string'
}, {
- name => 'lwp_timeout',
- desc => 'The timeout for the LWP request',
+ name => 'request_timeout',
+ desc => 'The timeout for the HTTP request',
type => 'string'
},
],
@@ -489,8 +489,8 @@ Deletes the cached value of the full-text holdings for a given ISBN or ISSN
desc => 'The base URL for the resolver and instance',
type => 'string'
}, {
- name => 'lwp_timeout',
- desc => 'The timeout for the LWP request',
+ name => 'request_timeout',
+ desc => 'The timeout for the HTTP request',
type => 'string'
},
],
commit e64c8643fedc3bf121d618aaf595d03cd3d685fd
Author: Art Rhyno <artrhyno at uwindsor.ca>
Date: Wed Dec 14 20:13:30 2011 -0500
Timeout for resolver interactions
These changes add some timeout options for using the resolver
setup. For example:
request open-ils.resolver open-ils.resolver.resolve_holdings "issn", \
"0013-0618", "http://sfx.scholarsportal.info/windsor", 10
where "10" is the number of seconds for a timeout. A default timeout can be
specified in the opensrf.xml file in the ResolverResolver section as well:
<lwp_timeout>30</lwp_timeout>
from TPAC, a request can be also include a timeout option:
[% IF openurl.enabled == 'true';
FOR issn IN args.resolver_issns;
resolver = ResolverResolver.resolve_issn(issn, openurl.baseurl,20);
FOR res IN resolver;
%]
where "20" is the number of seconds for a timeout.
In working through this, I found some bugs in my resolver collection
code in misc_util.tt2 for isbns which I have addressed.
Signed-off-by: Art Rhyno <artrhyno at uwindsor.ca>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
Signed-off-by: Art <artrhyno at uwindsor.ca>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
index 1351a68..df99fac 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/ResolverResolver.pm
@@ -84,6 +84,7 @@ my $cache;
my $cache_timeout;
my $default_url_base; # Default resolver location
my $resolver_type; # Default resolver type
+my $default_lwp_timeout; # Default browser timeout
our ($ua, $parser);
@@ -96,10 +97,14 @@ sub initialize {
$default_url_base = $sclient->config_value(
"apps", "open-ils.resolver", "app_settings", "default_url_base");
$resolver_type = $sclient->config_value(
- "apps", "open-ils.resolver", "app_settings", "resolver_type");
+ "apps", "open-ils.resolver", "app_settings", "resolver_type") || 'sfx';
+ # We set a browser timeout
+ $default_lwp_timeout = $sclient->config_value(
+ "apps", "open-ils.resolver", "app_settings", "lwp_timeout" ) || 60;
}
sub child_init {
+
# We need a User Agent to speak to the SFX beast
$ua = new LWP::UserAgent;
$ua->agent('SameOrigin/1.0');
@@ -114,6 +119,19 @@ sub resolve_holdings {
my $id_type = shift; # keep it simple for now, either 'issn' or 'isbn'
my $id_value = shift; # the normalized ISSN or ISBN
my $url_base = shift || $default_url_base;
+ my $lwp_timeout = shift || $default_lwp_timeout;
+
+ if (!$id_type) {
+ $logger->warn("Resolver was not given an ID type to resolve");
+ return;
+ }
+ if (!$id_value) {
+ $logger->warn("Resolver was not given an ID value to resolve");
+ return;
+ }
+
+ # Need some sort of timeout in case resolver is unreachable
+ $ua->timeout($lwp_timeout);
if ($resolver_type eq 'cufts') {
return cufts_holdings($self,$conn,$id_type,$id_value,$url_base);
@@ -158,13 +176,25 @@ sub cufts_holdings{
return $result;
}
- # Otherwise, let's go and grab the info from the CUFTS server
- my $req = HTTP::Request->new('GET', "$url_base$url_args");
+ my $res = undef;
# Let's see what we we're trying to request
$logger->info("Resolving the following request: $url_base$url_args");
- my $res = $ua->request($req);
+ # We attempt to deal with potential problems in request
+ eval {
+ $res = $ua->get("$url_base$url_args");
+ } or do {
+ $logger->info("execution error");
+ return bow_out_gracefully("$url_base?ctx_ver=Z39.88-2004&rft.$id_type=$id_value",
+ 'Check link for additional holdings information.');
+ };
+
+ if ($res->status_line =~ /timeout/) {
+ $logger->info("timeout error");
+ return bow_out_gracefully("$url_base?ctx_ver=Z39.88-2004&rft.$id_type=$id_value",
+ 'Check link for additional holdings information.');
+ }
my $xml = $res->content;
my $parsed_cufts = $parser->parse_string($xml);
@@ -264,14 +294,27 @@ sub sfx_holdings{
return $result;
}
- # Otherwise, let's go and grab the info from the SFX server
- my $req = HTTP::Request->new('GET', "$url_base$url_args");
+ my $res = undef;
# Let's see what we we're trying to request
$logger->info("Resolving the following request: $url_base$url_args");
- my $res = $ua->request($req);
+ # We attempt to deal with potential problems in request
+ eval {
+ $res = $ua->get("$url_base$url_args");
+ } or do {
+ $logger->info("execution error");
+ return bow_out_gracefully("$url_base?ctx_ver=Z39.88-2004&rft.$id_type=$id_value",
+ 'Check link for additional holdings information.');
+ };
+
+ if ($res->status_line =~ /timeout/) {
+ $logger->info("timeout error");
+ return bow_out_gracefully("$url_base?ctx_ver=Z39.88-2004&rft.$id_type=$id_value",
+ 'Check link for additional holdings information.');
+ }
+ # All clear
my $xml = $res->content;
my $parsed_sfx = $parser->parse_string($xml);
@@ -315,6 +358,23 @@ sub sfx_holdings{
return undef;
}
+# This uses the resolver structure for passing back a link directly to the resolver
+sub bow_out_gracefully {
+ my $alt_url = $_[0];
+ my $reason = $_[1];
+
+ my @sfx_result;
+
+ push @sfx_result, {
+ public_name => "Online holdings",
+ target_url => $alt_url,
+ target_coverage => $reason,
+ target_embargo => "",
+ };
+
+ return \@sfx_result;
+}
+
__PACKAGE__->register_method(
method => 'resolve_holdings',
api_name => 'open-ils.resolver.resolve_holdings',
@@ -336,6 +396,10 @@ Returns a list of "rhr" objects representing the full-text holdings for a given
name => 'url_base',
desc => 'The base URL for the resolver and instance',
type => 'string'
+ }, {
+ name => 'lwp_timeout',
+ desc => 'The timeout for the LWP request',
+ type => 'string'
},
],
'return' => {
@@ -366,6 +430,10 @@ Returns a list of raw JSON objects representing the full-text holdings for a giv
name => 'url_base',
desc => 'The base URL for the resolver and instance',
type => 'string'
+ }, {
+ name => 'lwp_timeout',
+ desc => 'The timeout for the LWP request',
+ type => 'string'
},
],
'return' => {
@@ -420,6 +488,10 @@ Deletes the cached value of the full-text holdings for a given ISBN or ISSN
name => 'url_base',
desc => 'The base URL for the resolver and instance',
type => 'string'
+ }, {
+ name => 'lwp_timeout',
+ desc => 'The timeout for the LWP request',
+ type => 'string'
},
],
'return' => {
diff --git a/Open-ILS/src/perlmods/lib/Template/Plugin/ResolverResolver.pm b/Open-ILS/src/perlmods/lib/Template/Plugin/ResolverResolver.pm
index 88109c2..b81b77f 100644
--- a/Open-ILS/src/perlmods/lib/Template/Plugin/ResolverResolver.pm
+++ b/Open-ILS/src/perlmods/lib/Template/Plugin/ResolverResolver.pm
@@ -62,12 +62,12 @@ sub ResolverResolver::params {
sub resolve_issn
{
- my ($class, $c, $baseurl) = @_;
+ my ($class, $issn, $baseurl, $timeout) = @_;
- if (length($c) <= 9) {
+ if (length($issn) <= 9) {
my $session = OpenSRF::AppSession->create("open-ils.resolver");
- my $request = $session->request("open-ils.resolver.resolve_holdings.raw", "issn", $c, $baseurl)->gather();
+ my $request = $session->request("open-ils.resolver.resolve_holdings.raw", "issn", $issn, $baseurl, $timeout)->gather();
if ($request) {
return $request;
}
@@ -79,11 +79,11 @@ sub resolve_issn
sub resolve_isbn
{
- my ($class, $c, $baseurl) = @_;
+ my ($class, $isbn, $baseurl, $timeout) = @_;
my $session = OpenSRF::AppSession->create("open-ils.resolver");
- my $request = $session->request("open-ils.resolver.resolve_holdings.raw", "isbn", $c, $baseurl)->gather();
+ my $request = $session->request("open-ils.resolver.resolve_holdings.raw", "isbn", $isbn, $baseurl, $timeout)->gather();
if ($request) {
return $request;
diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2
index b18e678..70c4f43 100644
--- a/Open-ILS/src/templates/opac/parts/misc_util.tt2
+++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2
@@ -60,36 +60,37 @@
args.holdings = [];
args.uris = [];
args.issns = [];
+ args.resolver_isbns = [];
+ args.resolver_issns = [];
# we use $9 of ISBN and ISSN as a flag for e-version
- sfx_isbn = xml.findnodes('//*[@tag="020"]/*[@code="9"]');
- IF sfx_isbn;
- IF sfx_isbn.textContent == "SFX";
- my_parent = sfx_isbn.parentNode();
- sfx_isbn = my_parent.findnodes('./*[@code="a"]').textContent;
- sfx_isbn = sfx_isbn.replace('-', '');
- args.resolver_isbn = sfx_isbn.replace('\ .*', '');
+ FOR resolver_isbn IN xml.findnodes('//*[@tag="020"]/*[@code="9"]');
+ IF resolver_isbn.textContent == "SFX" || resolver_isbn.textContent == "CUFTS";
+ my_parent = resolver_isbn.parentNode();
+ FOR resolver_isbn_val IN my_parent.findnodes('./*[@code="a"]');
+ args.resolver_isbns.push(
+ resolver_isbn_val.textContent.replace('-', '').replace('\ .*', '')
+ );
+ END;
END;
END;
- sfx_issn = xml.findnodes('//*[@tag="022"]/*[@code="9"]');
- IF sfx_issn;
- IF sfx_issn.textContent == "SFX";
- my_parent = sfx_issn.parentNode();
- sfx_issn = my_parent.findnodes('./*[@code="a"]');
- args.issns.push(
- sfx_issn.textContent.replace('[^\d\-X]', '')
- );
+ FOR resolver_issn IN xml.findnodes('//*[@tag="022"]/*[@code="9"]');
+ IF resolver_issn.textContent == "SFX" || resolver_issn.textContent == "CUFTS";
+ my_parent = resolver_issn.parentNode();
+ FOR resolver_issn_val IN my_parent.findnodes('./*[@code="a"]');
+ args.resolver_issns.push(
+ resolver_issn_val.textContent.replace('[^\d\-X]', '')
+ );
+ END;
END;
END;
- # we snag all issns if no SFX available
- IF args.issns.size == 0;
- FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
- args.issns.push(
- rawissn.textContent.replace('[^\d\-X]', '')
- );
- END;
+ # now snag all issns
+ FOR rawissn IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
+ args.issns.push(
+ rawissn.textContent.replace('[^\d\-X]', '')
+ );
END;
FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/examples/opensrf.xml.example | 1 +
.../lib/OpenILS/Application/ResolverResolver.pm | 94 +++++++++++++++++---
.../lib/Template/Plugin/ResolverResolver.pm | 10 +-
Open-ILS/src/templates/opac/parts/misc_util.tt2 | 45 +++++-----
.../src/templates/opac/parts/record/summary.tt2 | 13 ++--
Open-ILS/src/templates/opac/parts/result/table.tt2 | 7 +-
6 files changed, 121 insertions(+), 49 deletions(-)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list