private List<EventCalendar> getFollowingCals(String userId) throws Exception {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan().addGroup("userGroup");
    fp.setMaxFetchDepth(2);
    User user = pm.detachCopy(pm.getObjectById(User.class, userId));
    pm.close();

    log.info("Loading feed");
    EventCalendarDaoImpl eventDao = new EventCalendarDaoImpl();
    List<EventCalendar> cals = eventDao.getCalendarsById(user.getCalendarKeys(), 1);
    log.info("Loading feed: following cals count: " + cals.size());
    for (EventCalendar cal : cals) cal.setSource("following");
    return cals;
  }
 public void removeOwnedItem(String id, String itemId) {
   PersistenceManager pm = PMF.get().getPersistenceManager();
   User user = pm.getObjectById(User.class, id);
   EventCalendar cal = null;
   Set<EventCalendar> items = user.getOwnedCalendars();
   for (EventCalendar item : items) {
     if (item.getId().equals(itemId)) {
       cal = item;
       pm.deletePersistent(cal);
     }
   }
   user.removeOwnedCalendar(cal);
   pm.makePersistent(user);
   pm.close();
 }
 public void updateOwnedItem(String id, EventCalendar cal) {
   PersistenceManager pm = PMF.get().getPersistenceManager();
   User user = pm.getObjectById(User.class, id);
   Set<EventCalendar> items = user.getOwnedCalendars();
   for (EventCalendar item : items) {
     if (item.getId().equals(cal.getId())) {
       try {
         item.merge(cal);
         item.setDateLastUpdated(new Date());
         pm.makePersistent(item);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   pm.close();
 }