views:

1100

answers:

6

I am working on a simple java code to extract all calendar entries for a given date. I know it possible using Domingo but I would like to use only Notes.jar for this purpose. It is possible for me to create a session based on a given credentials and get the calendar object. I am looking to extract the current running notes session and use that session object to open the calendar view in the mail file and start playing with it. But I am not able to get it working. Anybody have any idea or links on this ?

+1  A: 

Just by googling I have found this article. They create an Eclispe plugin there for Notes. And the example code for getting employee brithdays is also there (I guess Calendar works in a similar way):

    s = NotesFactory.createSession();

    // Get the local address book
    Database nab = s.getDatabase("",s.getAddressBooks().elementAt(0).toString());
    if (nab.isOpen() == false) nab.open();  

    // Get the Birthdays & Anniversaries view     
    View baview = nab.getView("BA");
    ViewEntryCollection eba = baview.getAllEntries();
    ViewEntry entry = eba.getFirstEntry();

    list = new String[eba.getCount()];
    int count = 0;

    while (entry != null) {

        Vector vals = entry.getColumnValues();          
        list[count]= vals.elementAt(1).toString() + " " + vals.elementAt(2).toString();             
        entry = eba.getNextEntry();
        count++;
    }

EDIT: Also look at this link for some documentation on Notes.jar.

Superfilin
A: 

For some reason its failing at "NotesFactory.createSession();". In anycase If i am not wrong the code is accessing the address books database and getting the information. Most of the code in the domino docs are specific to write java code inside LN and outside. For instance most of the code uses a code called getSession(). But I can't figure out where the heck the code is there for getSession(). Any idea ?

vikramjb
+1  A: 

The NotesFactory.createSession() method is what you can use to get a handle to the current session. Notes will automatically share the current client session. If this method is failing, there may be something wrong with your basic configuration. Be sure that:

  • You have the Notes Client fully installed on the machine running the Java app, and be sure there is a valid Notes ID file. (For example, be sure you can open the Notes client on this machine successfully).
  • Also, be sure that the the nnotes.dll file is accessible on your machine's path (different than the Java CLASSPATH).
  • And, confirm that the Notes.ini file is also on the machine's PATH.
Ed Schembor
A: 

HI Ed

  • I have LN 8.0.2 installed on my machine and i am able to get a valid session using Domingo API which is a wrapper around Notes.jar.
  • nnotes.dll is there in C:\notes, i am not sure what you mean by machine path

  • notes.ini is there in c:\notes, i am not sure what you mean by machine path

The worst part now is even using Domingo API is not giving me access to the meeting invites for a particular day. Damn

vikramjb
A: 

Well I have done with the default notes API and here's the code.

NotesAPITest nat = new NotesAPITest();
  NotesThread.sinitThread();

  Session sess1 = NotesFactory.createSession();
  System.out.println(sess1.getUserName());
  Database database = sess1.getDatabase("", "mailfile");
  View calendarView = database.getView("($Calendar)");
  DateTime dt = sess1.createDateTime("today");
  ViewEntryCollection vec = calendarView.getAllEntriesByKey(dt, true);

  ViewEntry entry = vec.getFirstEntry();
      while (entry != null) 
      {

        Document caldoc = entry.getDocument();

        System.out.println("Subject: " + caldoc.getItemValueString("Subject"));
        System.out.println("Chair Person: " + caldoc.getItemValueString("Chair"));
        System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "StartDateTime") );
        System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "EndDateTime") );
        System.out.println("Required: " + caldoc.getItemValueString("RequiredAttendees"));
        entry = vec.getNextEntry(); 
      }

The only drawback i see is that, whenever the session is extracte, notes pops up a password dialog box. In my searches so far I have not seen a solution for that. Apparently a security arrangement in LN i guess.

vikramjb
+1  A: 

@vikramjb, try doing NotesFactory.createSession((String) null, (String) null, password); to prevent the notes password popup from prompting you each time you do something with the session that needs security.

Found out about this from here: http://lekkimworld.com/2006/07/10/java_in_notes_domino_explained_domino_session_tester.html

subdigit
and from here: http://www.ibm.com/developerworks/lotus/library/ls-Java_access_pt1/
subdigit
Thanks SubDigit, I was aware of that particular method. I did not want to add the overhead of caching LN usernames and password in my plugin which is why I did not use this method. Thanks for the link though.
vikramjb