* @param record Record to be added or updated
* @throws DataAccessException
*/
public Record setRecord(Record record, boolean modify) throws DataAccessException {
try {
EventList list = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
Event event = getEvent(record.getKey(), list, modify);
if (event == null) {
Dialog.inform("Event is null.");
return null;
}
String content = fixTag(record.getUid());
EventParser parser = ParserFactory.getParserInstance(list, event, modify);
parser.parseEvent(content);
event.commit();
String uid = event.getString(Event.UID, 0);
// Save the event data in cache
EventCache cache = new EventCache();
cache.put(uid, parser.getCacheData());
cache.save();
// Set the record key
record.setKey(uid);
list.close();
}
catch (Exception e) {
StaticDataHelper.log("[DEBUG]Exception in EventDataStore.setRecord(): " + e.toString());
//e.printStackTrace();