Personal Blog of Thomas Hampel - Creative Mythbusting in Development and Collaboration

Query results for : Development

Git Push Error : RPC failed; curl 56 SSLRead() return error -9806- 21 September 2016 - (0) Comments

Thomas Hampel
 21 September 2016

I am using Git for version control of software projects I am working on.
Recently I wanted to push the changes I've made to a Domino template my git client responded with the following error:

error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly

To cut a long story short : this problem was caused by using HTTP(S) for pusing changes to the git server. After changing to SSH, everything worked fine again.

Root Cause for ’Type mismatch in method OP_UNARY’- 21 March 2016 - (0) Comments

Thomas Hampel
 21 March 2016

Quickly creating a mail with Buttons containing LotusScript can cause headaches.
It just takes a few lines of code for running into undocumented error messages here is a small example:
Image:Root Cause for ’Type mismatch in method OP_UNARY’
will result in:
Image:Root Cause for ’Type mismatch in method OP_UNARY’

Changing "if not ..." to "is ..." like shown here
Image:Root Cause for ’Type mismatch in method OP_UNARY’
will result in a slightly different error message "Type mismatch in method IfCoerceBool: Unknown found, Uknown expected"
Image:Root Cause for ’Type mismatch in method OP_UNARY’
Do you spot the problem???

What is the root cause?

The property "IsNewDoc" acutally is a property of NotesUIDocument but is not a valid property of the NotesDocument class.
For testing if a NotesDocument is a new document, use the property IsNewNote
When creating a new button within the body of a new mail, Option Declare is not enabled by default like it is in the Designer client, so the error was not detected when saving the source code.
with Option Declare enabled its easier to spot the problem...
Image:Root Cause for ’Type mismatch in method OP_UNARY’

Reminder:

Mindoo FTP Server stopped running in Domino- 23 July 2015 - (0) Comments

Thomas Hampel
 23 July 2015

The Mindoo FTP Server project provides an FTP server wrapped into an XPages application. It is based on the Apache FtpServer which runs as OSGi plugin on the server side.
One day a customer reported the FTP server would no longer work. A quick check showed that port 21 does not respond any longer.

Restarting the HTTP task showed a JVM Exception
restart task http
...
17.07.2015 18:00:07   HTTP Server: Using Internet Site Configuration View
17.07.2015 18:00:12   JVM: Java Virtual Machine initialized.
17.07.2015 18:00:12   HTTP Server: Java Virtual Machine loaded
17.07.2015 18:00:16   XSP Command Manager initialized
17.07.2015 18:00:17   HTTP JVM: java.lang.reflect.InvocationTargetException


Checking the OSGI bundles showed the required bundle is not even installed.
> tell http osgi diag com.mindoo.ftp
Cannot find bundle com.mindoo.ftp.


Analysis

Check the file [DominoData]\domino\workspace\logs\error-log-0.xml for any problems
the very first warning in this file showed that a plugin was not loaded because the signer does not have the required access rights
CLFAD0331W: NSF Based plugin contribution denied because signer CN=SignerName/OU=Unit2/OU=Unit1/O=OrgEU does not have required access: CN=SignerName/OU=Unit2/OU=Unit1/O=OrgEU:System\UpdateSiteServer.nsf

and further down in the same file:
CLFAD0334W: Feature com.mindoo.ftp_feature_1.0.0.201306221322 skipped


At the first access rights seemed to be ok, but when looking a little closer I have found the user name does not have access to the server any longer because the Organization was renamed from "OrgEU" to "Org"

Solution (Part1)

The signature which is being used here is not a signature of a design element, it is the content of the Eclipse Update site which still had the old signature referenced. So how are we going to fix this?
  • Open the Eclipse UpdateSite and use "Actions\Sign All Content"
    Remark: This will not sign any design elements - it will sign the documents in the application only.
    Image:Mindoo FTP Server stopped running in Domino
  • Restart the HTTP task
    restart task http
  • Watching the server console
    Image:Mindoo FTP Server stopped running in Domino

Image:Mindoo FTP Server stopped running in Domino

Running into another problem

Although the FTP Server was running again, it seems like there still was an issue with the XPages application.
Quickly looking into  [DominoData]\domino\workspace\logs\error-log-0.xml showed a well known problem.
Image:Mindoo FTP Server stopped running in Domino

Solution (Part2)

