Using the "queryAccess" - Method of the Database- class, you can find out the current access level. If this access- level is > ACL.LEVEL_AUTHOR then the user can for sure write to the calendar.
If the access is lower, then things become a little more complicated.
Calendar document are something special. They are so called "Public documents". Therefor the access- level is not the only indicator for the right access.
There are two possibilities, a user can gain "read"- access to calendar documents:
access level >= ACL.LEVEL_READER OR user has "Read Public documents" enabled in the Acl.
This can be checked using the "queryAccessPrivileges"- method of the database class.
To be able to write calendar entries, one has to have "Write Public documents" enabled.
Here is code, that respects all of these aspects:
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database db = agentContext.getCurrentDatabase();
String user = session.getUserName();
int accLevel = db.queryAccess(user);
int accPriv = db.queryAccessPrivileges(user);
boolean blnCanWriteCalendar = false;
boolean blnCanReadCalendar = false;
blnCanWriteCalendar = ((accPriv & Database.DBACL_WRITE_PUBLIC_DOCS) > 0)
| accLevel > ACL.LEVEL_AUTHOR;
blnCanReadCalendar = ((accPriv & Database.DBACL_READ_PUBLIC_DOCS) > 0)
| accLevel >= ACL.LEVEL_READER;
} catch(Exception e) {
e.printStackTrace();
}
}
}