Access Keys:
Skip to content (Access Key - 0)
My Area (Access Key - 2)


Toggle Sidebar
Your Rating: Results: PatheticBadOKGoodOutstanding! 15 rates
Labels:
webvoyage webvoyage Delete
intermediate intermediate Delete
export export Delete
xslt xslt Delete
ims ims Delete
vle vle Delete
elympics elympics Delete
openurl openurl Delete
sfx sfx Delete
refworks refworks Delete
endnote endnote Delete
ris ris Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Tomcat WebVoyage Enhancer

Tags: , , , , , , , , , , ,
Last Updated: Mar 08, 2011 14:37


  • Description

    WebVoyáge Enhancer is a perl daemon that sits between Apache and Tomcat. It intercepts requests and responses and allows customisation of responses before they reach Apache and user's browser. WebVoyáge Enhancer has a modular design, and most of the built-in functionality is to provide a framework for plugins.

  • Features:
    • String translations
    • Extensibility
    • Plugins (see below for further information)
      • Enhanced OpenURLs
      • Short holdings summary
      • Open links to external sites in a new window
      • Reference Management (extended print/export options)
      • Improved patron information screen
      • Fixes to navigation of component parts (related records)
      • Reordering of the "search within" drop-down options in Advanced Search
      • Enhancements to patron request screens (e.g. hiding the barcode field)
      • Links from 856 fields in search results lists
      • Show links to host records for component parts in results list
    • Plugins can be enabled or disabled as needed so that unnecessary functionality is not loaded or executed

The Enhancer is designed to be light on resource usage. In normal scenarios memory and CPU consumption should not be an issue. Some plugins have features that may have performance implications. E.g. if plugin_elinks may need to read all bib and mfhd records (depending on configuration options) of a search result page. However, at least on our systems even this has not affected performance noticeably.


  • Author: Ere Maijala
  • Additional author(s):
  • Institution: None
  • Year: 2010
  • License: MPL 1.1 / GPL 2.0
  • Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
  • Link to terms: MPL 1.1, GPL 2.0
  • Skill required for using this code: intermediate

State

Stable (in production)

Programming language

Perl

Software requirements

Tomcat WebVoyáge. Tested in Voyager 7.2.1 (any feedback on problems in other versions welcome)

Screen captures

Download

Version 1.8

Working example

https://tyrni.amkit.fi/vwebv/searchBasic?sk=en_US
https://masto.amkit.fi/vwebv/searchBasic?sk=fi_EN

Using the following Ex Libris open interfaces

-

Changes

Version 1.8 - 3 March 2011

  • Fixed opening references in new window
  • Fix getting "subfield" from a fixed field
  • plugin_component_parts: Improved handling of missing identifiers and database handles
  • plugin_patron_data: Improved error checking and handling
  • plugin_patron_data: Implemented support for external authentication
  • plugin_patron_data: Fixed normalization of login id's (e.g. SSN)
  • plugin_requests: Modify only HOLD requests to avoid messing with CALLSLIPs

Version 1.73 - 2 December 2010

  • plugin_openurl: Improved OpenURL creation for title fields and page numbers
  • plugin_component_parts: Improved normalization of linking fields so that trailing periods don't break linking

Version 1.72 - 6 October 2010 (The Bug Fix Day)

  • Fixed several SQL statement leaks

Version 1.71 - 6 October 2010

  • plugin_openurl: fixed wrong url_encode call

