New Blood

Introducing the latest member of our development team: Jason Cooper!

Jason  has been around for a while and is a survivor of our data design wars (it’s all just structural units! why do we need data type groups?). We’ve given him the task of developing a new wizzy interface which will communicate with Jon’s APIs.

Like Jon, Jason is a PhD which means I’m now in the middle of a doctor-doctor joke.

REST versus SOAP

We want LUMP to have a well separated client-server architecture, so the we can deploy several different types of front end and also so that third party developers can implement their own front (and back!) ends independently. We’ve pretty much decided on using XML to return the results (as most client programming environments have some sort of XML handling these days, and if the worst comes to the worst there are network XSLT transformation services that can turn the XML into renderable HTML). However we needed to decide how to send requests from the client to the server in the first place.

The initial plan was to have clients lovingly hand craft XML documents for the request and then send these as a single parameter to a CGI script. This XML document would contain all the authentication, version, metadata for the LUMP protocol, as well as the method being requested and any parameters required. It would work OK, but meant that the clients needed to generate an XML document, even for a relatively simple request.

Next we considered the Simple Object Access Protocol (SOAP). SOAP basically does the XML packaging of parameters and results in a standardised manner that is supposed to allow different programming languages on different platforms to remotely access objects and methods as though the were part of the local application. That’s the theory at least. SOAP works better when coupled with the Web Services Description Language (WSDL) but there’s also where things start to come unravelled.

Firstly WSDL appears to have real difficulties in handling dynamic data structures. Most of the examples of WSDL on the web pass a string or two into a routine and then get out a single string, floating point or integer. But we’d like to return far more complex data structures such as nested hash of hashes, arrays of hashes, etc, etc. We could describe those in terms of an XML DTD for our hand crafted responses but not easily in WSDL for use with SOAP. WSDL also imposes an extra transfer over head on clients and/or requires that the client cache the WSDL file (which makes developing a pain, where the WSDL would have to be in constant flux normally and thus uncachable).

There were also some practical problems with SOAP. The main development of the LUMP server is likely to be in Perl and, whilst there is a SOAP Perl module available, its nowhere near as well developed as many of the other Perl modules available. Secondly we found that sometimes we could get SOAP to work with, say, Perl, but then not work with PHP (PHP being the other major target language, this time for the Moodle client block). Fixing access for the PHP client could then cause problems for the Perl client. Why things some times worked and sometimes didn’t wasn’t particularly clear and therefore this didn’t show SOAP to be particular platform independent. And debugging the SOAP transactions was also very hard – even with debugging turned on in the SOAP libraries the interactions can be very complicated and you end up having to sit with the SOAP specification trying to work out which bit of the libraries that were supposed to make life easy for you were actually making it much harder!

So we opted for a third choice, and one we were already quite familiar with: REpresentational State Transfer (REST). APIs that use REST (so called “RESTful” APIs) make use of the existing web infrastructure such as HTTP, SSL, web server authentication techologies and CGI scripts. A RESTful API uses a base URI pointing at some sort of program (such as a CGI script or mod_perl instance) combined with URI query parameters to specify the operation required, user authentication information, request details, etc. Many programming environments have built in support for accessing URIs and so these RESTful APIs can reuse existing technologies without needing new, complex and potentially buggy libraries. Generating the URIs is relatively simple and straight forward in most languages.

The results of a REST transaction can be anything you like, so there was not reason why it couldn’t be the sort of XML result documents that we looked at originally. This gave the result some platform neutrality, whilst still allowing us to return what were effectively dynamic data structures. It also means that you can easily do funky things with XSLT still if you want to. The clients can process XML returned fairly easily these days (as evidenced by the AJAX mash ups out there) but they wouldn’t need to go through the overhead of generating a new XML document for the outgoing request itself (unless it was required for a complex parameter perhaps – that’s flexibility for you!).

RESTful APIs also have a big conceptual win over a SOAP based API: the interface gets real URLs for each request. This means that not only get you retrieve object details using a suitably crafted URI, but also create, update and delete them (assuming you have rights to obviously). Having such URIs available means that the other parts of the W3C’s web standards development dovetail in nicely with RESTful APIs: things like RDF and XPointer only really become useful if they can reference resources using URIs.

Having chosen (for the moment!) REST as API mechanism there appeared to be one decision still outstanding. That is where to draw the line between the “base” URI and the parameters. One option is to have a single base URI for all operations and then a parameter (amongst others) that describes the operation we required. For example a FindSuid call might look something like:

http://example.com/cgi-bin/LUMP?operation=findsuid&what=Module&aspect=Module%20Code&value=08LBA100

The other option is to have different base URIs for each of the “methods” that the API has. For example the base URI for the above operation might be:

http://example.com/cgi-bin/LUMP/FindSuid

and then we’d add parameters to the end of that, giving a URI of:

http://example.com/cgi-bin/LUMP/FindSuid?what=Module&aspect=Module%20Code&value=08LBA100

There’s not really much in it as far as we can see at the moment. On the one hand having a single base URI might mean that the client’s configuration is very, very slightly simpler. On the flip side having separate URIs might translate to having lots of small, simple CGI scripts, as opposed to a single monolithic script. The small scripts might or might not be easier to maintain, depending on how much code reuse and modularisation we can come up with. Also if we use something like mod_perl with the scripts to speed things up, the smaller units will hog less memory in the web server, take less to get running and can be updated with less impact on a running service.

