REST in Domino with Lotusscript and Agents: a little enhacement

There are a lot of possibilites at the time of building a REST service inside Domino.

With the arrival of Domino REST API (AKA Domino Keep), it feels like HCL wants to unify and centralice the definition of REST API in Domino with a really great tool, focused on definition instead on the implementation.

But, what if we don’t have access to that tool in our environment… or maybe we are not confortable coding in Java but we have background as Lotusscript developers… In that case, we can build a perfectly functional REST API using the traditional Domino agents and the lotusscript languaje.

HCL Ambassador Tom Van Aken wrote a blog series where he explains the configuration on the server and also offers some guides of implementation. All this work had been put into OpenNTF and is public available.

From that great example, I thought it was appropriate to add a slightly different little approach in the Tom’s implementation part.

“Bike” Model

In order to remain untouched Tom’s great job and easily see the differences, i have added the “Bike” entity to the application model.

Bike Entity

Agent Responsability and Entity Responsability

One of the SOLID principles of object-oriented programming is the so-called “Single Responsibility Principle “. In the example we are describing, it is the entity “Bike “ that is in charge of generating the JSON (both of each individual entity and of an array),leaving the agent with the only responsibility of acting as a “router” from the obtained REST method firstly, and secondly, processing and injecting the headers in the response http request.

Bike controller agent

JSON stored on the Notes Document

To speed up the response in GET methods, one enhancement option is to save the generated JSON in the NotesDocument itself. This speeds up the response time since you do not have to construct this JSON based on the entity values.
This is done using the “ORM” design pattern using a class that “translates” from View or Document NOtes values to Json and vice versa.

Bike ORM Class

The example can be downloaded as a template from the OpenNTF site.

Of course, we encourage you to send us possible improvements and design alternatives to enrich or give ideas to other users.

HCL Domino LEAP is not HCL Domino Volt anymore and it is even better Obtain JSON Data from Domino 12 with DQL (an easy way)


Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now