Obviously someone did open the Application in Domino Designer without disabling the option to recompile xPages automatically.
So make sure this option is set to "Manually recompile Xpages"
Image:Mindoo FTP Server stopped running in Domino

and then open the Mindoo FTP Domino application in Domino Designer and hit "Project\Build Project" in your Designer client.
Image:Mindoo FTP Server stopped running in Domino

Testing results
  • Opening the Mindoo FTP Application from a browser seems to work
    Image:Mindoo FTP Server stopped running in Domino
  • "tell http osgi mftp status" shows that our server is now running on port 21
    Image:Mindoo FTP Server stopped running in Domino
  • Opening an FTP connection from a remote client is working fine

Source Control in Domino Designer 8.5.3- 10 October 2012 - (0) Comments

Thomas Hampel
 10 October 2012

Trying to set up a new machine with Domino Designer 8.5.3 and Source Control (SVN) based on this Blog post from Niklas Heidloff unfortunately was not working as expected.
It seems like the
Eclipse Update site for GEF which was refernced in his blog post was not available any longer.

> CWPPR0031: The requested provisioning operation(s) completed with partial success.

> Error parsing site stream. [The XML stream is not a valid default "site.xml" file. The root tag is not site.]


Image:Source Control in Domino Designer 8.5.3

A quick search brought me to the an update site hosting the
older versions recommended, adding it to the Application Locations fixed this small problem.
Image:Source Control in Domino Designer 8.5.3

Although this is one way to make it work, the most simple way is to make use of a ready-built Update Site from OpenNTF, see this project
Basically you need to download & unzip this file to your loal disk, and point the application installer to this update site.

Happy coding!

Exporting Notes Documents- 2 October 2012 - (0) Comments

Thomas Hampel
 2 October 2012

A customer wanted to have all attachments of some selected Notes document exported to the file system and also wanted to keep an option for developers to access the metadata of the original Notes document.
Nothing easier than that, so I wrote this small script to get the job done.


First the entire document is exported into DXL, then all attachments are detached to the file system. Both parts are not rocket science, but some people might want to reuse the code.
To avoid name conflicts while detaching files a folder is created for each Notes document so all attachments of this Notes document will be stored in this subfolder.


Option
Public
Option
Declare
Dim
gCounter&
Sub
Initialize
     
Dim s As New NotesSession
     
Dim coll As NotesDocumentCollection
     
Dim BasePath$

      BasePath$ =
