/**
   * Implementation of command pattern. Will be called by ScheduledInvocationManager for delayed
   * announcement notifications
   *
   * @param opaqueContext reference (context) for message
   */
  public void execute(String opaqueContext) {
    // get the message
    final Reference ref = entityManager.newReference(opaqueContext);

    // needed to access the message
    enableSecurityAdvisorToGetAnnouncement();

    final AnnouncementMessage msg = (AnnouncementMessage) ref.getEntity();
    final AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader();

    // read the notification options
    final String notification = msg.getProperties().getProperty("notificationLevel");

    int noti = NotificationService.NOTI_OPTIONAL;
    if ("r".equals(notification)) {
      noti = NotificationService.NOTI_REQUIRED;
    } else if ("n".equals(notification)) {
      noti = NotificationService.NOTI_NONE;
    }

    final Event delayedNotificationEvent =
        eventTrackingService.newEvent("annc.schInv.notify", msg.getReference(), true, noti);
    //		eventTrackingService.post(event);

    NotificationEdit notify = notificationService.addTransientNotification();

    super.notify(notify, delayedNotificationEvent);

    // since we build the notification by accessing the
    // message within the super class, can't remove the
    // SecurityAdvisor until this point
    // done with access, need to remove from stack
    disableSecurityAdvisor();
  }
  /** @inheritDoc */
  public void notify(Notification notification, Event event) {
    // get the message
    Reference ref = EntityManager.newReference(event.getResource());
    AnnouncementMessageEdit msg = (AnnouncementMessageEdit) ref.getEntity();
    AnnouncementMessageHeader hdr = (AnnouncementMessageHeader) msg.getAnnouncementHeader();

    // do not do notification for hidden (draft) messages
    if (hdr.getDraft()) return;

    // Put here since if release date after now, do not notify
    // since scheduled notification has been set.
    Time now = TimeService.newTime();

    if (now.after(hdr.getDate())) {
      super.notify(notification, event);
    }
  }