Monday, February 17, 2020

Rewrite URL with CloudFlare for Domino

Years ago I created few solutions for Domino using DSAPI:
  1. remove last slash in URL served by Domino.
  2. rewrite URL.
  3. better control over 404/500 error pages.

It was quite complicated solution (DSAPI is not easy topic).
Today another client asked similar features (remove last slash and rewrite url).
I started to recall how DSAPI works but then I reminded myself that the client stick with CloudFlare in front of their Domino servers.

Cloudflare has 'page rules' which allow to solve issue with last trailing slash. Just matter of configuration.

And about rewriting URL it's actually possible to achieve with workers! You can see below how to rewrite URL.
In example below I changed url like

addEventListener('fetch', event => {
  const url = new URL(event.request.url);
  const pathname = url.pathname.substr(1);
  if (pathname.startsWith("design") || pathname.startsWith("files") || pathname.startsWith("api")) {

 * Rewrite URL and makes query param available
 * @param {Request} request
async function handleRequest(request) {
  let url = new URL(request.url);
  let pathname = url.pathname.substr(1);
  url.pathname = "?openagent&req="+pathname;
  var query =;
  if (query!="") {
    url.pathname += "&" + query.substr(1);

  const newRequest = new Request(url, new Request(request));
  return await fetch(newRequest)

Wednesday, September 25, 2019

JSON Reader in LotusScript

For those who are still running Domino v9 (or below) here is a LotusScript library that can parse JSON into something useful. I implemented it some time ago and since that time almost had no issues with it. Since many customers that did not migrate to v10 (and probably won't do that in near future) it could be very useful to them.

You can download my realization on github: jsonparser-ls

See example below how it works

Dim parser As JSONParser
Dim jsonObj As JSONObject
Dim jsonArr As JSONArray
Dim jsonString As String

Set parser = New JSONParser

jsonString = |{"array":[1,  2  ,   300.56  ]  ,  "boolean":true,"null":null,"number":123,"object":{"a":"b","c":"d","arr":["12","23",34.56],"e":"f","ho":true},"string":"Hello World"}|
Set jsonObj = parser.parse(jsonString)
Print jsonObj.HasItem("array") 'true
Print jsonObj.HasItem("array1") 'false
print jsonObj.GetItem("array").Items(2) '300.56
print IsNull(jsonObj.GetItem("null")) 'true
print jsonObj.GetItem("number") '123
print jsonObj.GetItem("object").getItem("c") 'd
print jsonObj.GetItem("object").getItem("ho") 'true
print jsonObj.GetItem("object").getItem("arr").Items(2) '34.56

jsonString = |[{a:1,b:true,_dd:null},12,"13",true,{}]|
Set jsonArr = parser.parse(jsonString)
print jsonArr.Items(0).getItem("b") 'true
print jsonArr.Items(1) '12
print jsonArr.Items(2) '13
print jsonArr.Items(3) 'true
print TypeName(jsonArr.Items(4)) '"JSONOBJECT"

Tuesday, September 24, 2019

Create Excel files with LotusScript without Excel installed

One of my customer asked me to find a solution to create Excel files using LotusScript on server without Excel on it (well who wants to do install Excel and other tools on Server). Took some time but I have made a proof of concept using Apache POI and it worked very very nice. I have also made a LS2J cover so it's more easily for people who are not familiar with Java to create Excel files.

I put demo on my github account with some explanation so feel free to have a look on it: excel-apache-ls but if you wonder how it works, see snippet below:

Option Public
Option Declare

UseLSX "*javacon"
Use "Apache.Excel"

Sub Initialize
 Dim jSession As JavaSession
 Dim jClass As Javaclass
 Dim jObject As JavaObject
 Dim filepath As String
 Dim row As Integer

 Set jSession = New Javasession
 Set jClass = jSession.GetClass("")
 Set jObject = jClass.Createobject()
 Call jObject.createSheet("sheet A-100")
 Call jObject.createSheet("sheet B-100")
 Call jObject.createSheet("sheet C-100")
 Call jObject.getSheet("sheet A-100")

 row = row + 1
 Call jObject.setCellValueString("lorem", row, 0)
 Call jObject.setCellValueString("ipsum", row, 1)
 Call jObject.setCellValueDouble(55, row, 2)
 row = row + 1
 Call jObject.setCellValueString("hello", row, 0)
 Call jObject.setCellValueString("world", row, 1)
 Call jObject.setCellValueDouble(200.50, row, 2)
 row = row + 1
 Call jObject.setCellValueString("gurli gris", row, 0)
 Call jObject.setCellValueString("george", row, 1)
 Call jObject.setCellValueDouble(0.505, row, 2)
 filepath = Environ("Temp") & Join(Evaluate({@Unique})) & ".xls"
 Call jObject.saveAsFile(filepath)
 MsgBox filepath
End Sub

Tuesday, September 03, 2019

Formatting NotesDatetime as Java SimpleDateFormat

Recently I had to made proper formatting of NotesDateTime object (using LotusScript) with respect to different locale. I had written a cover in LS2J for Java SimpleDateFormat class that works independently (without Java library), so copy/paste and go on.

Here is an example how it works
Dim jdtr As New jDateTimeRich
Dim dt As New NotesDateTime("15-10-2017 10:20:30")

MsgBox jdtr.SimpleDateFormat(dt, "dd-MM-yyyy", "", "") ' "15-10-2017"
MsgBox jdtr.SimpleDateFormat(dt, "d-MMM-yy", "ru", "RU") ' "15-окт-17"
MsgBox jdtr.SimpleDateFormat(dt, "EEEEE MMMMM yyyy HH:mm:ss.SSSZ", "da", "DK") ' "søndag oktober 2017 11:20:30.000+0200")

The beautiful part of it - is translation of months and days according to Locale.
I have uploaded source/class on github. Feel free to re-use it: jDatetimeRich-LS and report issues of course.

Tuesday, July 17, 2018

Domino with Java 6 and TSL 1.2

Recently I have faced an issue where one of our provider changed SSL and they disabled supporting of TLS 1.0 (as far as I understand it's non secure ourdays) and TLS 1.2 should be used instead. As a result our java agents (which used HttpsURLConnection) could not connect anymore to provider.

Error message looked like this:
Caused by: Access denied ( setHostnameVerifier)
I have found 2 possible solutions:

Enable TLS 1.2 on Domino (applicable only for 9.0.1 FP3 IF2 and higher)

The Domino JVM is based on Java 1.6 and default settings configured in a way to use TLS 1.0. Luckily our Domino servers had version 9.0.1 FP4 (and TSL 1.2 support has been added since FP3 IF2). So our version was capable to work with 1.2 (in theory) but it took some time to make it work.

In order to configure Domino JVM to use TLS 1.2 you need to:
  1. Create JVM settings file, f.x. C:\Domino\jvmOptions.ini
  2. Add parameter in jvmOptions.ini
  3. Add path to jvmOptions.ini file in notes.ini
After you added settings don't forget to restart Domino server. Keep in mind that setting is global meaning all agents that will start to use TLS1.2 therefore it is definitely worth to verify everything before and after this fix.

Java library solution

If that is not a way you can go with (f.x. Domino has lower version or something won'f work if you switch to TLS 1.2) then it's still possible to make custom Java Library that will make it possible, see link: How to use TLS 1.2 in Java 6.

It worked for me as well, but it requires to give permission in java policy on Domino server.