Skip to content
Richard Stanley edited this page Aug 14, 2017 · 1 revision

"Hello, world" for OpenInfoMan

OpenInfoMan is built on BaseX. BaseX is Java-based XML database, XQuery engine, and RestXQ web application framework. Installing OpenInfoMan also installs BaseX.

Using a fresh Ubuntu 14.x install the OpenHIE repository and then OpenInfoMan. Accept the default options for OpenInfoMan (heap size: default, url: leave blank, database: provider_directory).

sudo add-apt-repository ppa:openhie/release
sudo apt-get update
sudo apt-get install openinfoman

After installation, OpenInfoMan will be running. The OpenInfoMan web application admin interface is at http://localhost:8984/CSD

Three different processes are running: The BaseX database server on port 1984, which services calls to the XML database and XQueries; the BaseX web application using Jetty on port 8984; and port 8985 for graceful web server shutdowns.

Stopping and starting OpenInfoMan

When OpenInfoMan is installed it puts both the BaseX and OpenInfoMan repository under /var/lib/openinfoman. In bin/ the basex script launches the command line REPL, also referred to as 'BaseX standalone'. basexhttp launches all components needed for OpenInfoMan (web server, database, web server shutdown). All of these are shell scripts that define the Java classpath and fires up Java.

Note: /var/lib/openinfoman/bin is not added to $PATH. If you directly invoke one of the shell scripts used to start the REPL (BaseX) or the web application (basexhttp) it will error out with The program 'basex' is currently not installed. You can install it by typing: sudo apt-get install basex Ignore the error and call the executable with the correct path.

To shutdown and launch OpenInfoMan, use the upstart service (/etc/init/openinfoman.conf) which uses a simple wrapper script. Starting the service increases the heap size then calls the BaseX web application (basexhttp). Stopping the OpenInfoMan service sends a call for the graceful shutdown of the web server then stops the other processes.

Root user privileges are needed to stop/start OpenInfoMan.

sudo service openinfoman stop
sudo service openinfoman start

Permissions and folder contents

The oi user and group owns OpenInfoMan but it disabled. We need to be the oi user to create and load functions in BaseX standalone. Either assign a password with sudo passwd oi to enable it then switch user with su - oi, or switch to the oi user with sudo -u oi -i.

Have a look at the folder and all of the modules installed by OpenInfoMan.

cd /var/lib/openinfoman/
ls -a
.  ..  .basex  .basexhome  BaseX.jar  bin  data  etc  lib  LICENSE  README.md  repo  repo-src  resources  webapp
$ ./bin/basex
BaseX 8.5.3 [Standalone]
Try 'help' to get more information.
> repo list
> exit
cd /var/lib/openinfoman/repo/com/github/openhie/openinfoman
ls
...
  • bin: Basex executables. The OpenInfoMan upstart script (/etc/init/openinfoman.conf) is a wrapper around these.
  • data: Database and the logs (data/.logs/)
  • etc: Example files from the BaseX source repository
  • lib: JAR files. these are declared in the Java classpath repo: The modules that are loaded and imported. This is where all modules are copied into and rewritten per their URI
  • repo-src: XQuery functions source code for OpenInfoMan GitHub repo.
  • resources: Source of OpenInfoMan GitHub repo.
  • webapp: RestXQ modules answering requests, making responses.

Note: From the BaseX docs, 'If an XQuery file is specified as input for the install command, it will be parsed as XQuery library module. If parsing was successful, the module URI will be rewritten to a file path and attached with the .xqm file suffix, and the original file will be renamed and copied to that path into the repository.' What this means for 'hello, world' is that the file we create will be parsed by the BaseX standalone command and will write a series of folders and copy the file into that folder path. /var/lib/openinfoman/repo/com/github/openhie/openinfoman is an example of this, where the original xqm files were placed into the path created.

Hello, world!

As the oi user, create a directory for our 'hello, world' module, e.g. tests, in /var/lib/openinfoman and create a file for the 'Hello, world' XQuery module.

A 'hello, world' example is included in the GitHub BaseX repo. We will put restxq.xqm into the webapp folder.

cd /var/lib/openinfoman/webapp
wget https://raw.github.com/BaseXdb/basex/master/basex-api/src/main/webapp/restxq.xqm

Basex is monitoring that folder, it will be active once it's copied into webapp.

Visit http://localhost:8984 or http://localhost:8984/hello/world

Clone this wiki locally