0

I'm writing Java code in an XPage Rest Service basing on https://setza-projects.atlassian.net/wiki/spaces/RSD/pages/44007659/IBM+Domino which is an REST service written in Java used to handle Resource Reservations database. However the way it currently works, it creates the reservations for the current session user only:

private JsonObject createIntanceAppointment(ResourceDefinition rd, Database reDatabase, Date dtStart, Date dtEnd, String subject) throws NotesException {
        Session session = reDatabase.getParent();
        Name nnOrganizier = session.createName(session.getEffectiveUserName());

        Name nnREsource = session.createName(rd.getFullName());
        DateTime dt_startDateUTC = session.createDateTime(dtStart);
        DateTime dt_endDateUTC = session.createDateTime(dtEnd);
        Document doc = reDatabase.createDocument();

        doc.replaceItemValue("form", "Reservation");
        doc.replaceItemValue("Purpose", subject);
        doc.replaceItemValue("ReservedFor", nnOrganizier.getCanonical());
        doc.replaceItemValue("ResourceName", nnREsource.getAbbreviated());
        doc.replaceItemValue("ResNameFormat", nnREsource.getAbbreviated());

I'm doing a very similar integration with Domino, although I'd prefer to have the reservations created for individual users (they provide their username & password on the room-booking application on a touch screen). I could just authenticate as the user in my REST client, but if I understand the installation requirements for that RoomZ api correctly, the 'api managing user' needs to be exclusively signed to the database, so I would need to do that for every user in Domino that could make reservations.

I tried using NotesFactory.createSession("", "user", "password"); but that doesn't work, it gives Cannot create a session from an agent error If I cannot create another session, is there any way I could verify that the username and password passed to the API in the payload is correct (to verify if the user can login)? Then I could just set the organizer/reserved for to this user.

Also, is there any way to make these reservation also appear in the organizer's Notes calendar? Currently they are succesfully created in the Reservations database and all, but the organizer is unaware of them despite he's assigned to the reservation.

AJ Cole
  • 169
  • 2
  • 13

1 Answers1

0

You do not need to create a session for every user. The important thing is the nnOrganizer = session.createName(" ") which should contain the user. Probably you'll also need to set additional fields like chair or from for the reservation.

If you want to have some entries in the organizers calendar, send them a proper invitation or create a calendar entry in their mailfile.

umeli
  • 1,068
  • 8
  • 14
  • But using the `nnOrganizer = session.createName("")` I was able to succesfully create a reservation for any random username, like `nnOrganizer = session.createName("CN=asdasdasd/O=Server")` even though the user wasn't existing in the Domino Server. If going this way, could I somehow check if some credentials are valid? I'd send the username & password in the json payload and confirm that they are valid in Java XPage. – AJ Cole Mar 15 '19 at 14:28
  • a minimal check would be to verify that the user exists in a directory, and if the user is in the directory there's a session.verifyPassword function.... – umeli Mar 15 '19 at 14:33
  • Thanks, I'll check it out. As for inviting the organizer (so he will also see the reservation in his calendar) how could I achieve this? – AJ Cole Mar 15 '19 at 14:37
  • As a starting point you could use for example https://itknowledgeexchange.techtarget.com/itanswers/how-to-create-a-lotus-notes-appointment-programmatically/ . There's a Calendar and Scheduling Schema from IBM available which tries to explain all the fields. https://www-10.lotus.com/ldd/ddwiki.nsf/dx/cs_schema_toc – umeli Mar 15 '19 at 14:45