public static String getRSSUrl(MainSessionController mainSessionController, String spaceId) {
   String userId = mainSessionController.getUserId();
   UserFull user = adminController.getUserFull(userId);
   StringBuilder builder = new StringBuilder();
   builder.append("/rsslastpublications/").append(spaceId);
   builder.append("?userId=").append(userId).append("&login="******"UTF-8"));
     builder.append("&password="******"UTF-8"));
     builder.append("&spaceId=");
     builder.append(URLEncoder.encode(spaceId, "UTF-8"));
   } catch (UnsupportedEncodingException e) {
     builder.append(user.getLogin());
     builder.append("&password="******"&spaceId=");
     builder.append(spaceId);
   }
   return builder.toString();
 }
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    SilverTrace.info("agenda", "SubscribeAgenda.doPost", "root.MSG_GEN_ENTER_METHOD");
    String userId = getUserId(req);
    String login = getLogin(req);
    String password = getPassword(req);
    FileInputStream fs = null;
    try {
      SilverTrace.info(
          "agenda", "SubscribeAgenda.doPost", "root.MSG_GEN_PARAM_VALUE", "userId = " + userId);

      // Check login/pwd must be a identified user
      AdminController adminController = new AdminController(null);
      UserFull user = adminController.getUserFull(userId);
      if (user != null && login.equals(user.getLogin()) && password.equals(user.getPassword())) {
        // Get calendar user
        ExportIcalManager exportManager = new ExportIcalManager(userId);
        String filePath = exportManager.exportIcalAgendaForSynchro();
        res.setContentType("text/calendar");
        res.setHeader("Content-Disposition", "attachment;filename=calendar" + userId + ".ics");
        OutputStream os = res.getOutputStream();
        fs = new FileInputStream(filePath);
        // Stream data back to the client
        int i;
        while (((i = fs.read()) != -1)) {
          os.write(i);
        }
        os.flush();
        os.close();
        res.getOutputStream();
      } else {
        objectNotFound(req, res);
      }
    } catch (Exception e) {
      objectNotFound(req, res);
    } finally {
      IOUtils.closeQuietly(fs);
    }
    SilverTrace.info("agenda", "SubscribeAgenda.doPost", "root.MSG_GEN_EXIT_METHOD");
  }
  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    SilverTrace.info("peasUtil", "RssServlet.doPost", "root.MSG_GEN_ENTER_METHOD");
    String instanceId = getObjectId(req);
    String userId = getUserId(req);
    String login = getLogin(req);
    String password = getPassword(req);
    // rechercher si le composant a bien le flux RSS autorisé
    if (isComponentRss(instanceId)) {
      try {
        SilverTrace.info(
            "peasUtil",
            "RssServlet.doPost",
            "root.MSG_GEN_PARAM_VALUE",
            "InstanceId = " + instanceId);

        // Vérification que le user a droit d'accès au composant
        AdminController adminController = new AdminController(null);
        UserFull user = adminController.getUserFull(userId);
        if (user != null
            && login.equals(user.getLogin())
            && password.equals(user.getPassword())
            && isComponentAvailable(adminController, instanceId, userId)) {

          String serverURL = getServerURL(adminController, user.getDomainId());
          ChannelIF channel = new Channel();

          // récupération de la liste des N éléments à remonter dans le flux
          int nbReturnedElements = getNbReturnedElements();
          Collection<T> listElements = getListElements(instanceId, nbReturnedElements);

          // création d'une liste de ItemIF en fonction de la liste des éléments

          for (T element : listElements) {
            String title = getElementTitle(element, userId);
            URL link = new URL(serverURL + getElementLink(element, userId));
            String description = getElementDescription(element, userId);
            Date dateElement = getElementDate(element);
            String creatorId = getElementCreatorId(element);
            ItemIF item = new Item();
            item.setTitle(title);
            item.setLink(link);
            item.setDescription(description);
            item.setDate(dateElement);

            if (StringUtil.isDefined(creatorId)) {
              UserDetail creator = adminController.getUserDetail(creatorId);
              if (creator != null) {
                item.setCreator(creator.getDisplayedName());
              }
            } else if (StringUtil.isDefined(getExternalCreatorId(element))) {
              item.setCreator(getExternalCreatorId(element));
            }
            channel.addItem(item);
          }

          // construction de l'objet Channel
          channel.setTitle(getChannelTitle(instanceId));
          URL componentUrl =
              new URL(
                  serverURL
                      + URLManager.getApplicationURL()
                      + URLManager.getURL("useless", instanceId));
          channel.setLocation(componentUrl);

          // exportation du channel
          res.setContentType("application/rss+xml");
          res.setHeader("Content-Disposition", "inline; filename=feeds.rss");
          Writer writer = res.getWriter();
          RSS_2_0_Exporter rssExporter = new RSS_2_0_Exporter(writer, "UTF-8");
          rssExporter.write(channel);
        } else {
          objectNotFound(req, res);
        }
      } catch (Exception e) {
        objectNotFound(req, res);
      }
    }
  }