private org.exoplatform.calendar.model.Calendar persist( org.exoplatform.calendar.model.Calendar cal, boolean isNew) { Calendar o; if (cal instanceof Calendar) { o = (Calendar) cal; } else { o = Calendar.build(cal); } int type = o.getCalType(); if (type == Calendar.Type.PERSONAL.type()) { try { dataStorage.saveUserCalendar(o.getCalendarOwner(), o, isNew); } catch (Exception ex) { LOG.error(ex); } } else if (type == Calendar.Type.GROUP.type()) { try { dataStorage.savePublicCalendar(o, isNew, null); } catch (Exception ex) { LOG.error(ex); } } else { throw new UnsupportedOperationException( "Save calendar with type '" + type + "' is not supported"); } return cal; }
@Override public Calendar remove(String id) { Calendar calendar = getById(id); if (calendar == null) { return null; } if (calendar.getCalType() == Calendar.Type.PERSONAL.type()) { try { dataStorage.removeUserCalendar(calendar.getCalendarOwner(), id); } catch (Exception ex) { LOG.error(ex); } } else if (calendar.getCalType() == Calendar.Type.GROUP.type()) { try { dataStorage.removeGroupCalendar(id); } catch (Exception ex) { LOG.error(ex); } } return calendar; }