private Map<String, String> makeActivityParams(
     CalendarEvent event, String calendarId, String eventType) {
   Map<String, String> params = new HashMap<String, String>();
   params.put(EVENT_TYPE_KEY, eventType);
   params.put(EVENT_ID_KEY, event.getId());
   params.put(CALENDAR_ID_KEY, calendarId);
   params.put(EVENT_SUMMARY_KEY, event.getSummary());
   params.put(EVENT_LOCALE_KEY, event.getLocation() != null ? event.getLocation() : "");
   params.put(EVENT_DESCRIPTION_KEY, event.getDescription() != null ? event.getDescription() : "");
   params.put(EVENT_STARTTIME_KEY, String.valueOf(event.getFromDateTime().getTime()));
   params.put(EVENT_ENDTIME_KEY, String.valueOf(event.getToDateTime().getTime()));
   params.put(EVENT_LINK_KEY, makeEventLink(event));
   return params;
 }
  private Map<String, String> buildParams(CalendarEvent oldEvent, CalendarEvent newEvent) {
    Map<String, String> messagesParams = new LinkedHashMap<String, String>();
    try {
      if (CalendarEvent.TYPE_EVENT.equals(newEvent.getEventType())) {
        if (!oldEvent.getSummary().equals(newEvent.getSummary())) {
          messagesParams.put(SUMMARY_UPDATED, newEvent.getSummary());
        }

        /* change description */
        if (newEvent.getDescription() != null
            && !newEvent.getDescription().equals(oldEvent.getDescription())) {
          messagesParams.put(DESCRIPTION_UPDATED, newEvent.getDescription());
        }
        /* remove description */
        else if ((newEvent.getDescription() == null) && (oldEvent.getDescription() != null)) {
          messagesParams.put(DESCRIPTION_REMOVED, "");
        }

        /* change location */
        if (newEvent.getLocation() != null
            && !newEvent.getLocation().equals(oldEvent.getLocation())) {
          messagesParams.put(LOCATION_UPDATED, newEvent.getLocation());
        }
        /* remove location */
        else if ((newEvent.getLocation() == null) && (oldEvent.getLocation() != null)) {
          messagesParams.put(LOCATION_REMOVED, "");
        }

        if (newEvent.getPriority() != null
            && !newEvent.getPriority().equals(oldEvent.getPriority())) {
          messagesParams.put(PRIORITY_UPDATED, newEvent.getPriority());
        }
        if (newEvent.getAttachment() != null)
          if (oldEvent.getAttachment() == null) {
            messagesParams.put(ATTACH_UPDATED, "");
          } else if (newEvent.getAttachment().size() != oldEvent.getAttachment().size()) {
            messagesParams.put(ATTACH_UPDATED, "");
          }
        if (isAllDayEvent(newEvent)
            && !isAllDayEvent(oldEvent)
            && CalendarEvent.TYPE_EVENT.equals(oldEvent.getEventType())) {
          messagesParams.put(ALLDAY_UPDATED, "");
        } else if (!isAllDayEvent(newEvent)) {
          if (newEvent.getFromDateTime().compareTo(oldEvent.getFromDateTime()) != 0) {
            messagesParams.put(FROM_UPDATED, String.valueOf(newEvent.getFromDateTime().getTime()));
          }
          if (newEvent.getToDateTime().compareTo(oldEvent.getToDateTime()) != 0) {
            messagesParams.put(TO_UPDATED, String.valueOf(newEvent.getToDateTime().getTime()));
          }
        }

        /*=== compare the repeat type ===*/
        String repeatSummary = buildRepeatSummary(newEvent);
        if (!repeatSummary.equals(buildRepeatSummary(oldEvent))) {
          messagesParams.put(REPEAT_UPDATED, repeatSummary);
        }

        /*=== compare the activity id ===*/
        // oldEvent -- occurrence or instance of repetitive event -- no activity
        // newEvent -- repetitiveEvent - with activity
        if (!newEvent.getActivityId().equals(oldEvent.getActivityId())) {
          messagesParams.put(
              REPEAT_EVENT_INSTANCE_REMOVED,
              getDateFormattedAfterUserSetting(oldEvent.getRecurrenceId()));
        }

      } else {
        if (!oldEvent.getSummary().equals(newEvent.getSummary())) {
          messagesParams.put(NAME_UPDATED, newEvent.getSummary());
        }
        /* change note */
        if (newEvent.getDescription() != null
            && !newEvent.getDescription().equals(oldEvent.getDescription())) {
          messagesParams.put(NOTE_UPDATED, newEvent.getDescription());
        }
        /* removed note */
        else if ((newEvent.getDescription() == null) && (oldEvent.getDescription() != null)) {
          messagesParams.put(NOTE_REMOVED, "");
        }

        if (!isAllDayEvent(newEvent)) {
          if (newEvent.getFromDateTime().compareTo(oldEvent.getFromDateTime()) != 0) {
            messagesParams.put(FROM_UPDATED, String.valueOf(newEvent.getFromDateTime().getTime()));
          }
          if (newEvent.getToDateTime().compareTo(oldEvent.getToDateTime()) != 0) {
            messagesParams.put(TO_UPDATED, String.valueOf(newEvent.getToDateTime().getTime()));
          }
        }
        if (newEvent.getPriority() != null
            && !newEvent.getPriority().equals(oldEvent.getPriority())) {
          messagesParams.put(PRIORITY_UPDATED, newEvent.getPriority());
        }
        if (newEvent.getAttachment() != null)
          if (oldEvent.getAttachment() == null) {
            messagesParams.put(TASK_ATTACH_UPDATED, "");
          } else if (newEvent.getAttachment().size() != oldEvent.getAttachment().size()) {
            messagesParams.put(TASK_ATTACH_UPDATED, "");
          }
        if (newEvent.getEventState() != null
            && !newEvent.getEventState().equals(oldEvent.getEventState())) {
          if (CalendarEvent.NEEDS_ACTION.equals(newEvent.getEventState())) {
            messagesParams.put(TASK_NEED_ACTION, newEvent.getEventState());
          } else if (CalendarEvent.IN_PROCESS.equals(newEvent.getEventState())) {
            messagesParams.put(TASK_IN_PROCESS_ACTION, newEvent.getEventState());
          } else if (CalendarEvent.COMPLETED.equals(newEvent.getEventState())) {
            messagesParams.put(TASK_COMPLETED_ACTION, newEvent.getEventState());
          } else if (CalendarEvent.CANCELLED.equals(newEvent.getEventState())) {
            messagesParams.put(TASK_CANCELLED_ACTION, newEvent.getEventState());
          }
        }
      }
    } catch (Exception e) {
      if (LOG.isDebugEnabled()) LOG.error("Can not build message for space when event updated ", e);
    }
    return messagesParams;
  }