Exemplo n.º 1
0
  protected void notifyInstanceChange(
      final SysEvent.SysCode code,
      final BwEvent val,
      final boolean shared,
      final String recurrenceId)
      throws CalFacadeException {
    try {
      String note = getChanges(code, val);
      if (note == null) {
        return;
      }

      /* We flag these as indexed. They get handled by the update for
        the master
      */
      if (code.equals(SysEvent.SysCode.ENTITY_DELETED)
          || code.equals(SysEvent.SysCode.ENTITY_TOMBSTONED)) {
        postNotification(
            SysEvent.makeEntityDeletedEvent(
                code,
                authenticatedPrincipal(),
                val.getOwnerHref(),
                val.getHref(),
                shared,
                val.getPublick(),
                true, // Indexed
                IcalDefs.fromEntityType(val.getEntityType()),
                recurrenceId,
                note,
                null)); // XXX Emit multiple targted?
      } else {
        postNotification(
            SysEvent.makeEntityUpdateEvent(
                code,
                authenticatedPrincipal(),
                val.getOwnerHref(),
                val.getHref(),
                shared,
                true, // Indexed
                val.getRecurrenceId(),
                note, // changes
                null)); // XXX Emit multiple targted?
      }
    } catch (NotificationException ne) {
      throw new CalFacadeException(ne);
    }
  }
Exemplo n.º 2
0
  protected String getChanges(final SysEvent.SysCode code, final BwEvent val) {
    try {
      if (code.equals(SysEvent.SysCode.ENTITY_DELETED)
          || code.equals(SysEvent.SysCode.ENTITY_TOMBSTONED)) {
        return NotificationsInfo.deleted(authenticatedPrincipal(), val);
      }

      if (code.equals(SysEvent.SysCode.ENTITY_UPDATED)) {
        return NotificationsInfo.updated(authenticatedPrincipal(), val);
      }

      if (code.equals(SysEvent.SysCode.ENTITY_ADDED)) {
        return NotificationsInfo.added(authenticatedPrincipal(), val);
      }

      return null;
    } catch (Throwable t) {
      error(t);
      return null;
    }
  }