public void removeAttendeeToEntryFromExternal(
      String componentId, String externalId, String userId) {
    SilverTrace.info(
        "calendar",
        "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId, String userId)",
        "root.MSG_GEN_ENTER_METHOD",
        "componentId=" + componentId + ", externalId=" + externalId + ", userId = " + userId);
    try {
      Attendee attendee = new Attendee();
      attendee.setUserId(userId);

      Collection<ToDoHeader> headers =
          getCalendarBm().getExternalTodos("useless", componentId, externalId);
      for (ToDoHeader header : headers) {
        if (header != null) {
          getCalendarBm().removeToDoAttendee(header.getId(), attendee);
        }
      }
    } catch (Exception e) {
      SilverTrace.error(
          "calendar",
          "TodoBackboneAcess.removeAttendeeToEntryFromExternal(String componentId, String externalId)",
          "calendar.MSG_CANT_REMOVE",
          "return null",
          e);
    }
  }
  /**
   * Retourne une Collection de UserDetail des utilisateurs selectionnés via le userPanel
   *
   * @param
   * @return
   * @throws TodoException
   * @see
   */
  public Collection getUserSelected() throws TodoException {
    Selection sel = getSelection();
    ArrayList attendees = new ArrayList();
    Collection oldAttendees = null;

    ToDoHeader todo = getCurrentToDoHeader();
    if (todo.getId() != null) {
      oldAttendees = getToDoAttendees(todo.getId());
    }

    String[] selectedUsers = sel.getSelectedElements();
    if (selectedUsers != null) {
      for (int i = 0; i < selectedUsers.length; i++) {
        Attendee newAttendee = null;
        if (oldAttendees != null) {
          Iterator attI = oldAttendees.iterator();
          while (attI.hasNext()) {
            Attendee attendee = (Attendee) attI.next();
            if (attendee.getUserId().equals(selectedUsers[i])) {
              newAttendee = attendee;
            }
          } // fin while
        } // fin if

        if (newAttendee == null) {
          newAttendee = new Attendee(selectedUsers[i]);
        }
        attendees.add(newAttendee);
      } // fin for
    } // fin if

    return attendees;
  }
  /**
   * Method declaration
   *
   * @param id
   * @param title
   * @param text
   * @see
   */
  protected void notifyAttendees(String id, String title, String text) {
    try {
      Collection attendees = getToDoAttendees(id);
      NotificationMetaData notifMetaData =
          new NotificationMetaData(NotificationParameters.NORMAL, title, text);
      notifMetaData.setSender(getUserId());
      notifMetaData.setSource(getString("todo"));
      for (Iterator i = attendees.iterator(); i.hasNext(); ) {
        Attendee attendee = (Attendee) i.next();

        notifMetaData.addUserRecipient(attendee.getUserId());
      }
      getNotificationSender().notifyUser(notifMetaData);
    } catch (Exception e) {
      SilverTrace.error(
          "todo", "ToDoSessionController.notifyAttendees()", "todo.MSG_CANT_SEND_MAIL");
    }
  }
  public String addEntry(
      TodoDetail todo, boolean notifyAttendees, String txtTitle, String txtMessage) {
    SilverTrace.info("calendar", "TodoBackboneAcess.addEntry()", "root.MSG_GEN_ENTER_METHOD");
    NotificationSender notifSender = new NotificationSender(todo.getComponentId());
    try {
      ToDoHeader header = todoDetailToHeader(todo);
      SilverTrace.info(
          "calendar", "TodoBackboneAcess.addEntry()", "root.MSG_GEN_ENTER_METHOD", "apres header");
      String id = getCalendarBm().addToDo(header);
      SilverTrace.info(
          "calendar", "TodoBackboneAcess.addEntry()", "root.MSG_GEN_ENTER_METHOD", "id=" + id);

      if (todo.getAttendees() != null) {
        Collection<UserRecipient> selectedUsers = new ArrayList<UserRecipient>();
        for (Attendee attendee : todo.getAttendees()) {
          getCalendarBm().addToDoAttendee(id, attendee);
          if (notifyAttendees && (!todo.getDelegatorId().equals(attendee.getUserId()))) {
            selectedUsers.add(new UserRecipient(attendee.getUserId()));
          }
        }
        if (!selectedUsers.isEmpty()) {
          NotificationMetaData notifMetaData =
              new NotificationMetaData(NotificationParameters.NORMAL, txtTitle, txtMessage);
          notifMetaData.setSender(todo.getDelegatorId());
          notifMetaData.setUserRecipients(selectedUsers);
          notifSender.notifyUser(notifMetaData);
        }
      }
      return id;
    } catch (Exception e) {
      SilverTrace.error(
          "calendar",
          "TodoBackboneAcess.addEntry()",
          "calendar.MSG_ADD_ENTRY_FAILED",
          "value return id= null",
          e);
      return null;
    }
  }
  /**
   * Paramètre le userPannel => tous les users, sélection des users participants
   *
   * @param
   * @return
   * @throws
   * @see
   */
  public String initSelectionPeas() {
    String m_context =
        GeneralPropertiesManager.getGeneralResourceLocator().getString("ApplicationURL");
    PairObject hostComponentName = new PairObject(getString("todo"), m_context + "/Rtodo/jsp/Main");
    PairObject[] hostPath = new PairObject[1];
    hostPath[0] = new PairObject(getString("editionListeDiffusion"), m_context + "/Rtodo/jsp/Main");
    String hostUrl = m_context + "/Rtodo/jsp/saveMembers";
    String cancelUrl = m_context + "/Rtodo/jsp/saveMembers";

    Selection sel = getSelection();
    sel.resetAll();
    sel.setHostSpaceName("");
    sel.setHostPath(hostPath);
    sel.setHostComponentName(hostComponentName);

    sel.setGoBackURL(hostUrl);
    sel.setCancelURL(cancelUrl);

    // set les users deja selectionnés
    Collection members = getCurrentAttendees();
    if (members != null) {
      String[] usersSelected;
      usersSelected = new String[members.size()];
      Iterator i = members.iterator();
      int j = 0;
      while (i.hasNext()) {
        Attendee attendee = (Attendee) i.next();
        usersSelected[j] = attendee.getUserId();
        j++;
      }
      sel.setSelectedElements(usersSelected);
    }

    // Contraintes
    sel.setPopupMode(true);
    sel.setSetSelectable(false);
    sel.setFirstPage(Selection.FIRST_PAGE_CART);
    return Selection.getSelectionURL(Selection.TYPE_USERS_GROUPS);
  }
 public void updateEntry(TodoDetail todo) {
   SilverTrace.info(
       "calendar", "TodoBackboneAcess.updateEntry(TodoDetail todo)", "root.MSG_GEN_ENTER_METHOD");
   try {
     ToDoHeader header = todoDetailToHeader(todo);
     getCalendarBm().updateToDo(header);
     if (todo.getAttendees() != null) {
       String[] userIds = new String[todo.getAttendees().size()];
       int posit = 0;
       for (Attendee attendee : todo.getAttendees()) {
         userIds[posit++] = attendee.getUserId();
       }
       getCalendarBm().setToDoAttendees(header.getId(), userIds);
     }
   } catch (Exception e) {
     SilverTrace.error(
         "calendar",
         "TodoBackboneAcess.addEntry(TodoDetail todo)",
         "calendar.MSG_UPDATE_ENTRY_FAILED",
         "id=" + todo.getId(),
         e);
   }
 }