DNUG Workshop LotusScript

Am Donnerstag, 21. November 2019 lädt Dich die Fachgruppe Development ab 9 Uhr zu einem besonderen Workshop ein.

Hier erfährst Du alles Wissenswerte zum Einstieg in die Notes-Programmierung.

In den acht Stunden ist zwar keine vollständige Ausbildung möglich, aber eine solide Einführung als Grundlage für eigene Weiterbildung.

Weitere Informationen und Anmeldung unter: https://dnug.de/event/grundausbildung-fuer-neue-notes-entwickler-fuer-azubis-und-quereinsteiger/


Nominations for HCL Masters 2020 are now open

The HCL Masters program is a recognition program that showcases the best of our community. HCL Masters go ‘above and beyond’ their normal job roles to help others, share information and organise events for the whole community to benefit.

Nominations will be judged by a panel of HCL employees on their individual merit against the other nominations we receive this year.

Please submit your nomination for you or someone else to be considered as a HCL Master.

For self nomination you will need:

  • A brief description of why you should be considered a HCL Master
  • A minimum of 3 detailed examples of how you go above and beyond (up to 6 examples)

To nominate someone else, you will need:

  • Consent from the person you are nominating to submit their details
    • Name, Email address and Company name
  • A detailed description & examples of why you consider that person to be a HCL Master

The nomination window is open from October 1st to 31st.

https://www.cwpcollaboration.com/hcl-master-nomination.html


NotesUser Activity Class

The NotesUserActivity Class is a customizable LotusScript library that returns database user activity summary information. The usage statistics for the prior day, week, and month since user activity recording began is provided. The number of documents a user or server has read, added, updated or deleted during each session, with the most recent activity first, is returned.

The class returns information that is available from the Notes user interface via the File/Database/Properties menu item, Information tab, Activity section, User Detail button selection. User activity for the specified database must be enabled for this function to work .

