vivo/doc/setting_up_orng.html

726 lines
No EOL
29 KiB
HTML

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Setting up VIVO to use OpenSocial Gadgets</title>
<link rel="stylesheet" href="./css/doc.css" media="screen">
</head>
<body>
<div id="branding" role="banner">
<h1 class="vivo-logo"><a href="/"><span class="displace">VIVO</span></a></h1>
</div>
<!-- Start of content -->
<div id="wrapper-content" role="main">
<h1>Setting up VIVO to use OpenSocial Gadgets</h1>
<small>
Instructions for connecting VIVO and Open Research Networking Gadgets
</small>
<p>
This document contains instructions on how to configure your VIVO
installation to use OpenSocial gadgets.
</p>
<p>
VIVO uses an extension of the OpenSocial protocols called
Open Research Networking Gadgets, or ORNG.
ORNG is a project of the Clinical & Translational Science Institute at the
University of California, San Francisco.
You can find out more about the ORNG project at their web site,
<a href="http://www.opengadgets.org/index.html">http://www.opengadgets.org/index.html</a>
</p>
<p>
ORNG supports gadgets using a modified version of Apache Shindig.
These instructions tell you how to install the Shindig-ORNG web application,
and how to configure it to work with VIVO.
</p>
<hr/>
<h2 id="tableofcontents">Table of Contents</h2>
<toc>
<ol class="roman1">
<li> <a href="#installation">Installing and Configuring</a>
<ol class="roman2">
<li><a href="#database">Create database tables and procedures</a></li>
<li><a href="#config_files">Create configuration directory and key file</a></li>
<li><a href="#tomcat_settings">Modify Tomcat settings</a></li>
<li><a href="#vivo_settings">Configure VIVO</a></li>
<li><a href="#deploy">Run the deployment script</a></li>
<li><a href="#confirm">Does it work?</a></li>
</ol>
</li>
<li> <a href="#gadgets">Changing the gadget configurations</a>
<ol class="roman2">
<li><a href="#orng_apps">The <em>orng_apps</em> database table</a></li>
<li><a href="#orng_app_views">The <em>orng_app_views</em> database table</a></li>
</ol>
</li>
<li> <a href="#additional">Additional Considerations</a>
<ol class="roman2">
<li><a href="#redeploying">Re-running the deployment script</a></li>
<li><a href="#cache">Resetting the gadget cache</a></li>
<li><a href="#LOD_issues">Issues with Linked Open Data</a></li>
</ol>
</li>
</ol>
</toc>
<hr/>
<h2 id="installation">I. Installing and Configuring</h2>
<h3 id="database">I.i. Create database tables and procedures</h3>
<p>
Shindig-ORNG uses several database tables in MySQL to store its data:
which gadgets appear on which pages, how large are the gadgets,
what information applies to each individual, and more.
Shindig-ORNG also creates stored procedures in MySQL. These are small
pieces of code that simplify the use of the database tables.
</p>
<p>
In the VIVO distribution directory, a file called
<em>vitro-core/opensocial/shindig_orng_tables.sql</em>
contains SQL commands that create the tables and
stored procedures for Shindig-ORNG to use.
</p>
<p>
Tell MySQL to process this file with a command like this:
<pre>mysql -u <em>username</em> -p <em>database</em> &lt; <em>sql_file</em></pre>
So, if your current directory is the VIVO distibution directory, and your
VIVO database is <em>vivoDb</em> and your MySQL user account is <em>vivoUser</em>,
then you might use the command this way:
<pre>mysql -u vivoUser -p vivoDb &lt; vitro-core/opensocial/shindig_orng_tables.sql</pre>
MySQL will prompt you for the password for your MySQL user account, and then
process the file.
</p>
<p>
You may want to start your gadget collection with some example gadgets
that have been developed by the ORNG group. The file called
<em>vitro-core/opensocial/shindig_example_gadgets.sql</em>
contains SQL commands that will add these gadgets to your system's configuration.
</p>
<p>
If you want to load these example gadgets, you can use a command similar to the previous one:
<pre>mysql -u vivoUser -p vivoDb &lt; vitro-core/opensocial/shindig_example_gadgets.sql</pre>
As before, MySQL will prompt you for the password for your MySQL user account, and then
process the file.
</p>
<h3 id="config_files">I.ii. Create configuration directory and key file</h3>
<p>
In your VIVO home directory, create a directory called <em>shindig</em>.
Under that, create directories called <em>conf</em> and <em>openssl</em>.
Your VIVO home directory will look something like this:
<pre> [VIVO home directory]
|
|--shindig
| |
| |--conf
| |
| |--openssl
|
|--solr
|
|--uploads</pre>
</p>
<p>
Shindig-ORNG uses an encryption key to insure that the communication
between the gadget and the server is secure.
You should create a file that contains the encryption key,
and store that file in the <em>shindig/openssl</em> directory that you created.
</p>
<p>
On Unix-based systems (like Linux or Mac OS X), this command will create
an encryption key from a random seed:
<pre>dd if=/dev/random bs=32 count=1 | openssl base64 > <em>[key-file]</em></pre>
For example, if your VIVO home directory is <em>/usr/local/vivo/data</em>,
you might use the command this way:
<pre>dd if=/dev/random bs=32 count=1 | openssl base64 > /usr/local/vivo/data/shindig/openssl/securitytokenkey.txt</pre>
</p>
<p>
If your VIVO installation is installed on a machine that runs Microsoft Windows,
you will need to find another way to create an encryption key.
The easiest way might be to find a Unix-based machine,
issue the command above, and copy the resulting file to your Windows machine.
</p>
<h3 id="tomcat_settings">I.iii. Modify Tomcat settings</h3>
<p>
The Shindig-ORNG application must know where to find the configuration file that you created in
Step I.
It must also know its own URL, so that URL can be inserted into the gadgets.
</p>
<p>
This information is provided through startup parameters in Tomcat.
With most installations of Tomcat, the "setenv.sh" or
"setenv.bat" file in Tomcat's bin directory is a convenient place to
set these parameters.
<em>If this file does not exist in Tomcat's bin directory, you can create it.</em>
</p>
<p>
Here is an example of the setenv.sh file, showing only the Shindig-ORNG requirements:
<pre>export CLASSPATH=/usr/local/vivo/data/shindig/conf
export CATALINA_OPTS="-Dshindig.host=localhost -Dshindig.port=8080"</pre>
</p>
<p>
Here is the equivalent file for an installation in Windows.
<pre>set CLASSPATH=C:\vivo\data\shindig\conf
set CATALINA_OPTS=-Dshindig.host=localhost -Dshindig.port=8080</pre>
</p>
<p>
This assumes that your setenv file was empty before starting this process,
and that you used the default location for the Shindig-ORNG configuration file in Step I.
In fact, it's more common for the setenv file to contain other parameters besides
those used for Shindig-ORNG. In that case, it might look more like this:
<pre>export CLASSPATH=/usr/local/vivo/data/shindig/conf
export CATALINA_OPTS="-Dshindig.host=localhost -Dshindig.port=8080 -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:MaxPermSize=128m"</pre>
</p>
<p>
Or, for Windows:
<pre>set CLASSPATH=C:\vivo\data\shindig\conf
set CATALINA_OPTS=-Dshindig.host=localhost -Dshindig.port=8080 -Djava.awt.headless=true -Xms1024m -Xmx1024m -XX:MaxPermSize=128m</pre>
</p>
<h3 id="vivo_settings">I.iv Configure VIVO</h3>
<p>
In the VIVO distribution directory, the file called <em>deploy.properties</em>
contains configuration options for the VIVO application.
You must set some additional parameters so VIVO will be able to communicate with Shindig-ORNG.
</p>
<table border='1' bordercolor="#CCCCCC" cellspacing="5">
<tbody>
<tr>
<th>
Property Name
</th>
<th>
Example Value
</th>
</tr>
<tr>
<td colspan="2">
The base URL that VIVO will use when contacting the Shindig-ORNG application.
Usually, this is the same host and port number as VIVO itself,
with a context path of <em>shindigorng</em>
</td>
</tr>
<tr class="odd_row">
<td>OpenSocial.shindigURL</td>
<td>http://localhost:8080/shindigorng</td>
</tr>
<tr>
<td colspan="2">
The host name and port number of the Token Service that Shindig-ORNG creates.
Note that a value of <em>localhost</em> or <em>127.0.0.1</em> will not work.
You must provide the actual host name of your machine, followed by <em>:8777</em>
</td>
</tr>
<tr class="odd_row">
<td>OpenSocial.tokenService</td>
<td>myhost.mydomain.edu:8777</td>
</tr>
<tr>
<td colspan="2">
The path to a key file that will be used to generate security tokens. This is the
file that was created in Step I of this process.
</td>
</tr>
<tr class="odd_row">
<td>OpenSocial.tokenKeyFile</td>
<td>/usr/local/vivo/data/shindig/openssl/securitytokenkey.txt</td>
</tr>
</tbody>
</table>
<h3 id="deploy">I.v. Run the deployment script</h3>
<p>
At the command line, from the top level of the VIVO distribution
directory, type:
<pre> ant orng</pre>
to configure the Shindig-ORNG application and deploy it to Tomcat's webapps directory.
</p>
<p>
The main VIVO application must also be re-deployed in order to accept the new settings
in <em>deploy.properties</em>. At the command line, from the top level of the VIVO distribution
directory, type:
<pre> ant deploy</pre>
to re-deploy VIVO with the new settings.
</p>
<h3 id="confirm">I.vi Does it work?</h3>
<h4>Startup tests</h4>
<p>
Start VIVO, and verify that you can see VIVO's home page in a browser.
</p>
<p>
On startup, VIVO runs a series of self-diagnostics, or "smoke tests". If these tests find
any problems with the OpenSocial configuration, you will see a warning message instead of
the VIVO home page.
</p>
<p>
Some of VIVO's "smoke tests" are run after the startup is finished, and may take up to a minute
to complete. If one of these tests fails, you will see the warning message as you
navigate from one VIVO page to the next.
</p>
<p>
If one of the OpenSocial tests fails, you may continue to use VIVO, but it is
likely that no gadgets will be shown.
You can review the warning message by seleting the "Startup Status"
link from the "Site Admin" page.
</p>
<h4>Search page</h4>
<p>
If you loaded the example gadgets, you should be able to see the "Google Search" gadget on the
Search Results page in VIVO.
</p>
<p>
Every VIVO installation comes with a geographic data model, so type "Chile" in the search box,
and view the results. Near the bottom of the page, you should see the "OpenSocial" section heading,
and beneath it, a gadget offering "Full Text Search Results". This gadget does a google search
at UCSF, using the search term that you entered. Again, this gadget is just an example, to show
what is possible with OpenSocial gadgets and VIVO.
</p>
<p>
The first time you bring up the search page, it may take several seconds for the gadget to
appear. After the first time, the gadget response should be must faster.
</p>
<h4>Profile page</h4>
<p>
If your VIVO installation contains profiles of people, you can see several gadgets on their
profile pages. You must be logged in to VIVO, with authority to edit the profile you are
viewing.
</p>
<p>
Go to a personal profile page in VIVO. If you loaded the example gadgets, you will see
the "OpenSocial" section heading above the property lists, with an assortment of
example gadgets available for experimentation.
</p>
<p>
As with the search page, the first appearance of the gadgets may be slow.
</p>
<h4>Troubleshooting</h4>
<p>
If the gadgets do not appear as you expect, look for these symptoms,
and check for the corresponding possible causes.
</p>
<table>
<tr>
<th>Symptoms</th>
<th>Possible causes</th>
</tr>
<tr>
<td>
<ul>
<li>
The "OpenSocial" heading does not appear on Individual page or in search results.
</li>
<li>
Tomcat log files do not contain errors.
</li>
</ul>
</td>
<td>
<ul>
<li>
VIVO was not re-deployed with <tt>ant deploy</tt> after the OpenSocial
values were set in <em>deploy.properties</em>
</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
<tr>
<td>
<ul>
<li>
Gadgets do not appear on Individual page or in search results.
</li>
<li>
Tomcat "localhost" log file contains an error message:
<pre>Unable to load properties: shindigorng.properties</pre>
</li>
</ul>
</td>
<td>
<ul>
<li>Configuration file is not correctly named.</li>
<li>Tomcat's setenv file does not specify the correct CLASSPATH</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
<tr>
<td>
<ul>
<li>
Dialog box appears in the browser with the message:
"Error 500 reading application data: internalError"
</li>
<li>
Tomcat "catalina" log file contains an error message:
<pre>java.sql.SQLException: Access denied for user</pre>
</li>
</ul>
</td>
<td>
<ul>
<li>
Configuration file contains incorrect value for one or more of these:
<ul>
<li>orng.dbURL</li>
<li>orng.dbUser</li>
<li>orng.dbPassword</li>
</ul>
</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
<tr>
<td>
<ul>
<li>
"Smoke tests" fail at startup.
<pre>Token key file for Shindig does not exist</pre>
</li>
<li>
Pages that display gadgets "hang" in the browser.
</li>
<li>
Tomcat "localhost" log file contains error messages, including:
<pre>com.google.inject.CreationException: Guice creation errors</pre>
</li>
</ul>
</td>
<td>
<ul>
<li>
<em>OpenSocial.tokenKeyFile</em> is not set in <em>deploy.properties</em>,
or the file does not exist at the specified location.
</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
<tr>
<td>
<ul>
<li>
Gadgets do not appear on Individual page or in search results
</li>
<li>
vivo.all.log contains an error message:
<pre>MySQLSyntaxErrorException: Table 'vivo.orng_apps' doesn't exist</pre>
</li>
</ul>
</td>
<td>
<ul>
<li>
MySQL does not contain the shindig tables.
<pre>shindig_orng_tables.sql</pre> was not processed.
</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
<tr>
<td>
<ul>
<li>
Gadgets do not appear on Individual page or in search results
</li>
<li>
vivo.all.log contains an error message:
<pre>java.net.ConnectException: Connection refused</pre>
</li>
</ul>
</td>
<td>
<ul>
<li>
In <em>deploy.properties</em>, <em>OpenSocial.tokenService</em> is not set correctly.
</li>
</ul>
</td>
</tr>
<tr class="odd_row"><td colspan="2"></td></tr>
</table>
<h2 id="gadgets">II. Changing the gadget configurations</h2>
<p>
VIVO will look at tables in MySQL to determine what gadgets should be made available,
where they should appear, how big they will be, and much more.
At this time, VIVO doesn't provide a user interface to edit the contents of these tables.
Administrators will need to use a MySQL admin client, or SQL commands, to set these
parameters.
</p>
<p>
The tables are named <em>orng_apps</em> and <em>orng_app_views</em>,
and are described in the following sections.
</p>
<h3 id="orng_apps">II.i The <em>orng_apps</em> database table</h3>
<p>
This table acts as a dictionary of the available gadgets.
It includes the name and ID of the gadget and where the source code is stored on the web.
</p>
<table>
<tr>
<th>Field</th>
<th>Type</th>
<th>Usage</th>
</tr>
<tr>
<td>appid</td>
<td>int(11)</td>
<td>
Identifies the gadget.
In particular, this will be used to determine which rows in the
<em>orng_app_views</em> table should apply to this gadget.
</td>
</tr>
<tr>
<td>name</td>
<td>varchar(255)</td>
<td>
A user-friendly name for the gadget.
This will be displayed in the gadget's "Title Bar".
</td>
</tr>
<tr>
<td>url</td>
<td>varchar(255)</td>
<td>
The location where the gadget's contents and behavior are defined.
</td>
</tr>
<tr>
<td>PersonFilterID</td>
<td>int(11)</td>
<td>deprecated - usually set to <em>NULL</em></td>
</tr>
<tr>
<td>enabled</td>
<td>tinyint(1)</td>
<td>
If set to 0, this gadget will never be displayed.
If set to 1, it is displayed according to the rules in the <em>orng_app_views</em> table.
</td>
</tr>
<tr>
<td>channels</td>
<td>varchar(255)</td>
<td>Keywords that identify the communication channels between the gadget and VIVO.</td>
</tr>
</table>
<h3 id="orng_app_views">II.ii The <em>orng_app_views</em> database table</h3>
<p>
This table tells how, where, and when to display the gadgets that are described in <em>orng_apps</em>.
Each row in this table is a "view", describing a single gadget and the rules that determine whether
the gadget will be displayed on a particular page.
</p>
<p>
Note: If a gadget is described and enabled in the <em>orng_apps</em> table, but has no records in the
<em>orng_app_views</em> table, the gadget will be displayed without restriction on all ORNG-enabled
pages. This can be helpful when developing a new gadget. To avoid this, either
<ul>
<li>remove the gadget from <em>orng_apps</em>, or </li>
<li>set the <em>enabled</em> flag in <em>orng_apps</em> to <em>0</em>, or</li>
<li>create a rule for the gadget in <em>orng_app_views.</em></li>
</ul>
</p>
<table>
<tr>
<th>Field</th>
<th>Type</th>
<th>Usage</th>
</tr>
<tr>
<td>appid</td>
<td>int(11)</td>
<td>
Determines which gadget in <em>orng_apps</em> is affected by this rule.
</td>
</tr>
<tr>
<td>viewer_req</td>
<td>char(1)</td>
<td>
What requirements must the viewer satisfy in order to see this view?
<ul>
<li>
<em>NULL</em> -- There are no requirements on the viewer.
</li>
<li>
<em>'U'</em> -- The viewer must be logged in to VIVO.
</li>
<li>
<em>'R'</em> -- The viewer must be logged in, and must be registered as a user of this gadget.
</li>
</ul>
</td>
</tr>
<tr>
<td>owner_req</td>
<td>char(1)</td>
<td>
What requirements must the owner of this page satisfy in order to see this view?
<ul>
<li>
<em>NULL</em> -- There are no requirements on the owner of the page.
</li>
<li>
<em>'R'</em> -- The owner of the page must choose to display this gadget to the public.
</li>
<li>
<em>'S'</em> -- The viewer must be the owner of the page being viewed.
</li>
</ul>
</td>
</tr>
<tr>
<td>page</td>
<td>varchar(50)</td>
<td>
What page does this rule apply to?
A single gadget might have several views, but no more than one view per page.
Recognized values are
<ul>
<li>
<em>individual</em> -- The profile page of an individual, when it is not in "edit" mode.
This applies when the viewer is not logged in, or does not have the right to edit the profile page.
</li>
<li>
<em>individual-EDIT-MODE</em> -- The profile page of an individual, when it is in "edit" mode.
This applies when the viewer is logged in as an administrator or other privileged user, or
as the owner of the profile page.
</li>
<li>
<em>search</em> -- The search results page.
</li>
<li>
<em>gadgetDetails</em> -- A page that contains only the selected gadget. This usually occurs when
the user clicks on an icon or a link that expands the gadget to full-page mode.
</li>
</ul>
</td>
</tr>
<tr>
<td>view</td>
<td>varchar(50)</td>
<td>
What is the view-mode of the gadget? These are defined as part of the OpenSocial standards.
<ul>
<li>
<em>profile</em> -- The "standard" view, commonly used on the profile page of an individual
</li>
<li>
<em>small</em> -- The "condensed" view.
</li>
<li>
<em>home</em> -- The view which allows the user to change the gadget's settings.
</li>
<li>
<em>canvas</em> -- The "expanded", commonly used when the gadget is the only thing on a page.
</li>
</ul>
</td>
</tr>
<tr>
<td>closed_width</td>
<td>int(11)</td>
<td>
How wide is the gadget when it is closed? (in pixels)
</td>
</tr>
<tr>
<td>open_width</td>
<td>int(11)</td>
<td>
How wide is the gadget when it is open? (in pixels)
</td>
</tr>
<tr>
<td>start_closed</td>
<td>tinyint(1)</td>
<td>
When the page is first loaded, is the gadget open or closed (1 = closed, 0 = open)
</td>
</tr>
<tr>
<td>chromeId</td>
<td>varchar(50)</td>
<td>
The gadget will be displayed on the page inside a &lt;div&gt; with this id.
Note: the page must contain this &lt;div&gt; and its contents
will be replaced with this gadget (or gadgets).
</td>
</tr>
<tr>
<td>display_order</td>
<td>int(11)</td>
<td>
If more than one gadget has the same chromeId, they will be displayed in order by this field.
</td>
</tr>
</table>
<h2 id="additional">III. Additional Considerations</h2>
<p>
Some things to be aware of when working with OpenSocial gadgets.
</p>
<h3 id="redeploying">III.i. Re-running the deployment script</h2>
<p>
The OpenSocial framework relies on several of the settings in the <em>deploy.properties</em> file,
in addition to the ones that are explicitly linked to it.
</p>
<p>
Each time you change the settings in <em>deploy.properties</em>, you should re-deploy
the framework with
<pre> ant orng</pre>
</p>
<h3 id="cache">III.ii. Resetting the gadget cache</h2>
<p>
For efficiency, VIVO reads the gadget configuration only when it starts up. VIVO keeps
a copy of the database tables in memory, for efficiency.
</p>
<p>
This means that if you change the gadget configuration in the database tables, you must
either tell VIVO to read the tables again. Direct your browser to
the <tt>orng/clearcache</tt> page within VIVO. For example,
<pre> http://localhost:8080/vivo/orng/clearcache</pre>
VIVO will re-read the gadget configuration, and display the VIVO home page.
</p>
<p>
You can achieve the same effect by restarting VIVO.
</p>
<h3 id="LOD_issues">III.iii. Issues with Linked Open Data</h2>
<p>
<b>TBD</b>
</p>
</div>
</body>
</html>