Version 1.7 - 6 October 2010

  • plugin_component_parts and plugin_elinks: process also the last record in results lists displaying 25 records
  • Improved performance by loading Oracle libraries upon startup (whether it makes any difference, I don't know)
  • Reloading configuration is now done via exiting child processes, just in case loading modules in child processes has an effect on memory usage (child processes not being able to share static data)

Version 1.6 - 17 September 2010

  • plugin_component_parts: added links to host records in results lists
  • plugin_holdings: added sorting of locations to
  • plugin_openurl: added customization options to OpenURL settings (e.g. open in a new dialog)
  • Fixed line endings (Windows -> Unix) in wv_enhancer.sh

Version 1.5 - 15 July 2010

  • Added plugin_elinks that allows displaying of links from 856 fields of bib and mfhd records in the search results lists
  • plugin_patron_data: fixed compilation

Version 1.4 - 7 July 2010

  • Added plugin_requests that allows enhancements to the patron request screens, e.g. hiding barcode entry
  • plugin_patron_data: display the active barcode instead of any barcode

Version 1.3 - 2 July 2010

  • Added plugin_search_order that allows reordering of the "search within" drop-down options in the Advanced Search tab

Version 1.21 - 28 June 2010

  • Oracle environment variables are now set from voyager.env if they're not already set. This makes it easier to start WebVoyáge Enhancer e.g. from Solaris SMF.

Version 1.20 - 16 June 2010

  • Changed renewal count display in plugin_patron_data to work properly with the markup in Voyager 7.2.1
  • Fixed plugin_holdings_summary to show the summary also after a patron request (e.g. a hold request) has been made

Version 1.18 - 17 May 2010

  • Fixed a typo from wv_enhancer.sh restart function (test -> then)
  • Fixed the version number wv_enhancer reports on startup

Version 1.17 - 12 May 2010

  • Added plugin_component_parts that fixes the navigation of component parts (WebVoyáge bug, hopefully will be resolved in a future version)
  • Added send_request method to the utils class for sending requests to Tomcat
  • Fixed plugin_openurl so that it works in Staff View too

Version 1.16 - 26 Apr 2010

  • Added a safeguard counter to child reaper
  • Fixed the URL check in plugin_references to be language-independent

Version 1.14 - 1 Apr 2010

  • Fixed child process accounting so that "maximum children" setting works properly
  • Fixed startup script to also work with an empty USER

Version 1.13 - 29 Mar 2010

  • Fixed OpenURL and holdings summary plugins to work properly when the search results in a single record

Version 1.12 - 9 Mar 2010

  • Improved handling of child processes in busy environments

Version 1.1 - 23 Feb 2010

  • General: Added dynamic reloading of configuration and plugins when configuration file has been updated. Invalid configuration or plugins with errors are rejected without disrupting the service
  • General: Added keepalive timeout that will close a connection after a specified timeout. This might help avoid too many Tomcat processes
  • plugin_patron_data: Added possibility to display renewal count and limit in patron's charged items
  • plugin_patron_data: Now exposes get_patron_id function that can be used to retrieve the ID of a logged-in patron

Version 1.0 - 8 Feb 2010

  • Initial release

Installation instructions

Extract the package somewhere, e.g. /m1/voyager/xxxdb/local/wv_enhancer. This path is used throughout these instructions, change as necessary. Note that by default you will need root permissions to change Apache configuration and restart it.

  1. Make wv_enhancer.sh and wv_enhancer.pl executable (chmod +x ...)
  2. Edit wv_enhancer.sh and change paths in CONFIG, DIR, DAEMON, PIDFILE and USER accordingly.
  3. Edit wv_enhancer.config. The most important settings are in general and tomcat stanzas.
    1. Settings are described in the table below.
    2. Tomcat address and port can be found in /m1/shared/apache2/conf/jk/workers.properties
  4. Add wv_enhancer.sh to the system startup
    1. This can be accomplished in many ways depending on the OS. See possible ways in the beginning of wv_enhancer.sh
    2. wv_enhancer does not need to be run by root. Set USER to e.g. voyager in wv_enhancer.sh to run as a different user.
  5. Start wv_enhancer and verify that the log shows it has started up.
  6. Test that wv_enhancer can connect to Tomcat by using telnet on the server:

    If telnet reports that it is connected, everything is good so far. Exit telnet by entering the escape combination it says and entering command quit. If instead it spits out some garbage and HTML regarding the service being unavailable, it means the Tomcat address or port is wrong, or Tomcat is not running.

  7. Redirect Apache to use WebVoyáge Enhancer instead of going directly to Tomcat by modifying /m1/shared/apache2/conf/jk/workers.properties. You will probably need root permissions to do this. Comment out the original setting for worker.ajp13_lb_xxxdb_vwebv.port and add the new definition. Example:
  8. Restart Apache for the change to take effect (e.g. run as root the command '/m1/shared/apache2/bin/apachectl restart')
  9. Test that everything works. If you encounter any trouble, consult wv_enhancer.log and /m1/shared/apache2/logs/mod_jk.log
    If you encounter trouble in WebVoyáge after implementing WebVoyáge Enhancer, try switching Apache back to using Tomcat directly to see if WebVoyáge Enhancer is the culprit.

Upgrading to a New Version

Upgrading to a new version is usually simple. You can just replace all but the config file and the startup script. Without any further changes the functionality should not be affected (apart from bug fixes) unless noted in the release notes. You can then modify the configuration file to enable new or additional features. See the documentation below and the distributed config file for examples of new configuration directives.

New Configuration Directives in Version 1.7

No new directives were introduced in this version.

New Configuration Directives in Version 1.6

Log Files

If debugging is enabled, wv_enhancer.log may grow quickly. Debug mode is not recommended for production systems except for possible troubleshooting. If debug=2, dump.dat will grow even faster.

If the daemon crashes, any output can be found in wv_enhancer.log.err. It could be useful to determine the reason.

As usual, it is a good idea to monitor the growth of the log file and/or implement a suitable log rotation scheme. The daemon does not keep the file open, so it can be archived or removed at any time. Log rotation can be done with e.g. logadm, logrotate or a simple crontab entry. Here is an example crontab entry that rotates the log every Sunday at midnight and keeps the last two log files:

Diagram of the Data Flow

Settings

Stanza Setting Required Notes
general log file yes Well, the log file
Path is relative to the working directory
general debug no Logging level. 0 = no debug logging, 1 = normal debug logging, 2 = debug logging plus tcp packets dumped into dump.dat. 0 is recommended for production use, as debug data will cause the log file (or dump.dat) to grow quickly
general listening address yes IP address WebVoyáge Enhancer binds to. If it's running on the same server as Apache, use 127.0.0.1 (localhost)
general listening port yes TCP port WebVoyáge Enhancer binds to. Use a non-conflicting port such as the normal Tomcat port + 20000. See instructions above on how to find the Tomcat port
general env file yes Voyager's env file. Used to retrieve database settings
general maximum children no Maximum number of child processes. A safeguard against unexpected problems.
general connection error status no Custom HTTP status to be returned if WebVoyáge Enhancer is unable to connect to Tomcat (default: 503)
general connection error message no Custom error message to be returned if WebVoyáge Enhancer is unable to connect to Tomcat (default: Service Temporarily Unavailable)
general keepalive timeout no Time in seconds until the connection between Apache, WebVoyáge Enhancer and Tomcat is closed as inactive. Might help keep the number of Tomcat processes down. N.B. Do not set to a too low value (e.g. less than 60) or the connection might time out while a request is being processed
tomcat server address yes Tomcat's listening address. If Tomcat is running on the same server, use 127.0.0.1
tomcat server port yes Tomcat's listening port. See instructions above on how to find the Tomcat port
oracle parameters no Parameters passed to DBI. Only to override defaults from env file.
oracle username no Username passed to DBI. Only to override defaults from env file.
oracle password no Password passed to DBI. Only to override defaults from env file.
oracle tablespace no Tablespace used in database queries. Only to override defaults from env file.
translation global no Language-independent translation file. Used for all pages.
translation (language code) no Language-dependent translation file. Used for all pages in the given language. Language code is retrieved from the <html> tag of the page. It is defined in /m1/voyager/xxxdb/tomcat/vwebv/context/vwebv/ui/<skin>/xsl/pageTools/framework.xsl. Default is 'en'
plugins preprocessing module (no) no Preprocessing plugins. (no) is an index starting from one. Use consequent numbers
plugins postprocessing module (no) no Postprocessing plugins. (no) is an index starting from one. Use consequent numbers

WebVoyáge Enhancer reloads the configuration and plugins whenever the timestamp of the configuration file changes. You can use touch command to update the timestamp after modifying a plugin, avoiding the need to restart the daemon. Note that it can take up to 10 seconds for the reload to happen, and it won't affect the listening address and port or database connection settings. Invalid configuration or plugins with errors are rejected without disrupting the service. See the log file for possible errors if the changes don't take effect. Note also that changing a module does not trigger a reload, only the timestamp of the configuration file is checked.

Translation Files

Translation files are simple text files that can be used to change any content in the HTML responses. Translation files are read line by line. There are two different types of translation lines:

  1. simple textual translations:

    original string is replaced with new string.

  2. Regular expressions:

    regexp is applied to the HTML.

Translations are applied only if content type is 'text/html;charset=UTF-8'.
Be careful not to translate strings commonly found in bibliographic records or other content. This can be avoided e.g. by adding tags or parts of them to the translation:

Plugins and Configuration

Plugins are called in the index number order. If a plugin is used for both preprocessing and postprocessing, it has to be listed in both. Index numbers need not be same.

Index numbers in the configuration file start from 1 and have to be consecutive.
If you need to modify a plugin, it might be a good idea to rename it to have _local or somesuch in the end (in addition to renaming the file, change also the package line in the file).

plugin_test

Provided as a very simple example or skeleton that can be used as a template for new plugins. By default it returns a simple custom HTML page if &test=1 is added to the URL, and rewrites page title "WebVoyáge Titles" to "WebVoyáge Results List".

plugin_links_in_new_window

Makes all links (<a href="...">) to external sites open in a new window. Does not require any configuration.

plugin_holdings_summary

Displays a condensed summary of holdings that replaces the holdings jump links.

Stanza Setting Required Notes
holdings summary items (language code) yes Text to display before item count
holdings summary available (language code) yes Text to display before available item count

plugin_patron_data

Displays extended patron information. Patron barcode is stored on login and used to fetch additional patron information for the patron display. This plugin is not yet complete. It can display user barcode and expiration date, but additional fields can be easily added.

Comment out any of the texts using a hash mark (#) to hide the field.

Stanza Setting Required Notes
patron data scratch dir yes Directory where temporary files containing the barcode are written
patron data barcode (language code) no Text to display before user's barcode
patron data expiration (language code) no Text to display before user record's expiration date
patron data renewals (language code) no Header text for renewal count and limit column in patron's charged items

plugin_patron_data exposes get_patron_id function that can be used to retrieve the ID of a logged-in patron. See the module itself for an example of the usage. Note that there is a small possibility that a valid ID is returned even though the user is not properly logged in, so use this only on pages a logged-in user can access.

plugin_references

Replaces the built-in Export function with an enhanced print/export function. The following features are provided:

  • XSL files to transform MARCXML to different formats
  • Redirection to e.g. RefWorks for direct import
  • Proper mime types, disposition and file name so that the browser knows to do The Right Thing (display on screen, offer to save the result, default to a sensible file name, automatically save to Zotero etc.)
  • Optionally open the results in a new window
  • Provide links back to Voyager in the records
  • Formats provided in the distribution:
    • HTML Reference List
    • HTML Reference List with Subjects
    • Refworks Tagged Format and a direct export to RefWorks
    • RIS (EndNote, ProCite, Reference Manager, etc.)
    • IMS Packages (Export records with added notes to virtual learning environments)
    • Raw MARCXML for advanced users

plugin_references calls xsltproc to do the actual transformation.

Stanza Setting Required Notes
references scratch dir yes Directory for temporary files
references format (no) id yes ID for the format (used in the form as the value of the selection)
references format (no) title (lang) yes Text displayed for the format in the given language
references format (no) stylesheet no Stylesheet used to transform the MARCXML
references format (no) window no Name of the window where results are opened (empty = same window, '_blank' = new window).
references format (no) type no Content type sent to the browser. Default is text/html in UTF-8. (see http://en.wikipedia.org/wiki/MIME#Content-Type for more information).
references format (no) disposition no Content disposition sent to the browser (see http://en.wikipedia.org/wiki/MIME#Content-Disposition for more information).
references format (no) backlink no Link back to WebVoyáge, added into the records in the XSL transformation. [001] is replaced with the tag contents.
references format (no) redirect no Address where the browser is redirected. $encodedurl is replaced with a link to the records, $url is the same but not url-encoded
references format (no) extra param no Extra parameters that can be used in the XSL file in the extra_param variable. E.g. IMS Package creation uses it to provide xslt a URL that will build the final package

plugin_openurl

Displays improved OpenURL links to e.g. SFX. This plugin requires that WebVoyáge is configured to display OpenURL's. It will replace the original OpenURL with the improved one and allows to hide the button if necessary metadata is not present.
All the functionality describing how the OpenURL is created is in the code. Due to its nature it would be difficult to provide settings that would achieve the same flexibility. The code is quite simple to modify. By default the plugin will try to build a nice OpenURL and display it only if ISSN is found. The OpenURL will contain the following fields: issn, date, volume, issue, spage, epage, isbn, doi (from 036), author and title.

Stanza Setting Required Notes
openurl dialog No Whether the OpenURL link is opened in a dialog (new window)
openurl dialog height No Dialog height in pixels
openurl dialog width No Dialog width in pixels
openurl dialog features No Features given to the dialog window
openurl extra parameters No Extra parameters given in the OpenURL
openurl link title No Title (tooltip) of the link

plugin_component_parts

Fixes the navigation in a list of component parts. There's a bug in WebVoyáge screwing up the result set when a record is displayed and breaking Next/Previous record navigation. The bug will hopefully be resolved in a future version, but meanwhile this plugin refreshes the record list in background and adds bibId parameters to Next/Previous record links to make them work properly.

Also adds a link to the host item to each component part in the results list. Most of the settings govern how the link is created.

Stanza Setting Required Notes
component parts fix links No Whether the plugin should fix the component part navigation problem described above
component parts add host item links No Whether the plugin should add links to host items
component parts show host item relationship No Whether the host link should display the relationship from field 773g
component parts remove no holdings text No Whether the "No holdings" text should be removed from component parts
component parts host link heading (lang) No A prefix for the host link

plugin_search_order

Allows configuration of the order in which the options are displayed in the "search within" drop-down in Advanced Search.

Stanza Setting Required Notes
search order advanced search no Comma-separated list of index codes. The first one is the default. It is not necessary to specify all index codes, but only those that need to be ordered in the beginning of the selection list.

plugin_requests

Depends on: plugin_patron_data

Provides enhancements to the patron request screens. Some of the features could be achieved with modifications to the xsl files, but they are provided here as a convenience.

Stanza Setting Required Notes
requests hide barcode no If set to 1, the mandatory barcode entry when making a request is disabled. The plugin will remove the field and add a hidden one prefilled with user's barcode. Requires that plugin_patron_data is in use so that user's barcode can be retrieved.
requests fix group selection no If set to 1, a small change to the form JavaScript for "Any Copy At" field is provided so that if the user selects a group from the drop-down menu, "Any Copy At" radio button is also selected.
requests disable this copy no If set to 1, item level requests are disabled.

plugin_elinks

Provides links from 856 fields of bib and/or mfhd records in the search results lists. No changes to template files are needed, but the added links can be styled as necessary using css. The containing div has class lineElink and the span that contains the link text has class elinkText.

Stanza Setting Required Notes
elinks bib links no Whether to create links from bib records. Set to 0 to disable.
elinks bib second indicators no Allowed second indicator values in the 856 field of a bib record. Underscore represents empty indicator. If the indicator value is not in the list, no link will be created from the field.
elinks bib link text subfields no List of subfield codes that contain possible link text to show. No separator character is needed, just enter e.g. yz. If no subfield is found, default text is used.
elinks bib link default text (lang) no Default link text to show if no value from a suitable subfield (as set above) is found. If empty, the link address is shown instead.
elinks mfhd links no Whether to create links from mfhd records. Set to 0 to disable.
elinks mfhd second indicators no Allowed second indicator values in the 856 field of a bib record. Underscore represents empty indicator. If the indicator value is not in the list, no link will be created from the field.
elinks mfhd link text subfields no List of subfield codes that contain possible link text to show. No separator character is needed, just enter e.g. yz. If no subfield is found, default text is used.
elinks mfhd link default text (lang) no Default link text to show if no value from a suitable subfield (as set above) is found. If empty, the link address is shown instead.
elinks new window=0 no If set to 1, the links will always open in a new window (or tab)

Writing New Plugins

New plugins can be easily added. plugin_test can be used as a template. Start by copying it to a new name and changing the package line to reflect the new name. WebVoyáge Enhancer calls preprocess function before the request is sent to Tomcat, and/or postprocess function before the response is sent to Apache. If preprocess return value is non-zero, the request will not be passed to Tomcat or further plugins, and the connection will be closed without further processing. Same applies for postprocess: if postprocess return value is non-zero, the original response will not be passed to Apache or further plugins.

Parameters passed to preprocess:

Parameter Notes
utils An instance of WvEnhancerUtils (see below)
apache Apache socket
tomcat Tomcat socket
request_attrs_ref A reference to a hash of attributes received in the request from Apache
headers_ref The actual header message received from Apache
headers_len_ref Length of above message
body_ref Any post data (e.g. form data) received from Apache
body_len_ref Length of above data

Currently any modifications to request_attrs_ref are not reflected in the request when it's passed to Tomcat. Modifications to headers_ref and body_ref are passed to Tomcat, but this has not yet been tested, and crafting them properly is somewhat complicated (e.g. Content-Length in headers must match the length of body data in bytes).

Parameters passed to postprocess:

Parameter Notes
utils An instance of WvEnhancerUtils (see below)
apache Apache socket
tomcat Tomcat socket
request_attrs_ref A reference to a hash of attributes received in the request from Apache
response_attrs_ref A reference to a hash of attributes received in the response from Tomcat
response_headers_ref The actual header message received from Tomcat
response_headers_len_ref Length of above message
content_ref Response content (body) received from Tomcat
content_len_ref Length of above data

Currently any modifications to response_attrs_ref are not reflected in the response when it's passed to Apache. Modifications to response_headers_ref and content_ref are passed to Apache, but as response_headers_ref is the raw message, crafting it properly is somewhat tedious.

WvEnhancerUtils class provides functions that help building plugins. The functions are documented in wv_enhancer_utils.pm. See documentation of parse_request and parse_response for information regarding typical attributes contained in request_attrs_ref and response_attrs_ref. You can also see the attributes in the log file when debug setting is enabled.

Runtime errors in plugin code don't cause the daemon to fail, but the error will be reported in the log file.

TO DO list

  • More plugins

Comments

Please comment if there's anything you'd like to see added, fixed or so

Page Attachments

File NameCommentSizeNumber of Downloads
wv_enhancer.zipWebVoyáge Enhancer Files v1.852 kB246

Added by Ere Maijala on Feb 08, 2010 15:51, last edited by Ere Maijala on Mar 08, 2011 14:37

  1. Oct 27, 2010

    This is how Auburn University Libraries implemented Ere Maijala's Tomcat Webvoyage Enhancer. We operate in a split server environment so setting this up proved to be a bit tricky. Many thanks to Ere for answering numerious emails from myself while I attempted to get this to work.

    We are on Voyager 7.2.1 and have a Database server on Solaris 10 and a Webserver on Solaris 9.

    Initially wv_enhancer complained of a missing library (libm.so.2). This was due to the difference in operating systems between our database and web server boxes. Libm.so.2 was present on our database server but not the web server where the wv_enhancer was to be installed. We copied libm.so.2 from our database server (/lib/libm.so.2) to our web server and put it in the same place (/lib/libm.so.2).

    Enhancer would now start, but we had several Oracle connection errors show up in wv_enhancer.log.err. First we made sure the .profile for the voyager user was correctly setting all the Oracle environmental variables (ORACLE_HOME, ORACLE_BASE, etc.) at login. This meant we had to create the directory structure for Oracle as it is on our database server (/oracle/app/oracle/product/10.2.0/db_1). We then copied over the nls and zoneinfo directories and their contents from the database server to the newly created Oracle directory on the web server.

    We also copied over /usr/local/bin/oraenv from the database server to the web server as it was missing from the web server. This helped with making sure the .profile of the voyager user on the web server got all it's enivronmental variables set correctly.

    Finally we downloaded the Oracle InstantClient Files from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. We choose the Basic Lite client for Solaris SPARC 64-bit for Oracle database version 10.2.0.3, but your hardware/database versions maybe different. You will get a .zip file that you have to extract all of it's contents into /oracle/app/oracle/product/10.2.0/db_1/lib32.

    After all that we were able to start wv_enhancer and receive no connection errors in the log files.

Adaptavist Theme Builder Powered by Atlassian Confluence