Пример #1
0
  private void doGo(ActionRequest request, ActionResponse response, StringBuffer message)
      throws ReadOnlyException, ValidatorException, IOException, PortletModeException {
    boolean save = true;
    // PortletPreferences prefs = request.getPreferences();
    String url = request.getParameter("url");
    if (!url.startsWith("http://")) {
      save = false;
      message.append("URLs must start with 'http://'<br/>");
      response.setRenderParameter("message", message.toString());
      response.setPortletMode(PortletMode.VIEW);
    }
    if (save) {
      request.getPortletSession().removeAttribute("highlights");
      // response.setRenderParameter("url", url.toLowerCase());
      // request.getPortletSession().setAttribute("current_url", url.toLowerCase());
      request.getPortletSession().setAttribute("current_url", url);
      this.sendEvent("loadedurl", url, response);
      response.setPortletMode(PortletMode.VIEW);
      request.getPortletSession().removeAttribute("highlights");
      // gestion de la consultation
      if (request.getPortletSession().getAttribute("consult_url")
          != null) // si une consultation a déjà commencé
      {
        if (!url.equalsIgnoreCase(
            (String)
                request
                    .getPortletSession()
                    .getAttribute("consult_url"))) // si on change de page à consulter
        {
          if (request.getPortletSession().getAttribute("user") != null) {
            // creates consultation
            // URI uri =
            // CREATOR_URI.createAndGetURI((String)request.getPortletSession().getAttribute("consult_url"));
            // CREATOR_CONSULTATION.createsConsultation((UserAccount)request.getPortletSession().getAttribute("user"), (Date)request.getPortletSession().getAttribute("start_consult") , new Date(), uri, "[PortletWebBrowse]");
            URI uri =
                daoResource.createAndGetURI(
                    (String) request.getPortletSession().getAttribute("consult_url"));
            daoConsultation.createsConsultation(
                (UserAccount) request.getPortletSession().getAttribute("user"),
                (Date) request.getPortletSession().getAttribute("start_consult"),
                new Date(),
                uri,
                "[PortletWebBrowse]");
          }
          request.getPortletSession().setAttribute("consult_url", url);
          request.getPortletSession().setAttribute("start_consult", new Date());
        }

      } else // si c'est la première consultation
      {
        request.getPortletSession().setAttribute("consult_url", url);
        request.getPortletSession().setAttribute("start_consult", new Date());
      }
    }
  }
Пример #2
0
  public void processEvent(EventRequest request, EventResponse response) {
    Event event = request.getEvent();
    String event_name = event.getName();
    // System.out.println("[PortletWebBrowser.processEvent] event : " + event.getName());
    if (event_name.equals("tohighlight")) {
      Object _highlight_event = event.getValue();
      // Récupérer la collection de highlights
      if (_highlight_event instanceof HighlightSelectionHTML) {
        ArrayList<HighlightSelectionHTML> _hightlights =
            (ArrayList<HighlightSelectionHTML>)
                request.getPortletSession().getAttribute("highlights");
        if (_hightlights == null) _hightlights = new ArrayList<HighlightSelectionHTML>();
        _hightlights.add((HighlightSelectionHTML) _highlight_event);
        request.getPortletSession().setAttribute("highlights", _hightlights);
      }
    }
    if (event_name.equals("todelete")) {
      // System.out.println("[PortletWebBrowser.processEvent] event to delete");
      if (event.getValue() instanceof HighlightSelectionHTML)
        doDelete(request, (HighlightSelectionHTML) event.getValue());
    }
    if (event_name.equals("toLoadUrl")) {
      if (event.getValue() instanceof String) {
        String url = (String) event.getValue();
        if (url.startsWith("http://")) {
          request.getPortletSession().setAttribute("current_url", url);
          // response.setRenderParameter("url", url.toLowerCase());
          request.getPortletSession().removeAttribute("highlights");
          request.removeAttribute("highlights");
          // gestion de la consultation
          if (request.getPortletSession().getAttribute("consult_url")
              != null) // si une consultation a déjà commencé
          {
            if (!url.equalsIgnoreCase(
                (String)
                    request
                        .getPortletSession()
                        .getAttribute("consult_url"))) // si on change de page à consulter
            {
              if (request.getPortletSession().getAttribute("user") != null) {
                // creates consultation
                // URI uri =
                // CREATOR_URI.createAndGetURI((String)request.getPortletSession().getAttribute("consult_url"));
                // CREATOR_CONSULTATION.createsConsultation((UserAccount)request.getPortletSession().getAttribute("user"), (Date)request.getPortletSession().getAttribute("start_consult") , new Date(), uri, "[PortletWebBrowse]");
                URI uri =
                    daoResource.createAndGetURI(
                        (String) request.getPortletSession().getAttribute("consult_url"));
                daoConsultation.createsConsultation(
                    (UserAccount) request.getPortletSession().getAttribute("user"),
                    (Date) request.getPortletSession().getAttribute("start_consult"),
                    new Date(),
                    uri,
                    "[PortletWebBrowse]");
              }
              request.getPortletSession().setAttribute("consult_url", url);
              request.getPortletSession().setAttribute("start_consult", new Date());
            }

          } else // si c'est la première consultation
          {
            request.getPortletSession().setAttribute("consult_url", url);
            request.getPortletSession().setAttribute("start_consult", new Date());
          }
        }
      }
    }
    if (event_name.equalsIgnoreCase("UserLog")) {
      if (event.getValue() instanceof UserAccount) {
        UserAccount _current_user = (UserAccount) event.getValue();
        if (_current_user.getId() != null)
          request.getPortletSession().setAttribute("user", _current_user);
      }
    }
    if (event_name.equalsIgnoreCase("UserUnLog")) {
      request.getPortletSession().removeAttribute("user");
    }
  }