The class was created by Alex Elliott of AGECOM (http://www.agecom.com.au). Unfortunately it was only availabe for Windows.

I tried to write a Linux port, but I only had a partial success. The code runs without any issues on Windows.

It also runs fine on a Domino V11 Beta1 server on Linux ( CentOS). But it constantly crashes on Domino 10.0.1 ( with or without FP ) on RHEL.

The crash occurs, when the code tries to get the UserName from the ActivityEntry.

pActivityEntry = puActivity + lEntry * 28
		
CopyMemory dt.Innards(0), pActivityEntry , LEN_DWORD
CopyMemory dt.Innards(1), pActivityEntry + 4 , LEN_DWORD
CopyMemory reads, pActivityEntry + 8 , LEN_WORD
CopyMemory adds, pActivityEntry + 10 , LEN_WORD
CopyMemory updates, pActivityEntry + 12 , LEN_WORD
CopyMemory deletes, pActivityEntry + 14 , LEN_WORD
CopyMemory nonDataReads, pActivityEntry + 16 , LEN_WORD
CopyMemory nonDataAdds, pActivityEntry + 18 , LEN_WORD
CopyMemory nonDataUpdates, pActivityEntry + 20 , LEN_WORD
CopyMemory nonDataDeletes, pActivityEntry + 22 , LEN_WORD
CopyMemory nameOffset, pActivityEntry + 24 , LEN_DWORD		

Dim spUsername As String * MAXUSERNAME
spUsername = Space(MAXUSERNAME)

CopyMemoryString spUsername, puActivity + nameOffset, MAXUSERNAME - 2

Dim sUserName As String
sUserName = Trim(spUsername)

CopyMemory and CopyMemoryString are declared as

Declare Sub TUX_CopyMemory Lib "libc.so.6" Alias "memcpy" _
(hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)

Declare Sub TUX_CopyMemoryString Lib "libc.so.6" Alias "memcpy" _
(ByVal hpvDest As LMBCS String, ByVal hpvSource As Long, ByVal cbCopy As Long)

I tried using undocumented method “Cmovmem” from libnotes.so but it also crashes on V10 AND V11. I must admit that I do not really know, how to use Cmovmem. I declared it this way:

Declare Sub CopyMemoryString Lib LIB_TUX Alias "Cmovmem"  _
(Byval lpSrc As Long, Byval lpDest As String, Byval lSize As Long)

You can find the code here.

Any help to get it working on V10 for Linux is appreciated.


Be careful when using DAOS and compact -c -ZU

There has been a change in Domino 10.0.1 FP2 how the -ZU switch in the compact task behaves.

SPR# GRHEB8YG4K – Fixed a problem where compact -c -ZU and -ZD failed when attempting to recompress DAOS objects.

-ZU lets you enable LZ1 compression on a database. Prior to the change, you could do a compact -c -ods -upgrade -* -n -v -ZU on all databases and templates on the server.

The -ZU switch did not work on DAOS enabled applications, but those applications were upgraded to the latest ODS using the above command.

As of Domino 10.0.1 FP2, -ZU will pull all attachments of a DAOS enabled application back into the application!

via atnotes.de


LotusScript – Error: Type Mismatch

I ran into an issue with a Variant variable passed from one LotusScript class to another. (error: Type mismatch)

The code reads the first ( and only ) document in a database and gets the values from a multi value item.
The value of this item is stored in a Variant; a getter lets you access the values.


Class ConfigProvider

Public Class ConfigProvider
	
	Private m_settings As Variant
	
	Public Sub New
		Dim session As New NotesSession

		m_settings = _
		FullTrim(session._
		currentDatabase._
		Alldocuments._
		Getfirstdocument()._
		Getitemvalue("settings"))
		
	End Sub

	Public Property Get Settings As Variant
		Settings = m_settings
	End Property
End Class

I access the ConfigProvider from within another class in a different LotusScript library. The code is invoked by an agent


Agent

Option Public
Option Declare
Use "de.eknori.config.provider"
Use "de.eknori.config.consumer"

Sub Initialize
	Dim cc1 As New ConfigConsumer(1)
	Dim cc2 As New ConfigConsumer(2)
	Dim cc3 As New ConfigConsumer(3)
End Sub


Class ConfigConsumer

Public Class ConfigConsumer
	
	Private m_settings As Variant
	
	Public Sub New(flag As integer)
		
		Dim cp As New ConfigProvider
		m_settings = cp.Settings
		
		MsgBox ""
		MsgBox " -------- sample: " + CStr(flag) 
		
		Select Case flag
			Case 1       :  'works
				ForAll t In m_settings
					MsgBox CStr(t)
				End ForAll

			Case 2       : 'works
				Dim i As Integer
				For i = 0 To UBound(cp.Settings)
					MsgBox CStr(cp.Settings(i))
				Next

			Case 3       : 'does not work
				ForAll s In cp.Settings
					MsgBox CStr(s)
				End ForAll
				
			Case Else    : 
				msgbox "Else"
		End Select

	End Sub

End Class

The expected behaviour is that in all cases, the code would print the values from the config document to the console, but …

te amgr run "variant.nsf" 'test'
09/03/2019 07:38:25 AM  AMgr: Start executing agent 'test' in 'variant.nsf'
09/03/2019 07:38:25 AM  Agent Manager: Agent message: 
09/03/2019 07:38:25 AM  Agent Manager: Agent message:  -------- sample: 1
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item1
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item2
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item3
09/03/2019 07:38:25 AM  Agent Manager: Agent message: 
09/03/2019 07:38:25 AM  Agent Manager: Agent message:  -------- sample: 2
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item1
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item2
09/03/2019 07:38:25 AM  Agent Manager: Agent message: item3
09/03/2019 07:38:25 AM  Agent Manager: Agent message: 
09/03/2019 07:38:25 AM  Agent Manager: Agent message:  -------- sample: 3
09/03/2019 07:38:25 AM  Agent Manager: Agent 'test' error: Type mismatch
09/03/2019 07:38:25 AM  AMgr: Agent 'test' in 'variant.nsf' completed execution

This is reproducible on Domino V9.x, V10.x and V11 Beta1

I have attached a small sample database, so you can test in your own environment


ESXI 6.7 update: No space left on device

I have tried to update my VMware ESXi 6.7 host to ESXi-6.7.0-20190802001-standard (Build 14320388) today. On the host’s SSH console, the command to use is:

esxcli software profile update -p ESXi-6.7.0-20190802001-standard -d  https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml 

Unfortunately, this gave me this error:

[InstallationError]
  [Errno 28] No space left on device
        vibs = VMware_locker_tools-light_10.3.10.12406962-14141615 
  Please refer to the log file for more details.

/var/log/esxcli.log only gives that exact message! Still, it should be fairly obvious a problem, there is no disk space left.
Just, there is. The commonly accepted fix for this problem is to enable using your datastore as swap space:

  • Logon to web ui
  • Go to Host, Manage, System
  • Select the Swap entry and change it to be enabled
  • Pick a datastore of your choice, and enable Host cache and Local swap

I wrote about this here https://www.eknori.de/2018-03-18/vmware-esxi-errno-28-no-space-left-on-device-ibmchampion/

Unfortunately, in this situation, host swap already was enabled.

There is though, a workaround. You can use an image that doesn’t have the tools vib included with this command:

esxcli software profile update -p ESXi-6.7.0-20190802001-no-tools -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot
 -index.xml

You can then manually install the troublesome vib (if you have a need for tools) with this command:

esxcli software vib install -v https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/esx/vmw/vib20/tools-light/VMware_locker_tools-light_10.3.10.12406962-14141615.vib

Access NotesDatabase Options (extended)

GetOption was introduced to the NotesDatabase class in V6. It allows to determine, if specific options are set or not.

By design, it only accesses $dboptions1 from the database. Other options are stored in $dboptions2 – 4.
Those option bits are not accessible using NotesDatabase.getOption(optionName%).

Here is code to access them.

Public Type DBOPTIONS
options (3) As Long
End Type

Public Const W32_LIB = {nnotes.dll}
Public Const TUX_LIB = {libnotes.so}

Declare Function W32_NSFDbGetOptionsExt Lib W32_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer

Declare Function TUX_NSFDbGetOptionsExt Lib TUX_LIB Alias {NSFDbGetOptionsExt}_
(ByVal hdb As Long, retDbOptions As DBOPTIONS) As Integer
Declare Function TUX_NSFDbOpen Lib TUX_LIB Alias {NSFDbOpen}_
(ByVal dbName As String, hDb As Long) As Integer
Declare Function TUX_NSFDbClose Lib TUX_LIB Alias {NSFDbClose}_
(ByVal hDb As Long) As Integer


Public Function NSFDbGetOptionsExt (hDb As Long, retDbOptions As DBOPTIONS)
	If isDefined("WINDOWS") Then
		NSFDbGetOptionsExt = W32_NSFDbGetOptionsExt(hDb, retDbOptions)
	Else
		NSFDbGetOptionsExt = TUX_NSFDbGetOptionsExt(hDb, retDbOptions)
	End If
End Function

Function NSFDbOpen( db As string, hDB As Long) As Integer
	If isDefined("WINDOWS") Then
		NSFDbOpen = W32_NSFDbOpen(db,hDb)
	Else
		NSFDbOpen = TUX_NSFDbOpen(db,hDb)
	End If
End Function

Function NSFDBClose (hDb As Long)
	If isDefined("WINDOWS") Then
		NSFDbClose = W32_NSFDbClose(hDb)
	Else
		NSFDbClose = TUX_NSFDbClose(hDb)
	End If
End Function

Sample:

Const  DBOPT_IS_IMAP = &h01000000

Sub Initialize
	Dim hDb As Long
	Dim rc As Integer
	Dim sDb As String
	
	Dim retDbOptions As DBOPTIONS
	
	sDb = "serv01/singultus!!mail/buser.nsf"
	
	rc = NSFDbOpen(sDb, hDb)
	
	If rc = 0 Then
		rc =  NSFDbGetOptionsExt (hDb, retDbOptions)
		If retDbOptions.options(1) And DBOPT_IS_IMAP Then
			MsgBox "IMAP enabled"
		Else 
			MsgBox "IMAP not enabled"
		End If
		rc = NSFDbClose(hDb)
	End If
End Sub

I have created an enhancement request for an optional method parameter to access the different optionsStores.
If you think, that this might give you some benefit, pls upvote my idea https://domino.ideas.aha.io/ideas/DDXP-I-508


Get sorted results from DQL queries

NotesDominoQuery by now does not support sorting of the results that come out of a query. John Curtis demoed at DNUG46 in Essen how you can get your results sorted. He showed the code only for a second, so I needed to rewrite it from scratch.

The method that he showed leverages from the new ‘maintainOrder’ property that has been added in V10 to the NotesViewEntryCollection class.

But let us first take a closer look at what is needed to make the code work.

I have a small application where I store code snippets. I can categorize them and also test code locally or against a server.

In my sample, I want to get all documents from that application that have “DEMO” in the subject and output the subject in ascending order.
Next I want to get the documents category in descending order.

Both columns, Subject and Category need to be prepared for sorting. They do not neccessarily have to be sorted initially.

To set the sorting programmatically, I use the ‘Resortview’ method from the NotesView class.
Be aware that the columnName must be the programmatic name of the column.
Here is a sample how to use the ‘ResortView‘ method

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim vec As NotesViewEntryCollection

Set db = session.currentDataBase
Set view = db.getView("Samples")

' Sort By Subject
Call view.Resortview("Subject", true)
Set vec = view.Allentries

' Sort By Category
Call view.Resortview("category", false)
Set vec = view.Allentries

vec will now contain all view entries sorted ascending by Subject and after the second ResortView it will contail all view entries by Category in descending order.

You can use the following code to print the result to the console

Private Sub printIt(vec As NotesViewEntryCollection, itemName As String)
	Dim ve As NotesViewEntry
	Dim doc As NotesDocument
	Dim item As NotesItem
	Dim s As String
	Set ve = vec.Getfirstentry()
	While (Not ve Is Nothing)
		s = "- no value -"
		Set doc = ve.Document
		Set item = doc.Getfirstitem(itemName)
		If (Not item Is Nothing) Then
			If (item.text <> "") Then
				s = item.text
			End if
		End If
		MsgBox s
		Set ve = vec.Getnextentry(ve)
	Wend
End Sub

Now lets add some code to query for all documents that have “DEMO” in the subject.

By now, DQL does not have the capability to build a query that uses CONTAINS. This will be added in a future version of Notes and Domino.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView

Dim vec As NotesViewEntryCollection
Dim ve As NotesViewEntry
Dim col as NotesDocumentCollection
Dim doc As NotesDocument
	
Dim query As String
query = "Subject >= 'DEM' AND  Subject < 'DEN'"
Dim dql As NotesDominoQuery
	
Set db = session.currentDataBase
Set view = db.getView("Samples")

Set dql = db.CreateDominoQuery()
Set col = dql.Execute(query)

Call view.Resortview("Subject", true)
Set vec = view.Allentries
Call vec.Intersect(col, true)
Call printIt(vec, "Subject")

Call view.Resortview("category", false)
Set vec = view.Allentries
Call vec.Intersect(col, true)
Call printIt(vec, "category")

I put the code into an agent and ran that agent from the console. Here is the output.

Happy coding!


Technote: Limitations of NotesHTTPRequest and NotesJSONNavigator with future considerations

If you are already using the NotesHTTPRequest and / or NotesJSONNavigator classes in your code and you are experiencing one of the following issues, here is an important technote for you.

  • SPR# DCONB8VMAV – NotesJSONNavigator is unable to parse JSON content > 64k
  • SPR# ASHEB95LFR – Unable to parse JSON string: Missing a name for object member, offset 1
  • SPR# DCONB8F6JV – bad character conversion happening in NotesHTTPRequest response
  • SPR# ASHEB95LFR – NotesJSONNavigator unable to navigate a string which contains new lines and carriage returns
  • SPR# DCONBB2KNR – NotesJSONNavigator experiencing severe issues when parsing packages with empty string values
  • SPR# JCORBB2KWU – Unable to Post > 64K String in NotesHTTPRequest
  • SPR# DCONBB44T4 – Creating a NotesJSONNavigator from nulled response causes crash

https://www-01.ibm.com/support/docview.wss?uid=ibm10875724


Programmatically Update /Add Database to DQL Design Catalog

For high speed access to internal information about views and view columns, DQL processing uses design data extracted from view notes. Currently this information will be stored in a new database, named GQFdsgn.cat.

It is created using new updall flags. It does not replicate and is solely used as a fast-path tool to access design data at runtime.

Here is some LotusScript code to add / update the design of a named Notes application to the catalog. The NSFDesignHarvest call is currently undocumented. Use it at your own risk.

'DECLARATIONS

Public Const UPDATE_DESIGN_CATALOG = 0
Public Const ADD_TO_DESIGN_CATALOG = 1

Const NNOTES ="nnotes.dll"
Const LIBNOTES ="libnotes.so"

Declare Public Function WIN_NSFDbOpen Lib NNOTES Alias "NSFDbOpen" _
(ByVal dbName As String, hDb As Long) As Integer
Declare Public Function LIN_NSFDbOpen Lib LIBNOTES Alias "NSFDbOpen" _
(ByVal dbName As String, hDb As Long) As Integer
Declare Public Function WIN_NSFDbClose Lib NNOTES Alias "NSFDbClose" _
(ByVal hDb  As Long) As Integer
Declare Public Function LIN_NSFDbClose Lib LIBNOTES Alias "NSFDbClose" _
(ByVal hDb  As Long) As Integer
Declare Public Function WIN_NSFDesignHarvest Lib NNOTES Alias "NSFDesignHarvest" _
(ByVal hDb  As Long, ByVal flag  As Long) As Integer
Declare Public Function LIN_NSFDesignHarvest Lib LIBNOTES Alias "NSFDesignHarvest" _
(ByVal hDb  As Long, ByVal flag  As Long) As Integer

' API FUNCTIONS
Private Function NSFDbOpen( db As String, hDB As Long) As Integer
	If isDefined("WINDOWS") Then
		NSFDbOpen = WIN_NSFDbOpen(db,hDb)
	ElseIf isDefined("LINUX") Then
		NSFDbOpen = LIN_NSFDbOpen(db,hDb)
	End If
End Function

Private Function NSFDbClose (hDb As Long)
	If isDefined("WINDOWS") Then
		NSFDbClose = WIN_NSFDbClose(hDb)
	ElseIf isDefined("LINUX") Then
		NSFDbClose = LIN_NSFDbClose(hDb)
	End If
End Function

Private Function NSFDesignHarvest (hDb As Long, flag As long) As Integer
	If isDefined("WINDOWS") Then
		NSFDesignHarvest = WIN_NSFDesignHarvest(hDb, flag)
	ElseIf isDefined("LINUX") Then
		NSFDesignHarvest = LIN_NSFDesignHarvest(hDb, flag)
	End If
End Function

Public Function catalogDesign(sDb As String, flag As Long) As Integer
	
	Dim hDb As Long
	Dim rc As Integer
	
	If flag > 1 Then flag = 1
	If flag < 0 Then flag = 0
	
	rc = NSFDbOpen(sDb, hDb)
	
	If rc = 0 Then
		rc = NSFDesignHarvest(hDb, flag)
		rc = NSFDbClose(hDb)
	End If
	
	catalogDesign = rc 
	
End Function


Get Linux Version Information

To get some basic information about the installed Linux version you can use uname -a.

This will give you something like

Linux serv03.fritz.box 3.10.0-957.1.3.el7.x86_64 #1 SMP 
Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Well, we get the kernel version and the architecture.

rpm -qia ‘release gives much more information

Name        : nodesource-release
Version     : el7
Release     : 1
Architecture: noarch
Install Date: Thu 29 Nov 2018 09:01:53 AM CET
Group       : System Environment/Base
Size        : 3191
License     : MIT
Signature   : RSA/SHA256, Thu 04 Jan 2018 09:42:19 PM CET, Key ID 5ddbe8d434fa74dd
Source RPM  : nodesource-release-el7-1.src.rpm
Build Date  : Thu 04 Jan 2018 09:40:35 PM CET
Build Host  : luthien
Relocations : (not relocatable)
URL         : http://rpm.nodesource.com/pub_8.x/
Summary     : N|Solid repository configuration
Description :
This package contains the NodeSource NodeJS repository
GPG key as well as configuration for yum.
Name        : redhat-release-server
Version     : 7.4
Release     : 18.el7
Architecture: x86_64
Install Date: Tue 27 Nov 2018 01:50:07 PM CET
Group       : System Environment/Base
Size        : 43146
License     : GPLv2
Signature   : RSA/SHA256, Wed 28 Jun 2017 08:59:19 PM CEST, Key ID 199e2f91fd431d51
Source RPM  : redhat-release-server-7.4-18.el7.src.rpm
Build Date  : Wed 28 Jun 2017 08:36:32 PM CEST
Build Host  : x86-037.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
Summary     : Red Hat Enterprise Linux Server release file
Description :
Red Hat Enterprise Linux Server release files
Name        : epel-release
Version     : 7
Release     : 11
Architecture: noarch
Install Date: Wed 28 Nov 2018 07:54:48 AM CET
Group       : System Environment/Base
Size        : 24834
License     : GPLv2
Signature   : RSA/SHA256, Mon 02 Oct 2017 07:52:02 PM CEST, Key ID 6a2faea2352c64e5
Source RPM  : epel-release-7-11.src.rpm
Build Date  : Mon 02 Oct 2017 07:45:58 PM CEST
Build Host  : buildvm-ppc64le-05.ppc.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://download.fedoraproject.org/pub/epel
Summary     : Extra Packages for Enterprise Linux repository configuration
Description :
This package contains the Extra Packages for Enterprise Linux (EPEL) repository
GPG key as well as configuration for yum.


Enable/Disable/Sign agents without opening DDE

A couple of days ago, Thomas Adrian posted a new idea on aha.io Allow Enable/Disable/Sign agents from Domino Administrator without opening DDE.

This is a pretty cool idea, I think. Although there already is a great tool available from Ytria ( agentEZ ), handling of agents should be a part of the core features of Notes / Domino.

Notes / Domino contains some of the requested features and for example, you can enable an agent via adminp. You can simply create a new admin request in the admin4.nsf; if you know, which values to set. Unfortunately, this is not documented and you have to do a lot of try and error before the admin request is processed. The advantage of using adminp would be documentation of who did what.
As a downside, you cannot disable an agent; there is no adminp request for that.

Back in 2007, I already demonstrated, how you can add your own adminp requests to the adminp Delete Group Members Using The Administration Process

After reading Thomas’ idea, I decided to spend some hours on building a Domino server addin that would enable / disable or toggle the status of scheduled agents in an application. The application path, agent name and what to do should be passed as parameters to the addin.

Project “AMgr2” was born.

Over the years, I have created my own Notes cAPI CPP framework. This is still work in progress, as I add new methods and properties when I need them.

The framework is a great help when it comes to RAD in Notes / Domino using c/c++. I tried to name methods and properties as close as possible to what we have in LotusScript or Java to make the resulting source code readable and maintainable. Here is an example how I determine if an agent is of type “scheduled” within my framework

bool cNotesAgent::isScheduled() {
		cNotesDocument doc(db_h, agnt_id, OPEN_NOVERIFYDEFAULT);
		cNotesItemText trigger = doc.getItemText("$AssistTrigger");
		if(!trigger.compare("1")) {return TRUE;} else {return FALSE;} 
		}

Most of the magic happens in the framework, so the source code for AMgr2 is pretty short.

// main.h

#ifndef _MAIN_H_
#define _MAIN_H_

#include <string>

#if defined (_MSC_VER) &amp;&amp; !defined(ND64)
#pragma pack(push, 1)
#endif
#include <global.h>
#include <miscerr.h>
#include <addin.h>
#if defined (_MSC_VER) &amp;&amp; !defined (ND64)
#pragma pack(pop)
#endif

#include "cNotesFramework.h"
#include "cNotesAgent.h"
#include "cmdline.h"

#if defined (W64)
#define HANDLE DHANDLE
#undef NOTEHANDLE
#define NOTEHANDLE DHANDLE
#else
#define DHANDLE HANDLE
#undef NOTEHANDLE
#define NOTEHANDLE HANDLE
#endif

#define ADDIN_STATUS_LINE	"AMgr2"
#define APP_NAME	"AMgr2: "
#undef MSG
#define MSG(fmt) APP_NAME fmt
#define ERROR -1
using namespace std;

#endif

// main.cpp

/*
* Amgr2
*
* eknori at eknori dot de  www.eknori.de FEBRUARY 2019
*
* copyright (c) 2019 Ulrich Krause www.eknori.de
*/

#pragma warning(disable:4005) 

#include "main.h"

STATUS LNPUBLIC AddInMain (HMODULE hModule, int argc, char *argv[]) {

	STATUS				error = NOERROR;
	HANDLE				hStatusLine;
	HANDLE				hStatusLineDesc;
	HMODULE				hMod;

	AddInQueryDefaults (&amp;hMod, &amp;hStatusLine);
	AddInDeleteStatusLine (hStatusLine);
	hStatusLineDesc = AddInCreateStatusLine(ADDIN_STATUS_LINE);
	AddInSetDefaults (hMod, hStatusLineDesc);
	AddInSetStatusText("Initialising");

	CmdLine *cmdline = new CmdLine();

	cmdline->addUsage("  amgr2, V1.0.0.0, (c) 2019, Ulrich Krause\n");
	cmdline->addUsage("Usage: lo amgr2 [options] [flags]\n");

	cmdline->addUsage( "Options:\n" );
	cmdline->addUsage( "-d    --db\t\tdatabase path" );
	cmdline->addUsage( "-a    --agent\t\tagent name" );

	cmdline->addUsage( "" );
	cmdline->addUsage( "Flags:\n" );
	cmdline->addUsage( "-h    --help\t\tPrints this help" );
	cmdline->addUsage( "      --enable\tEnable agent" );
	cmdline->addUsage( "      --disable\tDisable agent" );
	cmdline->addUsage( "      --toggle\tToggle agent status" );

	cmdline->setOption( "db", 'd' );
	cmdline->setOption( "agent", 'a' );

	cmdline->setFlag ( "help", 'h' ); 
	cmdline->setFlag ( "enable");
	cmdline->setFlag ( "disable");
	cmdline->setFlag ( "toggle");

	cmdline->processCommandArgs( argc, argv );

	if( ! cmdline->hasOptions()) {
		cmdline->printUsage2();
		delete cmdline;
		return ERROR;
		}

	if( cmdline->getFlag( "help" ) 
		|| cmdline->getFlag( 'h' ) ) {
			cmdline->printUsage2();
			return NOERROR;
		}

	string file_path;
	if( cmdline->getValue( 'd' ) != NULL  
		|| cmdline->getValue( "db" ) != NULL  ){
			file_path = cmdline->getValue( 'd' );
		} 

	string agent_name;
	if( cmdline->getValue( 'a' ) != NULL  
		|| cmdline->getValue( "agent" ) != NULL  ){
			agent_name = cmdline->getValue( 'a' );
		} 

	cNotesDatabase _NotesDatabase;

	try{

		_NotesDatabase.open(
			file_path.c_str());

		cNotesAgent _NotesAgent(
			_NotesDatabase.h, agent_name.c_str());

		if(_NotesAgent.isScheduled()) {

			if( cmdline->getFlag( "enable" )) {
				_NotesAgent.enable();

				AddInLogMessageText(
					MSG("... agent '%s' in database '%s' has been enabled\n"), 
					NOERROR, 
					_NotesAgent.name.c_str(), 
					_NotesDatabase.filePath().c_str());
				}

			if( cmdline->getFlag( "disable" )) {
				_NotesAgent.disable();

				AddInLogMessageText(
					MSG("... agent '%s' in database '%s' has been disabled\n"), 
					NOERROR, 
					_NotesAgent.name.c_str(), 
					_NotesDatabase.filePath().c_str());
				}

			if( cmdline->getFlag( "toggle" )) {
				if(_NotesAgent.isEnabled()) {
					_NotesAgent.disable();

					AddInLogMessageText(
						MSG("... agent '%s' in database '%s' has been disabled\n"), 
						NOERROR, 
						_NotesAgent.name.c_str(), 
						_NotesDatabase.filePath().c_str());
					}
				else {
					_NotesAgent.enable();

					AddInLogMessageText(
						MSG("... agent '%s' in database '%s' has been enabled\n"), 
						NOERROR, 
						_NotesAgent.name.c_str(), 
						_NotesDatabase.filePath().c_str());
					}
				}

			} else { // is_scheduled

				AddInLogMessageText(
					MSG("... agent '%s' in database '%s' is not a scheduled agent\n"), 
					NOERROR, 
					_NotesAgent.name.c_str(), 
					_NotesDatabase.filePath().c_str());

			}

		} catch (cNotesErr&amp; err) {
			delete cmdline;
			_NotesDatabase.close();

			AddInLogMessageText(
				MSG("Notes Error: %s\n"), 
				NOERROR, err.what());
			return ERROR;

		} catch (...) {
			delete cmdline;
			_NotesDatabase.close();

			AddInLogMessageText("Unexpected Error\n", NOERROR);
			return ERROR;
			}

		delete cmdline;
		_NotesDatabase.close();
		return error;
	}

To build the cmdline parser, I use another framework that I wrote a couple of years ago. I used the Boost.Program_options in a couple of other projects before, but it is a lot of overhead for such a small project like AMgr2.
CmdLine is much smaller. Despite of its simplicity, it is reliable and produces nice help screens.

I have not yet published CmdLine on Github. If you are interested in the source code, send me an email and I will send you the sources.

Putting it all together, we get a 64bit binary amgr2.exe Copy it to your Domino program directory and you are ready to go.

Open the Domino server console and type

lo amgr2 -h  and you should get

  amgr2, V1.0.0.0, (c) 2019, Ulrich Krause

  Usage: lo amgr2 [options] [flags]

  Options:

  -d    --db		database path
  -a    --agent		agent name
  
  Flags:

  -h    --help		Prints this help
        --enable	Enable agent
        --disable	Disable agent
        --toggle	Toggle agent status

To enable a scheduled agent in an application type

lo amgr2 -d names.nsf -a test --enable

[219C:0002-1CE8] 17.02.2019 08:39:56   AMgr2: ... agent 'test' in database 'names.nsf' has been enabled 

Use –disable to disable an agent or –toggle to change the status of an agent accordingly.

AMgr2 only works for scheduled agents. If an agent does not match this criteria, you’ll get the following message on the server console

lo amgr2 -d names.nsf -a test2 --toggle

[1F94:0002-15D8] 17.02.2019 08:47:53   AMgr2: ... agent 'test2' in database 'names.nsf' is not a scheduled agent

You also can build a simple Notes application that scans all applications on a server for scheduled agents.
Next you can use NotesSession.SendConsoleCommand to enable / disable / toggle one or more agents.

Here is some sample code

Sub Click(Source As Button)
	Dim session As New NotesSession
	serverName$ = "serv01/singultus"
	consoleCommand$ = Inputbox$("Type command:", _
	"Send console command")
	consoleReturn$ = session.SendConsoleCommand( _
	serverName$, consoleCommand$)
	Messagebox consoleReturn$,, consoleCommand$
End Sub

This might not be what Thomas asked for, but it is a good starting point. There is a lot room for improvements and enhancements. AMgr2 will sign the agent with the server id. This might not always be intended. It is not rocket science to implement code and add a couple of parameters to the cmdline parse to use a different id for signing. It is more work to make sure, this id is stored in a secure place and cnnot be accessed by any unauthorized person.

For now, this is it.

AMgr2 once again proves that you can do everything with Notes / Domino. The creators gave us tools that let us add functionallity that is not in the core code. OK, I admit that c/c++ is not the preferred programming language for most of the Notes / Domino developers.


SyntaxHighlighter Evolved: @Formula Brush

Submitted another plugin to the WordPress plugin directory.

The plugin adds a new brush to the SyntaxHighlighter Evolved plugin to colorize @formula code.

Example:

_exclude:= 
"$FILE":"$Fonts":"Form":"$UpdatedBy":"$Revisions":
"ID":"ModifiedBy":"AddressInvoiceAppartment";
_fld:=@Trim(@ReplaceSubstring(@DocFields; _exclude; @Nothing));
 
"{\"@unid\":\""
+@Text(@DocumentUniqueID)+"\","
+ @Implode ( @Transform (
_fld; "_fn" ; "\"" + _fn + "\":\"" + 
@Text ( @GetField ( _fn) ) + "\"" ) ; "," ) +
"},"

java.lang.UnsatisfiedLinkError: lotus/domino/local/Database.NcreateDQuery()J

UPDATE 05-FEB-2019: Issue is being tracked under SPR # VRARB94KAQ

When executing db.createDominoQuery(); in a Java agent on the server, I see the following error message on the Domino console:

te amgr run "ec11.nsf" 'dql.java'
[021963:000035-00007F2BE8DFD700] 02/03/2019 05:41:29 AM AMgr: Start executing agent 'dql.java' in 'ec11.nsf'
[021963:000037-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent printing: Version: Release 10.0.1 November 29, 2018
[021963:000037-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent printing: Db Title: singultus's Directory
[021963:000038-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: Exception in thread "AgentThread: JavaAgent"
[021963:000039-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: java.lang.UnsatisfiedLinkError: lotus/domino/local/Database.NcreateDQuery()J
[021963:000041-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: at lotus.domino.local.Database.createDominoQuery(Unknown Source)
[021963:000043-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: at JavaAgent.NotesMain(JavaAgent.java:19)
[021963:000045-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: at lotus.domino.AgentBase.runNotes(Unknown Source)
[021963:000047-00007F2BE816F700] 02/03/2019 05:41:29 AM Agent Manager: Agent error: at lotus.domino.NotesThread.run(Unknown Source)
[021963:000035-00007F2BE8DFD700] 02/03/2019 05:41:29 AM AMgr: Agent 'dql.java' in 'ec11.nsf' completed execution

According to John Curtis (HCL) “… We haven’t seen this to date.”.

I have tested on different OS.

serv02: 
Red Hat Enterprise Linux Server release 7.4 (Maipo)
Linux serv02.fritz.box 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
IBM Domino (r) Server (64 Bit) (Release 10.0.1 for Linux/64) 02/03/2019 05:48:40 AM
serv02 has been upgraded from V10.0
serv03:
CentOS Linux release 7.6.1810 (Core)
Linux serv03.fritz.box 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
IBM Domino (r) Server (64 Bit) (Release 10.0.1 for Linux/64) 02/03/2019 05:49:15 AM (Community server)
serv03 is "fresh" install and not upgraded from earlier Domino versions.

Here is the code I used

import lotus.domino.AgentBase;
import lotus.domino.Database;
import lotus.domino.DominoQuery;
import lotus.domino.Session;

public class JavaAgent extends AgentBase {

	public void NotesMain() {

		try {
			Session session = getSession();
			System.out.println("Version: " + session.getNotesVersion());
			
			Database db = null;
			db = session.getDatabase(null, "names.nsf");
			System.out.println("Db Title: " + db.getTitle());
			
			DominoQuery dql = null;
			dql = db.createDominoQuery();

			dql.recycle();
			db.recycle();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

As it works on Domino 10.0.1 on WINDOWS, I investigated nlsxbe.dll and liblsxbe.so

nlsxbe.dll contains the function in question

Java_lotus_domino_local_Database_NcreateDQuery 0x0000000180017cd0 0x00017cd0 732 (0x2dc) nlsxbe.dll W:\Domino\nlsxbe.dll Exported Function

liblsxbe.so is missing the function. At least, it is not exported.

nm -D liblsxbe.so | grep createD

0000000000096a03 T Java_lotus_domino_local_Database_NcreateDocColl
0000000000095587 T Java_lotus_domino_local_Database_NcreateDocument
000000000012bf7d T Java_lotus_domino_local_DateRange_NrecreateDateRange
00000000000e33e1 T Java_lotus_domino_local_DateTime_NrecreateDateTime
0000000000110ad2 T Java_lotus_domino_local_DbDirectory_NcreateDatabase
00000000000d5d6d T Java_lotus_domino_local_Session_NcreateDateRange
00000000000da091 T Java_lotus_domino_local_Session_NcreateDateTime
00000000000d6bd1 T Java_lotus_domino_local_Session_NcreateDxlExporter
00000000000d6d71 T Java_lotus_domino_local_Session_NcreateDxlImporter
00000000000957a0 T Java_lotus_notes_Database_NcreateDocument
0000000000110d7e T Java_lotus_notes_DbDirectory_NcreateDatabase
00000000000d5f40 T Java_lotus_notes_Session_NcreateDateRange
00000000000da360 T Java_lotus_notes_Session_NcreateDateTime
U _ZN11XmlDocument14createDocumentEv
U _ZN11XmlDocument22cr
eateDocumentFragmentEv

The version and date seem to be OK.

ls -al liblsxbe.so
-rwxr-xr-x. 1 root root 14510400 Nov 29 07:48 liblsxbe.so

Perhaps someone else can confirm this behaviour. I have already created case #TS001863705 with HCL.


SyntaxHighlighter Evolved: LotusScript Brush

SyntaxHighlighter Evolved: LotusScript Brush is a small WordPress plugin that adds support for the LotusScript language to the great SyntaxHighlighter Evolved plugin by Alex Mills.

I have submitted a request to add the plugin to the official WordPress plugin directory. The review process will take some time.

In the meantime, you can start using SyntaxHighlighter Evolved: LotusScript Brush right now.

Download the plugin from here , unpack it and upload to your /wp-content/plugins directory.

Update 04-FEB-2019: The plugin is now available in the WordPress plugin directory.

Next activate the plugin

SyntaxHighlighter Evolved: LotusScript Brush will now be available as a new language in the Block Editor (“Code Languages”)

SyntaxHighlighter Evolved: LotusScript Brush highlights classes, method and properties, keywords, strings, comments and directives.


NotesDominoQuery – Find the needle in the haystack (LS)

Think about a big database with lots of documents in it and you want to find only one particular document. You can do that with FTSearch, or you can use a db.search with some formula.

As of V10.0.x, you also have DQL and the new NotesDominoQuery class.
The class is available in Lotsscript and Java.
I want to demonstrate in this sample, how you can find the needle in the haystack with DQL in Lotusscript.

My database has about 12.500.000 Documents. It is one of our customers database at midpoints. The amount of documents was created by accident. Some call it a bug. Anyway, the database is a good playground.

The code is typical for a LS developer. It initiates objects and stuff, assigns variables like our dqlTerm (line 6 see the similarity to the @formula, you would probably use with db.search? ), does a check, if the target database is open (line 9 ) and also has some basic error handling (17, 20-21). We will come to that later.

I am running the sample on the client. As of today , you cannot run a query client / server. I will show in another post, how you can run the query on the server and work with the results on the client. But that is another story.

public Sub foo() 
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim col As NotesDocumentCollection
	Dim dqlTerm As String
	dqlTerm = "form = 'frm.rules.device.rule' And rule_unid = '99A242AAB69B5BB9C1257FFC005DE6C4'"
	
	Set db = session.Getdatabase("","trul-big.nsf", False)
	If db.Isopen Then
		
		Dim dql As NOTESDOMINOQUERY
		Set dql = db.CreateDominoQuery()
		
		Dim parse_result As String
		parse_result = dql.parse(dqlTerm)

		If LCase(parse_result) = "success" Then
			Set col = dql.Execute(dqlTerm)
			MsgBox dql.Explain(dqlTerm)
		Else
			MsgBox parse_result
		End If
		
	End If
End Sub

Before you run the code and try to search such a huge amount of data, you need to set some notes.ini variables.

QUERY_MAX_DOCS_SCANNED=13000000 
QUERY_MAX_VIEW_ENTRIES_SCANNED=13000000

By now, there is no other way to increase the number of documents. There are setters in the NotesDominoQuery class, but those setters are broken. This is a known issue and HCL is working on a solution.

When we now run the code, we will get the following result

It took 51.3 secs to find 110642 documents that use the form “frm.rules.device.rule” and zero to none secs to find 1 document in that resultset.

Would it be faster or slower, if we modify our query to use only the rule_unid field and search over the entire set of documents?

dqlTerm = "rule_unid = '99A242AAB69B5BB9C1257FFC005DE6C4'"

Here is the result

32.2 secs to find the needle in the haystack. Use this kind of single field search, if you are sure that the field “rule_unid” is only used on one form.

But even in the case that the field is used on another form; to filter the resulting NotesDocument collection afterwards is much faster than the AND dqlTerm from the original code.

Maybe, you already have a view in your application where the rule_unid is in a sorted column.

Then we can use a modified dqlTerm to find the document in that view.

Again, let’s change our dqlTerm a little bit

dqlTerm = "'all'.rule_unid = '99A242AAB69B5BB9C1257FFC005DE6C4'"

And here is the result

THAT is pretty cool, isn’t it? 5.6 msecs to find the needle in the haystack.

Can it be even faster? I think no, but let us take another look at the code that does the query.

        Dim parse_result As String
        parse_result = dql.parse(dqlTerm)
 
        If LCase(parse_result) = "success" Then
            Set col = dql.Execute(dqlTerm)
            MsgBox dql.Explain(dqlTerm)
        Else
            MsgBox parse_result
        End If

We can safely remove all of our “Error handling”, that means lines 14-17 and 20-22. Why? Because dql.Excecute(dqlTerm) does the parse before executing the query.

So we end up with the following code

public Sub foo() 
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim col As NotesDocumentCollection
	Dim dqlTerm As String
	
	dqlTerm = "'all'.rule_unid = '99A242AAB69B5BB9C1257FFC005DE6C4'"

	Set db = session.Getdatabase("","trul-big.nsf", False)
	If db.Isopen Then
		Dim dql As NOTESDOMINOQUERY
		Set dql = db.CreateDominoQuery()
		Set col = dql.Execute(dqlTerm)
		MsgBox dql.Explain(dqlTerm)
	End If
End Sub

When we run the code, we get

Keep in mind that the numbers vary a litte bit from run to run.

If we now modify our dqlTerm and add an error, we are shown a nice dialog box explaining the error in detail.

That’s all for today, I hope you find this information useful.


Bye, bye, Watson Workspace

I received the following mail from IBM announcing the End of Marketing for all Watson Workspace offerings and ending the Watson Workspace service on 2/28/19.

Watson Workspace Announcement

Tomorrow, Tuesday 15 Jan 2019, IBM will formally announce the End of Marketing for all Watson Workspace offerings and we anticipate ending the Watson Workspace service on 2/28/19. This includes Watson Workspace Essentials, Plus, and the free offering. It is our intent to ensure that you have a clear understanding of your options regarding the closure of Watson Workspace.
While there is no question that Watson Workspace is innovative and agile, it hasn’t resonated with clients or obtained the traction in the marketplace necessary for IBM to continue forward with the service. Despite our best efforts and enthusiasm for these offerings, our decision to withdraw them aligns to IBM’s investment strategy, focused on delivering solutions that deliver measurable value to our customers and business partners.
IBM has stopped accepting new orders for Watson Workspace products, and we will not be adding any new features to the offerings. We have been working with our licensed customers and business partners to provide options for handling subscriptions and contracts once the end of service announcement is published to provide a smooth transition.
Starting tomorrow there will be a banner placed into the UI of Watson Workspace informing users of the timeline for moving off the service. Mobile customers may find details in the release notes of the mobile app. We will also provide access to a tool that will allow you to download and save your conversations and content from Watson Workspace. Please plan accordingly to capture any content you’d like to retain as we work to sunset the service. This option will only be available for a limited time.
Thank you for your support of Watson Workspace and IBM Collaboration Solutions. Please find additional details and answers to commonly asked questions in the FAQ that will be posted in the Watson Workspace banner tomorrow.


IBM Collaboration Services, Offering Management


NotesHttpRequest LotusScript example

NotesHttpRequest is a new LotusScript class in Notes V10.0.1 used to make HTTP requests to web servers.

The example wraps the get(), post(), put() and deleteResource() methods in a LotusScript class.

I have also put together a small Node.js / Express.js project that can be used as test server for the NotesHttpRequest example.

Class HttpRequestWrapper

%REM
	Library 10010.http
	Created Jan 8, 2019 by Ulrich Krause/singultus
%END REM
Option Public
Option Declare

Const BASE_URL_PORT = "http://192.168.178.35:3001/api/"
Const CLASS_CUSTOMER ="customers"

Const CUSTOMER_5 = |{
					"firstname" : "Ulrich",
					"lastname" : "Krause",
					"age" : 59,
					"id" : 5
				}|

Const CUSTOMER_5_UPDATE = |{
					"firstname" : "Heinz Ulrich",
					"lastname" : "Krause",
					"age" : 59,
					"id" : 5
				}|
				
%REM
	Class HttpRequestWrapper
%END REM
Public Class HttpRequestWrapper
	
	Private m_session As NotesSession
	Private m_url As String
	Private m_class As String
	Private m_json As String
	Private m_httpRequest As NOTESHTTPREQUEST
	
	%REM
		Sub New
	%END REM
	Public Sub New()
		Set m_session = New NotesSession
		Set m_httpRequest = me.m_session.CreateHttpRequest()
		
		m_httpRequest.Preferstrings = True
		
		m_url = BASE_URL_PORT
		m_class = CLASS_CUSTOMER
	End Sub
	
	%REM
		Function getApiVersion
	%END REM
	Public sub getApiVersion()
		m_json = m_httpRequest.Get(BASE_URL_PORT)
		MsgBox m_json
	End Sub
	
	%REM
		Sub getAllObj
	%END REM
	Public Sub getAllObj()
		m_json = m_httpRequest.Get(_
		BASE_URL_PORT + CLASS_CUSTOMER)
		
		MsgBox m_json
	End Sub
	
	%REM
		Sub getObjById
	%END REM
	Public Sub getObjById(id As String)
		m_json = m_httpRequest.Get(_
		BASE_URL_PORT + CLASS_CUSTOMER + "/" + id)
		
		MsgBox m_json	
	End Sub
	
	%REM
		Sub createObj
	%END REM
	Public Sub createObj()
		m_json = m_httpRequest.Post(_
		BASE_URL_PORT + CLASS_CUSTOMER,_
		removeCRLF(CUSTOMER_5))
		
		MsgBox m_json	
	End Sub
	
	%REM
		Sub updateObj
	%END REM
	Public Sub updateObj(id As String)
		m_json = m_httpRequest.Put(_
		BASE_URL_PORT + CLASS_CUSTOMER + "/" + id,_
		removeCRLF(CUSTOMER_5_UPDATE))
		
		MsgBox m_json
	End Sub
	
	%REM
		Sub deleteObj
	%END REM
	Public Sub deleteObj(id As String)
		m_json = m_httpRequest.DeleteResource(_
		BASE_URL_PORT + CLASS_CUSTOMER + "/" + id)
		
		MsgBox m_json
	End Sub
End Class

Public Function removeCRLF(json As String) As String
	removeCRLF = Replace(Replace(json, Chr(13), ""),Chr(10),"")
End Function

Sample usage:

Use "10010.http"

Sub Click(Source As Button)
	Dim httpRequestWrapper As New HttpRequestWrapper()

	Call httpRequestWrapper.getApiVersion()
	Call httpRequestWrapper.createObj()
	Call httpRequestWrapper.deleteObj("3")
	Call httpRequestWrapper.getAllObj()
	Call httpRequestWrapper.updateObj("5")
	Call httpRequestWrapper.getObjById("5")
End Sub



Starting Express.js applications with PM2

I recently ran into an issue with PM2. I have created a “helloworld” applications using Express.js.

[root@nodejs projects]# express helloworld
warning: the default view engine will not be jade in future releases
warning: use --view=jade' or--help' for additional options
create : helloworld/
create : helloworld/public/
create : helloworld/public/javascripts/
create : helloworld/public/images/
create : helloworld/public/stylesheets/
create : helloworld/public/stylesheets/style.css
create : helloworld/routes/
create : helloworld/routes/index.js
create : helloworld/routes/users.js
create : helloworld/views/
create : helloworld/views/error.jade
create : helloworld/views/index.jade
create : helloworld/views/layout.jade
create : helloworld/app.js
create : helloworld/package.json
create : helloworld/bin/
create : helloworld/bin/www
change directory:
$ cd helloworld
install dependencies:
$ npm install
run the app:
$ DEBUG=helloworld:* npm start

The application started without issues with npm start.

Next I started the application with PM2

[root@nodejs helloworld]# pm2 start app.js

PM2 displayed the application as “online”, but it constantly restarted and was not accessible.

I found the solution here

[root@nodejs helloworld]# pm2 start bin/www

did the trick for me.