InputBox ("Export data to path...: ", "Export", "C:\")
     
     
'# add backslash at the end
     
If right (BasePath$,1) <> "\" Then BasePath$ = BasePath$ & "\"
     
     
Print "Using BasePath : " & BasePath$
     
     
Set coll = s.currentdatabase.Unprocesseddocuments
     
If coll Is Nothing Then
             
MessageBox "No documents selected"
     
Else
             
Print "Processing " & coll.count & " documents..."
             
Call ExportToDXL (coll, BasePath$)
             
Call ExportToFile (coll, BasePath$)
             
MessageBox "Export completed."
     
End If        
End
Sub

Function
ExportToDXL (Coll As NotesDocumentCollection, BasePath As String)
     
Dim session As New NotesSession
     
Dim stream As NotesStream
     
Dim DXLfilename$
     
Dim doc As NotesDocument
     
Dim tdoc As NotesDocument
     
Dim exporter As NotesDXLExporter
     
     
If coll Is Nothing Then Exit function
     
Set doc = coll.getfirstdocument
     
While Not doc Is Nothing
             
Set tdoc = coll.getNextDocument (doc)
             
'# Open xml file named after current database
             
Set stream = session.CreateStream
              DXLfilename$ = BasePath$ & doc.universalid &
".dxl"
             
If Not stream.Open(DXLfilename$) Then
                     
MessageBox "Cannot open " & DXLfilename$,, "Error"
                     
Exit Function
             
End If
             
             
'# kick off the exporter process
             
Set exporter = session.CreateDXLExporter
             
Call exporter.SetInput(doc)
             
Call exporter.SetOutput(stream)
             
Call exporter.Process
             
             
Set doc = tdoc
     
Wend
End
Function

Function
ExportToFile (coll As NotesDocumentCollection, BasePath As String)
        On Error GoTo ErrH
        Dim doc As NotesDocument
        Dim tdoc As NotesDocument
        Dim rtitem As variant
        Dim targetpath$, fname$
        Dim FieldList(0) As String
        Dim oba As Variant
       
        '# define which fields to scan for attachments
        FieldList (0) = "Body"
       
        If coll Is Nothing Then Exit Function
       
        Set doc = coll.getfirstdocument
        While Not doc Is Nothing
                Set tdoc = coll.getNextDocument (doc)
                If doc.Hasembedded Then
                        targetpath$ = BasePath$ & doc.universalid & "\"
                       
                        If Dir$ (BasePath$ & doc.universalid, 16) = "" Then MkDir targetpath$
                       
                        '# loop list of fields
                        ForAll f In FieldList
                                 Set rtitem = doc.GetFirstItem(f)
                                 If Not rtitem Is Nothing Then
                                        If (rtitem.Type = RICHTEXT ) Then
                                                '# make sure the field contains some objects and detach
                                                If IsArray(rtitem.embeddedObjects) Then
                                                        ForAll o In rtitem.EmbeddedObjects
                                                                If ( o.Type = EMBED_ATTACHMENT ) Then
                                                                        Fname$=o.Name
                                                                        If FileExists (fname$) Then fname$ = CStr(gCounter&) & Fname$
                                                                        Call o.ExtractFile(targetPath$ & Fname$)
                                                                        gCounter& = gCounter& + 1
                                                                End If
                                                        End ForAll
                                                End If

                                        End If
                                End If
                        End ForAll
                End If
                Set doc = tdoc
        Wend
continue:
        Exit Function
       
errH:
        Stop
        Print "Error " & Err() & " in line " & Erl() & " - " & Error
        Resume continue
End Function

Profile documents and Author rights in ACL- 30 July 2012 - (0) Comments

Thomas Hampel
 30 July 2012

What if a developer is using user specific profile documents to store some settings in a Domino application.
In this example users have Author access with the ability to create new documents and the ability to write public documents, no roles and no reader or author name fields are used in any document.

Image:Profile documents and Author rights in ACL

I'm wondering why users are not able to modify their own profile document by using the simple formula @Command([EditProfile]; "profile"; @Username)

Of course developers will refer to the Designer Help or
this technote where IBM clearly states:

In order to edit profile documents, including your own profile, using @Command([EditProfile]), you must have at least Editor access or Author access in the ACL plus inclusion in an Author field.


so it sounds like the user name must be listed in an author name field in order to modify an existing userprofile.


Unfortunately in reality it seems to be working slightly different... see this example:

I've created a new form to be used as a profile document, the form contained only a single field

Image:Profile documents and Author rights in ACL
Additionally I've created a small agent with the following code:


Sub
Initialize
       
Dim s As New NotesSession
       
Dim doc As NotesDocument
       
Dim ws As New NotesUIWorkspace
       
       
Set doc = s.currentdatabase.Getprofiledocument("profile", s.Effectiveusername)
       
       
'# allows to modify the field values in the backend
       
Call doc.Replaceitemvalue("Test", "test")
       
Call doc.Save(true, false)
       
       
'# allows to modify field values using the frontend
       
Call ws.Dialogbox("profile", true, true, false, false, false, false, "Test", doc, false, false, false)
       
Call doc.Save(True, False)
       
       
'# does NOT allow to modify the document
       
Call ws.Editprofile("profile", s.Effectiveusername)
End
Sub

It seems like its possible to modify userprofile documents (which dont have an author name field) even when you dont have author access to the document itself.
To clarify: the application was put on a server and access rights were limited to Author.

Image:Profile documents and Author rights in ACL

I'm wondering if there's any good explanation for this behavior.

Update : The problem has been filed as SPR (Software Problem Report) # RGAU8WZE2X and the Customer Report, APAR # LO71028 was created.

Bug in DominoBlog template- 12 June 2012 - (0) Comments

Thomas Hampel
 12 June 2012

For some reason it wasnt possible to use embedded images within blog postings, looking at the HTML source of the resulting web page showed that some piece of HTML code was inserted when saving the document.
Image:Bug in DominoBlog template
After some debugging, I figured out that it was caused by the scriptlibrary "DXNotesContentProcessing" where the function "autoCreateLinks" is the one to be looked at.


Function
autoCreateLinks(strIn As String) As String
   
If configdoc.config_createlinks(0)="Create Links" Then
           
'Search for text and replace with link
           autoCreateLinks=strIn

           
Dim view As notesview
           
Dim docLink As NotesDocument
           
Set view=db.getview("vLinksDesc")
           
Set docLink=view.GetFirstDocument
           
Do Until docLink Is Nothing
                   
If Instr(autoCreateLinks," "+docLink.linktext(0)+" ")>0 Then
                           autoCreateLinks=R5replaceSubstring(autoCreateLinks,
" "+docLink.linktext(0)+" ",{ <a href="}+docLink.link(0)+{" title="}+docLink.linktext(0)+{">}+docLink.linktext(0)+{</a> })
                   
End If
                   
Set docLink=view.GetNextDocument(docLink)
           
Loop
   
Else
           autoCreateLinks=strIn

   
End If
End
Function

This function is used to replace a piece of text with the URL configured for it. Its using the links from "Configuration\Links" to search for any entry where the field "Link Text" is matching the HTML string.
Bad luck if one created links like this one, where no link text is specified:

Image:Bug in DominoBlog template


which causes the function above to search for the occurance of 2 spaces "  ", which unfortunately is true for embedded images... actually they are located directly behind the tag.

Image:Bug in DominoBlog template

Workaround
  • Turn off "Auto Create Links from Link List" located in the configuration document of the blog under "Site Settings\Content Creation"
  • Make sure that all links in "Configuration\Links" are created with a propper link text

What about a permanent fix?

Modify the form "Link" and add an input validation formula to the field "linktext" as shown below.

Image:Bug in DominoBlog template

Creating PDF documents from within Notes/Domino- 3 December 2011 - (0) Comments

Thomas Hampel
 3 December 2011

How can PDF documents be rendered from within a Notes application?
Converting Notes documents into Adobe's PDF format can be a challanging task.
Many different software addon products for Lotus Notes/Domino are being sold to make this happen,
e.g. DominoPDF which is being used by some of my customers - but in fact you dont need anything else than a Java component inside of your application.

Simply by using the iText Library and a small piece of source code, you can add PDF conversion functions to your Domino application. Look at this video to see an example. The solution outlined here makes sense for embedding this functionality inside an application. For single computers instead, its most likely enough to look at FreePDF (english) a freeware PDF converter which installs itself as a printer device.

Delete Workstation ECL- 17 November 2011 - (0) Comments

Thomas Hampel
 17 November 2011

Recently I came across a situation where multiple workstations had a corrupted local ECL. The document itself was corrupted that it was not possible to edit nor refresh it automatically. The only chance was to rebuild the ECL completely by creating a new NAB, which of course is not what users want to do. With some little reverse engineering and the help of some friends, I've figured out how to use an (undocumented) Notes API call to delete the workstation ECL directly.
For those who want to do something similar, here is the sourcecode:


%REM

      Agent DeleteECL

%END REM

Option
Public
Option
Declare

Const
ERR_MASK = &H3fff
Const
PKG_MASK = &H3f00
Const
ERRNUM_MASK = &H00ff

Declare
Function NSFDbOpen Lib "nnotes.dll" (ByVal PathName As String, rethDB As Long) As Integer
Declare
Function NSFDbClose Lib "nnotes.dll" (ByVal hDB As Long) As Integer
Declare
Function NSFDbDeleteECL Lib "nnotes.dll" (ByVal hDB As Long, ByVal UserName As String, ByVal UserNameLen As Integer, ByVal ECLType As Integer) As Integer
Declare
Function OSLoadString Lib "nnotes.dll" (ByVal hModule As Long, ByVal stringCode As Integer, _
ByVal
retBuffer As String, ByVal bufferLength As Integer) As Integer

Sub
DeleteECL(Source As Button)
     
Dim rc%, build&, filename$
     
Dim hDB&
     
Dim s As New NotesSession
     
      build& =  s.NotesBuildVersion        

     
If build& <= 190 Then filename$ = "desktop5.dsk" Else filename$ = "names.nsf"
     
     
Print "Using desktop file : " & filename$
     
      rc% = NSFDbOpen (filename$, hDB&)

     
If rc% <> 0 Then
             
Print "Unable to open " & filename$
             
End
     
End If
     
      rc% = NSFDbDeleteECL  (hdb&, s.UserName,
Len (s.UserName), 1)
     
If rc% = 0 Then
             
Print "Successfully deleted local Workstation-ECL in file " & filename$ & " for user " & s.UserName
     
Else
             
Print "Not successful, returncode = " & rc%
             
Print GetAPIError  (rc%)
     
End If
     
      rc% = NSFDbDeleteECL  (hdb&, s.UserName,
Len (s.UserName), 2)
     
If rc% = 0 Then
             
Print "Successfully deleted local Applet-ECL in file " & filename$ & " for user " & s.UserName
     
Else
             
Print "Not successful, returncode = " & rc%
             
Print GetAPIError  (rc%)
     
End If
     
      rc% = NSFDbDeleteECL  (hdb&, s.UserName,
Len (s.UserName), 3)
     
If rc% = 0 Then
             
Print "Successfully deleted local JavaScript-ECL in file " & filename$ & " for user " & s.UserName
     
Else
             
Print "Not successful, returncode = " & rc%
             
Print GetAPIError  (rc%)
     
End If
      rc% = NSFDbClose (hDB&)

     

End
Sub
Function
GetAPIError (errorCode As Integer) As String
     
'** this function translates Notes API error codes into their
     
'** corresponding error strings
     
Dim errorString As String*256
     
Dim returnErrorString As String
     
Dim resultStringLength As Long
     
Dim errorCodeTranslated As Integer
     
     
'** mask off the top 2 bits of the errorCode that was returned; this is
     
'** what the ERR macro in the API does
      errorCodeTranslated = (errorCode
And ERR_MASK)
     
     
'** get the error code translation using the OSLoadString API function
      resultStringLength = OSLoadString(
0, errorCodeTranslated, errorString, Len(errorString) - 1)
     
     
'** strip off the null-termination on the string before you return it
     
If (InStr(errorString, Chr(0)) > 0) Then
              returnErrorString =
Left$(errorString, InStr(errorString, Chr(0)) - 1)
     
Else
              returnErrorString = errorString

     
End If
     
      GetAPIError = returnErrorString

     

End
Function

How to enable/disable advanced DB properties such as DAOS- 1 September 2011 - (2) Comments

Thomas Hampel
 1 September 2011

Is it possible to set / remove the DAOS - flag in the advanced DB properties via Script??

Up to now I thought its possible to do it in the same way as for all the other DB flags as shown in this technote.

https://www-304.ibm.com/support/docview.wss?rs=899&uid=swg21244071

But it looks like the DAOS flag isnt stored in there....

Well in fact they are stored in there... but they are only exposed with ODS51 and the flag is not written to the $Flags field but written to a $DAOS field.


$DAOS=1 means enabled

$DAOS=0 means disabled

One could set the flag by using the small script supplied in the technote above and referring to the $DAOS field instead, but wait there's a better option:


Just use an (undocumented) LotusScript method "GetOption" and "SetOption" of the NotesDatabase class.

Call NotesDatabase.SetOption(81,true) will enable DAOS

Option
Public
Option
Declare

Sub
Initialize
       
'# Server name in canonical format, use "" for client:
       
Const Servername$ = ">>>your server name here<<<"
       
Dim db As NotesDatabase
       
Dim dbdir As New NotesDbDirectory(servername)
       
Set db = dbdir.GetFirstDatabase(DATABASE)
       
While Not db Is Nothing
               
'# Skip databases which you don't have access to
               
On Error 4060 GoTo Error4060
               
Call db.Open(servername, db.FilePath)
               
Call db.setoption(DBOPT_LZCOMPRESSION, True)
               
Call db.setoption(81, True)        '# DAOS Enable
GetNextDb:

               
Set db = dbdir.GetNextDatabase()
       
Wend
       
Exit Sub
Error4060:

       
'# If the code reaches here then the agent does not have access rights to the db.
       
Print db.FilePath & " incorrect rights to access!"
       
Resume GetNextDb
End
Sub

View Icons changed between Domino versions- 13 October 2010 - (0) Comments

Thomas Hampel
 13 October 2010

A customer asked me if the icons which are displayed in views have been changed between Domino 7.0 and 8.5.

In fact they did, see the difference yourself - when displaying icons in a view, Domino R6.5 and 7.0 are displaying those icons

Image:View Icons changed between Domino versions

starting with Domino 8.5. the icons have changed - in general they now display less colorful.

Table of column icons

Extract file name and display in a view- 24 September 2010 - (0) Comments

Thomas Hampel
 24 September 2010

If you want to display the file name in a view, but you only have a field containing file and pathname, here is a small formula to get the file name only.

List:=@Explode(FilePath;"\\");
nrElm:=@Elements(List);
@Subset(List;-1)
Go ElsewhereSubscribe to RSSAboutStay ConnectedAnd More
Thomas Hampel, All rights reserved.