Either of these would appear to be RESTful as they both result in workable URIs. Luckily we can have our cake and eat it in this case. If we opt for individual URIs for each method then we can take advantage of the back end benefits, but also then use existing web technologies to make them appear as a single monolithic interface with a single base URI and an “operation” parameter if we wish to. This could either be through a wrapper CGI script or one of the web server URL rewriting technologies (though Apache may have issues with rewriting parameters).

Data Structure Design

With LUMP what we’d like to achieve is a far more flexible database design than the previous versions of the LORLS reading list system. Traditionally we’ve modeled the database structure and the resulting relations on a fairly restricted model of book like objects and also had to work round limitations in the way reading lists were used. For example at Loughborough we were initially told that a module would have a single reading list. This proved to not always be true – sometimes a module would be taught by more than one lecturer and so we had to introduce the “bodge” of sub-lists linked to the main one. As other institutions used LORLS we also found that our way of linking reading lists to modules to courses to departments did not always match up with other organisations’ structures.

So we thought it was time for a rethink. We wondered if it was possible to come up with a generic data container that could be a reading list item, a reading list itself, a module, a course, a department, a faculty or indeed anything you like. We called these containers “structural units” and decided that they could contain metadata and/or other structural units. The more we thought about structural units, the more we realised that a generic concept such as this could allow great flexibility in a reading list system, and possibly also form the basis for other systems.

However it was also clear that we needed more than just the structural units themselves. For one thing it was felt to be advantageous to all structural units to be grouped by type, such as “reading list”, “module”, “department”, “book”, “video”, “3d holographic projection”, etc. The typing system would allow a set of custom metadata elements to be defined that would be available to all structural units of the given type. For example a “department” structural unit might have metadata of a department name, a URL pointing to a departmental website and another URL pointing to a departmental logo. A “book” on the other hand would have the normal bibliographic and holding information metadata that we have used in LORLS for some time.

Each piece of metadata itself has a type, and a value. The value is the actual piece of metadata (“Andrew S. Tanenbaum”, or “Computer Networking”, or “Prentice-Hall”, etc for a book for example). The data type on the other hand tells us information about whether this piece of metadata is repeatable or not (you might only allow one record of holding information but allow any number of authors for example), where it is ranked in the output, and how it is to be represented for editing (string, integer, date, etc). The data type can also be linked to a controlled vocabulary if required to limit the choices available for associated data values.

Structural unit types could also be linked to one another as parents and children, so that we could enforce certain heirarchical or mesh layouts on structural units of given types. For instance a structural unit type of “department” is a child of a type called “faculty”, so only structural units of type “faculty” can be a parent of a “department” typed structural unit.

The data structure also need to encompass information about the ownership of structural units, and the permissions users had to access and/or alter them. Users could be part of one or more usergroups, and the groups have access controls applied to them for access both to structural units themselves and also editing sections (the name of which was hotly debated for several weeks but which is currently “Data Type Groups”!). The editing sections allow us to group data types that are “similar” together, thereby allowing such things as tabbed editing for a single structural unit, with each tab holding a different sort of metadata (holdings, bibliographic, etc).

We wanted to allow structural units to be rendered in a variety of forms (HTML, BibTeX, RefWorks, etc) and had to decide whether this was a client or server side task. We decided on doing it on the server side as it meant that a single set of code at the server could then produce output for a larger number of simpler clients. It also meant that new or changed output formats only required changes to be made once at the server end, rather than in all the clients. For flexibility we could still return structural unit information to clients in “raw” XML so that they could process it themselves, or to allow them to provide editing features.

The current database ER diagram is :

Going nowhere fast

We’ve been working on designing a new and improved database structure  for LORLS which allows for greater flexibility. Unfortunately work on this hasn’t really progressed due to the implementation of RFID-based self-service here which is occupying all our time at the moment.

But on the plus side we have come up with a name for the backend (DB+APIs):

<Drum roll>

LUMP

What! (we hear you shout)

Yes LUMP it stands for Loughborough Universal Metadata Platform which we realise may sound a little pretentious but how can you not like an acronym like LUMP!

Version 6: A new LORLS

Jon and I have begun to think about the future of LORLS. At the moment we seem to keep coming up against issues with the data design whenever we try to implement a new feature. So we’re thinking it might be time to (warning scary thought coming) throw anyway what we’ve got and start again from stratch.

Having spent a couple of late Monday evenings discussing this we’ve come up with a new data model. This is still very much at the play stage – so things are likely to change.

One thing we’d be keen to do this time round is to seperate the backend that provides access to the databse from the frontend, or rather frontends –  assuming that with a XML+HTTP based API at the backend there could be multiple frontends for different tasks, institutions, mash ups, etc.

Of course a well defined XML+HTTP API could even mean that there could be multiple backends.  For example traditional Perl based CGI scripts for use with Apache for those of us with a modicum of common sense, or Java+Tomcat for people who like smacking their foreheads against walls (you can tell we might have a small bias, can’t you? 🙂 ).

Interestingly we’ve just had an email from one of the other LORLS sites asked about forking the existing code. So maybe this is an opporuntity for some cross institutional development of LORLS.

Go to Top