Monthly Archives: May 2011

Lotus Domino: First Contact

Lotus Domino is an IBM server product that provides an enterprise collaboration platform.

To communicate with the Lotus Domino server over the network from a Java application IBM ships Domino with a library named NCSO.jar.

The document-oriented database of Lotus is called NSF (Notes Storage Facility). The data is stored as documents. To find specific documents views are used. Each document is associated with a unique ID and further meta data.

That’s all we need to now for making a fist contact to the server:



            String host = "172.16.230.132:63148";
            Session s = NotesFactory.createSession(host, "stephan/sw7", "secret");
            System.out.println(s.getUserName());

            Database db = s.getDatabase("dom7/sw7", "mail/stephan.nsf");

            Vector viewVector = db.getViews();
            Enumeration views = viewVector.elements();
            while(views.hasMoreElements()) {
                View v = (View)views.nextElement();
                System.out.println("HttpURL: " + v.getHttpURL());
                System.out.println("Name: " + v.getName());
                System.out.println("NotesURL: " + v.getNotesURL());
                System.out.println("SelectionFormula: " + v.getSelectionFormula());
                System.out.println("UniversalID: " + v.getUniversalID());
                System.out.println("URL: " + v.getURL());
                System.out.println("ViewInheritedName: " + v.getViewInheritedName());
                System.out.println();
            }


To access the inbox:


            View view = db.getView("$Inbox");

            Document doc = view.getFirstDocument();
            while(doc != null) {
                String docUniversalID = doc.getUniversalID();
                System.out.println(" UniversalID -> " + doc.getItemValue("UniversalID"));
                Document docMerker = doc;
                Vector items = doc.getItems();
                Enumeration enumer = items.elements();
                while(enumer.hasMoreElements()) {
                    Item key = (Item)enumer.nextElement();
                    Vector val = (Vector)doc.getItemValue(key.toString());
                    System.out.print(" " + key.toString() + " { ");
                    for(int i = 0; i < val.size(); i++)
                        System.out.print("    >>" + val.get(i) + "<<");
                    System.out.println(" }");
                }
                System.out.println();
                doc = view.getNextDocument(doc);
                docMerker.recycle();
            }