我有一个项目为Lotus Notes创建一个插件,可以创建新的日历条目并获取现有日历条目的数据。
偏好
到目前为止我做了什么:
我做了一个工具栏按钮,其中创建了一个日历条目,点击时。按'F9'后,创建的日历条目将显示在莲花笔记日历上,但是当我点击它时,我收到错误warning 'IBM Notes: Object variable not set'
。我通过谷歌搜索了这个问题并发现,我必须在ACL上设置访问权限。我以不同的方式尝试了这一点,但到目前为止没有任何效果。
这是我的代码:
package com.acme.plugin;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
NotesThread.sinitThread();
Session session = NotesFactory.createSession();
DbDirectory dir = session.getDbDirectory(null);
Database db = dir.openMailDatabase();
Document document = db.createDocument();
MeetingInformation dummyData = createDummyData(session);
// Testing if calendar read and write rights are given
int accLevel = db.queryAccess(dummyData.getUsername());
int accPriv = db.queryAccessPrivileges(dummyData.getUsername());
boolean blnCanWriteCalendar = ((accPriv & Database.DBACL_WRITE_PUBLIC_DOCS) > 0)
| accLevel > ACL.LEVEL_AUTHOR;
boolean blnCanReadCalendar = ((accPriv & Database.DBACL_READ_PUBLIC_DOCS) > 0)
| accLevel >= ACL.LEVEL_READER;
if ((blnCanWriteCalendar && blnCanReadCalendar) == false) {
ACL acl = db.getACL();
ACLEntry entry = acl.getEntry(dummyData.getUsername());
entry.setPublicReader(true);
if (entry.isPublicReader())
System.out.println("PublicReader = true");
entry.setPublicWriter(true);
if (entry.isPublicWriter())
System.out.println("PublicWriter = true");
acl.save();
}
createCalenderEntry(document, session, dummyData);
} catch (Exception e) {
e.printStackTrace();
}
}
private void createCalenderEntry(Document document, Session session,
MeetingInformation meetingInformation) {
try {
// Appointment Type
document.replaceItemValue("Form", "Appointment");
document.replaceItemValue("AppointmentType", meetingInformation
.getAppointmentType());
// Subject, Location
document.replaceItemValue("Categories", "Meeting");
document.replaceItemValue("Location", meetingInformation
.getLocation());
document.replaceItemValue("Subject", meetingInformation
.getSubject());
document.replaceItemValue("Body", meetingInformation
.getDescription());
// Creator of meeting
document
.replaceItemValue("Chair", meetingInformation.getUsername());
document.replaceItemValue("AltChair", meetingInformation
.getUsername());
document.replaceItemValue("From", meetingInformation.getUsername());
document.replaceItemValue("Principal", meetingInformation
.getUsername());
document.replaceItemValue("$AltPrincipal", meetingInformation
.getUsername());
// Remind settings
document.replaceItemValue("Alarm", 1);
document.replaceItemValue("AlarmOffset", -15);
document.replaceItemValue("Alarms", 1);
// Icon
switch (Integer.parseInt(meetingInformation.getAppointmentType())) {
case 0:
document.replaceItemValue("_ViewIcon", 160);
document.replaceItemValue("$IconSwitcher", "Appointment");
break;
case 1:
document.replaceItemValue("_ViewIcon", 63);
document.replaceItemValue("$IconSwitcher", "Anniversary");
break;
case 2:
document.replaceItemValue("_ViewIcon", 9);
document.replaceItemValue("$IconSwitcher", "AllDayEvent");
break;
case 3:
document.replaceItemValue("_ViewIcon", 158);
document.replaceItemValue("$IconSwitcher", "Meeting");
break;
case 4:
document.replaceItemValue("_ViewIcon", 10);
document.replaceItemValue("$IconSwitcher", "Reminder");
break;
default:
document.replaceItemValue("_ViewIcon", 158);
document.replaceItemValue("$IconSwitcher", "Meeting");
}
/* date and time ----- */
// date in format dd/mm/yyyy
DateTime startDay = session.createDateTime(meetingInformation
.getStartDay());
// time in format hh/mm/ss (AM|PM)
DateTime startTime = session.createDateTime(meetingInformation
.getStartTime());
DateTime endTime = session.createDateTime(meetingInformation
.getEndTime());
document.replaceItemValue("CalendarDateTime", startDay);
document.replaceItemValue("StartDateTime", startTime);
document.replaceItemValue("EndDateTime", endTime);
document.replaceItemValue("StartDate", startDay);
document.replaceItemValue("EndDate", startDay);
document.replaceItemValue("EndTime", endTime);
document.replaceItemValue("$NoPurge", endTime);
document.replaceItemValue("tmpStartTime_Local", startTime);
document.replaceItemValue("tmpEndTime_Local", endTime);
// save document and alarm
document.save(true);
document.putInFolder("$Alarms", true);
} catch (Exception e) {
e.printStackTrace();
}
}
private MeetingInformation createDummyData(Session session) {
MeetingInformation meetingInformation = new MeetingInformation();
try {
meetingInformation.setUsername(session.getUserName());
meetingInformation
.setSubject("Created Meeting by plugin");
meetingInformation.setAppointmentType("3");
meetingInformation.setStartTime("01:00:00 PM");
meetingInformation.setEndTime("02:00:00 PM");
meetingInformation.setStartDay("12/08/2013");
meetingInformation.setEndDay("12/08/2013");
meetingInformation.setRecipient("testing_notes@gmx.net");
meetingInformation.setDescription("Description: hidden feature");
meetingInformation.setLocation("Everywhere");
} catch (Exception e) {
e.printStackTrace();
}
return meetingInformation;
}
}
那么我该如何解决这个问题呢?要解决这个问题需要做些什么?
我环顾四周,但似乎无法找到解决此问题的任何方法,感谢任何帮助。
答案 0 :(得分:1)
“对象变量未设置”是常见的Lotusscript错误。我想,打开你的参赛作品会失败。在某些领域可能缺少字段或错误的值。
最好的方法是将您在字段级别(属性框)的文档与您手动输入的条目进行比较。
如果失败,启动调试器并找到有问题的代码段。
答案 1 :(得分:1)
现在我有一个解决这个问题的方法。
这些条目是作为草稿创建的,因此必须在通过java创建它们后保存它们,但它们是可编辑的,没有任何错误警告。
这里是java中的代码示例:
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
NotesThread.sinitThread();
Session session = NotesFactory.createSession();
DbDirectory dir = session.getDbDirectory(null);
Database db = dir.openMailDatabase();
createCalenderEntry(db, session, createDummyData(session));
} catch (Exception e) {
e.printStackTrace();
}
}
private void createCalenderEntry(Database database, Session session,
MeetingInformation meetingInformation) {
try {
Document document = database.createDocument();
// Appointment Type
document.replaceItemValue("Form", "Appointment");
document.replaceItemValue("AppointmentType", meetingInformation
.getAppointmentType());
// Subject
document.replaceItemValue("Subject", meetingInformation
.getSubject());
document.replaceItemValue("Body", meetingInformation
.getDescription());
// Creator of meeting
document
.replaceItemValue("Chair", meetingInformation.getUsername());
document.replaceItemValue("From", meetingInformation.getUsername());
document.replaceItemValue("Principal", meetingInformation
.getUsername());
// Icon
switch (Integer.parseInt(meetingInformation.getAppointmentType())) {
case 0:
document.replaceItemValue("_ViewIcon", 160);
document.replaceItemValue("$IconSwitcher", "Appointment");
break;
case 1:
document.replaceItemValue("_ViewIcon", 63);
document.replaceItemValue("$IconSwitcher", "Anniversary");
break;
case 2:
document.replaceItemValue("_ViewIcon", 9);
document.replaceItemValue("$IconSwitcher", "AllDayEvent");
break;
case 3:
document.replaceItemValue("_ViewIcon", 158);
document.replaceItemValue("$IconSwitcher", "Meeting");
break;
case 4:
document.replaceItemValue("_ViewIcon", 10);
document.replaceItemValue("$IconSwitcher", "Reminder");
break;
default:
document.replaceItemValue("_ViewIcon", 158);
document.replaceItemValue("$IconSwitcher", "Meeting");
}
/* date and time ----- */
// date in format dd/mm/yyyy
DateTime startDay = session.createDateTime(meetingInformation
.getStartDay());
// time in format hh/mm/ss (AM|PM)
DateTime startTime = session.createDateTime(meetingInformation
.getStartTime());
DateTime endTime = session.createDateTime(meetingInformation
.getEndTime());
document.replaceItemValue("CalendarDateTime", startDay);
document.replaceItemValue("StartDateTime", startTime);
document.replaceItemValue("EndDateTime", endTime);
document.replaceItemValue("StartDate", startDay);
document.replaceItemValue("StartTime", startTime);
document.replaceItemValue("EndDate", startDay);
document.replaceItemValue("EndTime", endTime);
document.replaceItemValue("$NoPurge", endTime);
document.replaceItemValue("tmpStartTime_Local", startTime);
document.replaceItemValue("tmpEndTime_Local", endTime);
document.replaceItemValue("$PublicAccess", "1");
document.replaceItemValue("MailOptions", "");
document.replaceItemValue("$CSFlags", "m");
document.replaceItemValue("$CSVersion", "2");
document.replaceItemValue("ExcludeFromView", "D");
// save document and alarm
document.save(false, true);
} catch (Exception e) {
e.printStackTrace();
}
}
private MeetingInformation createDummyData(Session session) {
MeetingInformation meetingInformation = new MeetingInformation();
try {
meetingInformation.setUsername(session.getUserName());
meetingInformation
.setSubject("Meeting title");
meetingInformation.setStartTime("01:00:00 PM");
meetingInformation.setEndTime("02:00:00 PM");
meetingInformation.setStartDay("12/08/2013");
meetingInformation.setEndDay("12/08/2013");
meetingInformation.setLocation("Everywhere");
meetingInformation.setDescription("Description");
meetingInformation.setRecipient("test@mail.com");
meetingInformation.setAppointmentType("3");
} catch (Exception e) {
e.printStackTrace();
}
return meetingInformation;
}
}