I'm writing an integration API in Java for IBM Domino 10, I want to perform resource (room) reservations, fetch and update them from an external source. So far, I successfully created an entry in current user's calendar (current session) and the reservation is also successfull, however I want to create reservations as certain users (personification), since only one user is configured to use my API database. So the main user is used to do everything, but I'd like to pass him the credentials of other users and he should create the events & reservations in their calendars. I can verify if an user exists & if his password is correct, but I don't know how could I open his calendar because it's session based.
My current code:
Database mdb = session.getDbDirectory(session.getServerName()).openMailDatabase();
NotesCalendar cal = session.getCalendar(mdb);
java.text.SimpleDateFormat datefmt = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
String dStart = datefmt.format(dtStart);
String dEnd = datefmt.format(dtEnd);
Name nnOrganizer = session.createName(session.getEffectiveUserName());
String iCalEntry = "BEGIN:VCALENDAR\n" +
"PRODID:-//Test//Reservation API//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"DTSTART:" + dStart + "\n" +
"DTEND:" + dEnd + "\n" +
"SUMMARY:Sample Meeting\n" +
"DESCRIPTION:TEST\n" +
"ORGANIZER;CN=admin/O=Corp:mailto:test@test.test\n" +
"ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;" + nnOrganizer.getCanonical() + ";RSVP=false:mailto:test@test.test\n" +
"ATTENDEE;CUTYPE=ROOM;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;" + nnResource.getCanonical() + ";RSVP=true:mailto:room@test.test\n" +
"END:VEVENT\n" +
"END:VCALENDAR\n";
NotesCalendarEntry entry = cal.createEntry(iCalEntry);
System.out.println("calendar uid " + entry.getUID());
How could I make this work with any user I want? So it's not using session.getCalendar()
but something else, so I could create an entry in another user's calendar.
Also, how can I programatically get the organizer's & room's email addresses? As for now, they are hardcoded. I know I could do a directory lookup, but sometimes the email (internet address) isn't configured, and lookupNames returns nothing. Notes client somehow bypasses that and creates an email like Name_Surname/server@Corp
, is it enough?
Edit
I achieved what I wanted by using the REST Service (CustomServiceBean) and NotesCalendar for creating/updating/deleting reservations, paired with direct document access to check for conflicts and read detailed room & reservation data. Everything works fine so far, reservations are visible in both user's calendar and the dtabase. However when I re-installed the server from scratch and added the database with rest service, I couldn't access the api with my default admin user (403 forbidden, You are forbidden to perform this operation ) server logs:
HTTP JVM: CLFAD0229E: Security exception occurred servicing request for: /db.nsf/services.xsp/api - HTTP Code: 403. For more detailed information, please consult error-log-0.xml
When I added the admin user to Configuration->Current Server Document->Security->Sign or run unrestricted methods and operations, it starts working correctly, even when accessing the API with newly registered users (that weren't assigned any groups, permissions, nothing at all just an internet password & address and they were created by the admin account) Will this work correctly? I need to access the API from accounts of normal users, because I need to create entries in user's calendars.