コード例 #1
0
  // Process action is called for action URLs / form posts, etc
  // Process action is called once for each click - doView may be called many times
  // Hence an obsession in process action with putting things in session to
  // Send to the render process.
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {

    // System.out.println("==== processAction called ====");

    PortletSession pSession = request.getPortletSession(true);

    // Our first challenge is to figure out which action we want to take
    // The view selects the "next action" either as a URL parameter
    // or as a hidden field in the POST data - we check both

    String doCancel = request.getParameter("sakai.cancel");
    String doUpdate = request.getParameter("sakai.update");

    // Our next challenge is to pick which action the previous view
    // has told us to do.  Note that the view may place several actions
    // on the screen and the user may have an option to pick between
    // them.  Make sure we handle the "no action" fall-through.

    pSession.removeAttribute("error.message");

    if (doCancel != null) {
      response.setPortletMode(PortletMode.VIEW);
    } else if (doUpdate != null) {
      processActionEdit(request, response);
    } else {
      // System.out.println("Unknown action");
      response.setPortletMode(PortletMode.VIEW);
    }

    // System.out.println("==== End of ProcessAction  ====");
  }
コード例 #2
0
  /*
   * Process the "finished" action for the edit page. Set the "url" to the value specified in the
   * edit page.
   */
  private void processEditFinishedAction(ActionRequest request, ActionResponse response)
      throws PortletException {
    String nbPublis = request.getParameter(TEXTBOX_NB_ITEMS);
    String maxAge = request.getParameter(TEXTBOX_MAX_AGE);
    String displayDescription = request.getParameter("displayDescription");

    // Check if it is a number
    try {
      int nb = Integer.parseInt(nbPublis);
      Integer.parseInt(maxAge);
      if (nb < 0 || nb > 30) {
        throw new NumberFormatException();
      }
      // store preference
      PortletPreferences pref = request.getPreferences();
      try {
        pref.setValue("nbPublis", nbPublis);
        pref.setValue("maxAge", maxAge);
        pref.setValue("displayDescription", displayDescription);
        pref.store();
      } catch (ValidatorException ve) {
        log("could not set nbPublis", ve);
        throw new PortletException("IFramePortlet.processEditFinishedAction", ve);
      } catch (IOException ioe) {
        log("could not set nbPublis", ioe);
        throw new PortletException("IFramePortlet.prcoessEditFinishedAction", ioe);
      }
      response.setPortletMode(PortletMode.VIEW);

    } catch (NumberFormatException e) {
      response.setRenderParameter(ERROR_BAD_VALUE, "true");
      response.setPortletMode(PortletMode.EDIT);
    }
  }
コード例 #3
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());
      }
    }
  }
コード例 #4
0
  @RequestMapping(params = "action=save")
  public void saveConfiguration(
      ActionRequest request,
      ActionResponse response,
      @ModelAttribute("form") SearchPortletConfigurationForm form)
      throws PortletModeException {

    PortletPreferences prefs = request.getPreferences();

    try {

      prefs.setValue("gsaEnabled", String.valueOf(form.isGsaEnabled()));
      prefs.setValue("gsaBaseUrl", form.getGsaBaseUrl());
      prefs.setValue("gsaSite", form.getGsaSite());
      prefs.setValue("directoryEnabled", String.valueOf(form.isDirectoryEnabled()));
      prefs.setValue("portletRegistryEnabled", String.valueOf(form.isPortletRegistryEnabled()));
      prefs.store();

    } catch (ValidatorException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ReadOnlyException e) {
      e.printStackTrace();
    }

    response.setPortletMode(PortletMode.VIEW);
  }
  /**
   * Resets/restores the values in the portletPreferences.xhtml Facelet composition with portlet
   * preference default values.
   */
  public void reset() {

    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
    PortletPreferences portletPreferences = portletRequest.getPreferences();

    try {
      Enumeration<String> preferenceNames = portletPreferences.getNames();

      while (preferenceNames.hasMoreElements()) {
        String preferenceName = preferenceNames.nextElement();
        portletPreferences.reset(preferenceName);
      }

      portletPreferences.store();

      // Switch the portlet mode back to VIEW.
      ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
      actionResponse.setPortletMode(PortletMode.VIEW);
      actionResponse.setWindowState(WindowState.NORMAL);

      FacesContextHelperUtil.addGlobalSuccessInfoMessage();
    } catch (Exception e) {
      FacesContextHelperUtil.addGlobalUnexpectedErrorMessage();
    }
  }
  /**
   * Saves the values in the portletPreferences.xhtml Facelet composition as portlet preferences.
   */
  public void submit() {

    // The JSR 329 specification defines an EL variable named mutablePortletPreferencesValues that
    // is being used in
    // the portletPreferences.xhtml Facelet composition. This object is of type Map<String,
    // Preference> and is
    // designed to be a model managed-bean (in a sense) that contain preference values. However the
    // only way to
    // access this from a Java class is to evaluate an EL expression (effectively self-injecting)
    // the map into
    // this backing bean.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    String elExpression = "mutablePortletPreferencesValues";
    ELResolver elResolver = facesContext.getApplication().getELResolver();
    @SuppressWarnings("unchecked")
    Map<String, Preference> mutablePreferenceMap =
        (Map<String, Preference>)
            elResolver.getValue(facesContext.getELContext(), null, elExpression);

    // Get a list of portlet preference names.
    PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
    PortletPreferences portletPreferences = portletRequest.getPreferences();
    Enumeration<String> preferenceNames = portletPreferences.getNames();

    try {

      // For each portlet preference name:
      while (preferenceNames.hasMoreElements()) {

        // Get the value specified by the user.
        String preferenceName = preferenceNames.nextElement();
        String preferenceValue = mutablePreferenceMap.get(preferenceName).getValue();

        // Prepare to save the value.
        if (!portletPreferences.isReadOnly(preferenceName)) {
          portletPreferences.setValue(preferenceName, preferenceValue);
        }
      }

      // Save the preference values.
      portletPreferences.store();

      // Switch the portlet mode back to VIEW.
      ActionResponse actionResponse = (ActionResponse) externalContext.getResponse();
      actionResponse.setPortletMode(PortletMode.VIEW);
      actionResponse.setWindowState(WindowState.NORMAL);

      // Report a successful message back to the user as feedback.
      FacesContextHelperUtil.addGlobalSuccessInfoMessage();
    } catch (Exception e) {
      FacesContextHelperUtil.addGlobalUnexpectedErrorMessage();
    }
  }
コード例 #7
0
  @RequestMapping("EDIT")
  public void savePreferences(
      ActionRequest request,
      ActionResponse response,
      @RequestParam("topicsToUpdate") Integer topicsToUpdate)
      throws PortletException {

    List<TopicSubscription> newSubscription = new ArrayList<TopicSubscription>();

    for (int i = 0; i < topicsToUpdate; i++) {
      Long topicId = Long.valueOf(request.getParameter("topicId_" + i));

      // Will be numeric for existing, persisted TopicSubscription
      // instances;  blank (due to null id field) otherwise
      String topicSubId = request.getParameter("topicSubId_" + i).trim();

      Boolean subscribed = Boolean.valueOf(request.getParameter("subscribed_" + i));
      Topic topic = announcementService.getTopic(topicId);

      // Make sure that any pushed_forced topics weren't sneakingly removed (by tweaking the URL,
      // for example)
      if (topic.getSubscriptionMethod() == Topic.PUSHED_FORCED) {
        subscribed = new Boolean(true);
      }

      TopicSubscription ts = new TopicSubscription(request.getRemoteUser(), topic, subscribed);
      if (topicSubId.length() > 0) {
        // This TopicSubscription represents an existing, persisted entity
        try {
          ts.setId(Long.valueOf(topicSubId));
        } catch (NumberFormatException nfe) {
          logger.debug(nfe.getMessage(), nfe);
        }
      }

      newSubscription.add(ts);
    }

    if (newSubscription.size() > 0) {
      try {
        announcementService.addOrSaveTopicSubscription(newSubscription);
      } catch (Exception e) {
        logger.error(
            "ERROR saving TopicSubscriptions for user "
                + request.getRemoteUser()
                + ". Message: "
                + e.getMessage());
      }
    }

    response.setPortletMode(PortletMode.VIEW);
    response.setRenderParameter("action", "displayAnnouncements");
  }
コード例 #8
0
  public void processActionEdit(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
    // TODO: Check Role

    // Stay in EDIT mode unless we are successful
    response.setPortletMode(PortletMode.EDIT);

    Placement placement = ToolManager.getCurrentPlacement();
    // get the site toolConfiguration, if this is part of a site.
    ToolConfiguration toolConfig = SiteService.findTool(placement.getId());
    String id = request.getParameter(LTIService.LTI_ID);
    String toolId = request.getParameter(LTIService.LTI_TOOL_ID);
    Properties reqProps = new Properties();
    Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
      String name = (String) names.nextElement();
      reqProps.setProperty(name, request.getParameter(name));
    }
    Object retval = m_ltiService.updateContent(Long.parseLong(id), reqProps);
    placement.save();

    response.setPortletMode(PortletMode.VIEW);
  }
  @RequestMapping(params = "action=updateConfiguration")
  public void saveConfiguration(
      ActionRequest request,
      ActionResponse response,
      @ModelAttribute("config") AnnouncementConfiguration config,
      @RequestParam(value = "save", required = false) String save)
      throws PortletModeException {

    if (StringUtils.isNotBlank(save)) {
      log.debug("Saving announcement configuration: {" + config.toString() + "}");
      configService.saveConfiguration(request, config);
    }

    response.setPortletMode(PortletMode.VIEW);
  }
コード例 #10
0
  public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws PortletException, IOException {
    // grab parameters - they will be cleared in processing of edit response
    String webContentParameter =
        actionRequest.getParameter(WebContentRewriter.ACTION_PARAMETER_URL);
    String ssoPrincipalName = actionRequest.getParameter(SSO_EDIT_FIELD_PRINCIPAL);
    String ssoPrincipalPassword = actionRequest.getParameter(SSO_EDIT_FIELD_CREDENTIAL);

    // save the prefs
    super.processAction(actionRequest, actionResponse);

    // process credentials
    if (webContentParameter == null || actionRequest.getPortletMode() == PortletMode.EDIT) {
      // processPreferencesAction(request, actionResponse);
      // get the POST params -- requires HTML post params named above
      String siteUrl = actionRequest.getPreferences().getValue("SRC", "");
      String localUser = actionRequest.getUserPrincipal().getName();
      SSOSite site = sso.getSiteByUrl(siteUrl);
      try {
        if (!SecurityHelper.isEmpty(siteUrl)
            && !SecurityHelper.isEmpty(ssoPrincipalName)
            && !SecurityHelper.isEmpty(ssoPrincipalPassword)) {
          if (site == null) {
            site = sso.newSite(siteUrl, siteUrl);
            sso.addSite(site);
            SSOPortletUtil.updateUser(
                sso, actionRequest, site, ssoPrincipalName, ssoPrincipalPassword);
          } else {
            SSOPortletUtil.updateUser(
                sso, actionRequest, site, ssoPrincipalName, ssoPrincipalPassword);
          }
        }
      } catch (SSOException e) {
        String errorMessage =
            "Failed to add remote user for the portal principal, "
                + actionRequest.getUserPrincipal().getName()
                + ".";
        if (e.getCause() != null) {
          errorMessage += " (" + e.getCause() + ")";
        }
        StatusMessage statusMessage = new StatusMessage(errorMessage, StatusMessage.ERROR);
        PortletMessaging.publish(actionRequest, "SSOWebContent", "status", statusMessage);
        actionResponse.setPortletMode(PortletMode.EDIT); // stay on edit
      }
    }
  }
  /* ACTION call from Portlet's <form> of EDIT JSP */
  public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException {

    String saveSettingsGoogleMapsUtility =
        actionRequest.getParameter("saveSettingsGoogleMapsUtility");
    /*You can add other getParameter of EDIT JSP*/

    if (saveSettingsGoogleMapsUtility != null) {
      PortletPreferences prefs = actionRequest.getPreferences();

      if (actionRequest.getParameter("inTypeUtility") != null)
        prefs.setValue("typeUtility", actionRequest.getParameter("inTypeUtility"));

      if (actionRequest.getParameter("inStreetView") != null)
        prefs.setValue("chkStreetView", actionRequest.getParameter("inStreetView"));
      if (actionRequest.getParameter("inZoom") != null)
        prefs.setValue("chkZoom", actionRequest.getParameter("inZoom"));
      if (actionRequest.getParameter("inDraggable") != null)
        prefs.setValue("chkDraggable", actionRequest.getParameter("inDraggable"));
      if (actionRequest.getParameter("inPanControl") != null)
        prefs.setValue("chkPanControl", actionRequest.getParameter("inPanControl"));
      if (actionRequest.getParameter("inRotateControl") != null)
        prefs.setValue("chkRotateControl", actionRequest.getParameter("inRotateControl"));
      if (actionRequest.getParameter("inScaleControl") != null)
        prefs.setValue("chkScaleControl", actionRequest.getParameter("inScaleControl"));

      if (actionRequest.getParameter("inTypeMap") != null)
        prefs.setValue("typeMap", actionRequest.getParameter("inTypeMap"));

      if (actionRequest.getParameter("inAddress") != null)
        prefs.setValue("address", actionRequest.getParameter("inAddress"));
      if (actionRequest.getParameter("inDescriptionMarker") != null)
        prefs.setValue("descriptionMarker", actionRequest.getParameter("inDescriptionMarker"));
      if (actionRequest.getParameter("inTypeIcon") != null)
        prefs.setValue("typeIcon", actionRequest.getParameter("inTypeIcon"));

      if (actionRequest.getParameter("inFromAddress") != null)
        prefs.setValue("fromAddress", actionRequest.getParameter("inFromAddress"));
      if (actionRequest.getParameter("inToAddress") != null)
        prefs.setValue("toAddress", actionRequest.getParameter("inToAddress"));

      prefs.store();
      actionResponse.setPortletMode(PortletMode.VIEW);
    }
  }
コード例 #12
0
 public void saveName(ActionRequest actionRequest, ActionResponse actionResponse)
     throws IOException, PortletException {
   _log.debug("saveName started");
   final String name =
       ParamUtil.get(actionRequest, MyHelloWorldMVCUtil.REQUEST_PARAM_NAME, StringPool.BLANK);
   final PortletPreferences portletPreferences = actionRequest.getPreferences();
   if (Validator.isBlank(name)) {
     _log.error("Name is blank. You must introduce valid value for name parameter.");
   } else {
     portletPreferences.setValue(MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME, name);
     _log.info(
         "saving new value ("
             + name
             + ") of "
             + MyHelloWorldMVCUtil.PORTLET_PREFERENCES_PARAM_NAME
             + " on portletPreferences");
     portletPreferences.store();
   }
   // Una vez que terminas la lógica de saveName forward a la vista
   actionResponse.setPortletMode(PortletMode.VIEW);
 }
コード例 #13
0
  @RequestMapping(
      value = {"EDIT"},
      params = {"action=updatePreferences"})
  public void updatePreferences(
      ActionRequest request,
      ActionResponse response,
      @RequestParam(value = "viewUserBox", required = false) String[] viewUserBox,
      @RequestParam(value = "viewManagerBox", required = false) String[] viewManagerBox,
      @RequestParam(value = "userViewMode", required = false) String userViewMode,
      @RequestParam(value = "managerViewMode", required = false) String managerViewMode,
      @RequestParam(value = "viewMaxTickets", required = false) String viewMaxTickets)
      throws Exception {

    final PortletPreferences prefs = request.getPreferences();

    if (userViewMode.equalsIgnoreCase("enable")) {
      if (viewUserBox == null) {
        String[] defUserValues = {"owner"};
        prefs.setValues(WebController.PREF_TAB_USER, defUserValues);
      } else {
        prefs.setValues(WebController.PREF_TAB_USER, viewUserBox);
      }
      prefs.store();
    }
    if (managerViewMode.equalsIgnoreCase("enable")) {
      if (viewManagerBox == null) {
        String[] defManagerValues = {"managed"};
        prefs.setValues(WebController.PREF_TAB_MANAGER, defManagerValues);
      } else {
        prefs.setValues(WebController.PREF_TAB_MANAGER, viewManagerBox);
      }
      prefs.store();
    }
    if ((this.testFieldValue(ALL_NUMBER_REGEX, viewMaxTickets) == SUCCESS)
        && (!prefs.isReadOnly(WebController.PREF_MAX_TICKETS))) {
      prefs.setValue(WebController.PREF_MAX_TICKETS, viewMaxTickets);
      prefs.store();
    }
    response.setPortletMode(PortletMode.VIEW);
  }
コード例 #14
0
 public void processAction(ActionRequest request, ActionResponse response)
     throws PortletException, PortletSecurityException, IOException {
   String op = request.getParameter("op");
   StringBuffer message = new StringBuffer(1024);
   if ((op != null) && (op.trim().length() > 0)) {
     // Mise à jour de l'url dans la barre de navigation de la portlet en View
     if (op.equalsIgnoreCase("go")) {
       doGo(request, response, message);
       return;
     }
     // il y a eu une action de sélection pour annotation
     else if (op.equalsIgnoreCase("selection")) {
       doSelection(request, response);
       return;
     }
     // mise à jour des données par interface Edit
     else if (op.equalsIgnoreCase("update")) {
       doUpdate(request, response, message);
       return;
     } else if (op.equalsIgnoreCase("cancel")) {
       doCancel(response);
       return;
     } else if (op.equalsIgnoreCase("Page")) {
       doPage(request, response);
       return;
     } else {
       System.out.println("[BrowserPortlet.processAction 2]" + op);
       message.append("Operation not found");
     }
   } else {
     System.out.println("[BrowserPortlet.processAction 3]" + op);
     message.append("Operation is null");
   }
   System.out.println("[BrowserPortlet.processAction 4]" + op);
   response.setRenderParameter("message", message.toString());
   response.setPortletMode(PortletMode.VIEW);
 }
コード例 #15
0
 private void doUpdate(ActionRequest request, ActionResponse response, StringBuffer message)
     throws ReadOnlyException, ValidatorException, IOException, PortletModeException {
   String url = request.getParameter("default-url");
   // System.out.println("[BrowserPortlet.doUpdate] url : " + url);
   String height = request.getParameter("height");
   String width = request.getParameter("width");
   String noMessage = request.getParameter("nomessage");
   boolean px = false;
   boolean save = true;
   // boolean save = true;
   if ((url != null) && (height != null) && (width != null) && (noMessage != null)) {
     if (!url.startsWith("http://")) {
       save = false;
       message.append("URLs must start with 'http://'<br/>");
     }
     try {
       if (height.endsWith("px")) {
         height = height.substring(0, height.length() - 2);
       }
       Integer.parseInt(height);
     } catch (NumberFormatException nfe) {
       // Bad height value
       save = false;
       message.append("Height must be an integer<br/>");
     }
     try {
       if (width.endsWith("px")) {
         px = true;
         width = width.substring(0, width.length() - 2);
       } else if (width.endsWith("%")) {
         width = width.substring(0, width.length() - 1);
       }
       Integer.parseInt(width);
     } catch (NumberFormatException nfe) {
       // Bad height value
       save = false;
       message.append("Width must be an integer<br/>");
     }
     if (save) {
       if (request.getParameter("hide") != null
           && request.getParameter("hide").equalsIgnoreCase("hide")) {
         hide_url = true;
         request.removeAttribute("hide");
       } else hide_url = false;
       if (request.getParameter("hide_open") != null
           && request.getParameter("hide_open").equalsIgnoreCase("hide")) {
         hide_new_windows = true;
         request.removeAttribute("hide");
       } else hide_new_windows = false;
       // System.out.println("[BrowserPortlet.doUpdate] save");
       response.setRenderParameter("height", height + "px");
       response.setRenderParameter("width", px ? width + "px" : width + "%");
       // response.setRenderParameter("url", url);
       request.getPortletSession().setAttribute("current_url", url);
       // this.sendEvent("url", url, response);
       this.sendEvent("loadedurl", url, response);
       response.setRenderParameter("message", noMessage);
       defaultURL = url;
       sendEvent("default_url", url, response);
       request
           .getPortletSession()
           .setAttribute("default_url", url, request.getPortletSession().APPLICATION_SCOPE);
       defaultHeight = height + "px";
       defaultWidth = px ? width + "px" : width + "%";
       defaultMessage = noMessage;
       applicationProps.setProperty("defaultURL", defaultURL);
       applicationProps.setProperty("defaultHeight", defaultHeight);
       applicationProps.setProperty("defaultWidth", defaultWidth);
       applicationProps.setProperty("defaultMessage", defaultMessage);
       if (hide_url) applicationProps.setProperty("hide_url", "true");
       else applicationProps.setProperty("hide_url", "false");
       if (hide_new_windows) applicationProps.setProperty("hide_new_windows", "true");
       else applicationProps.setProperty("hide_new_windows", "false");
       PropertiesUtils.store(
           applicationProps,
           getPortletContext().getRealPath(saved_properties),
           "[PortletWebBrowser.doUpdate]");
       response.setPortletMode(PortletMode.VIEW);
       return;
     }
     response.setRenderParameter("message", message.toString());
     response.setPortletMode(PortletMode.VIEW);
   }
 }
コード例 #16
0
 /*
  * Process the "cancel" action for the edit page.
  */
 private void processEditCancelAction(ActionRequest request, ActionResponse response)
     throws PortletException {
   response.setPortletMode(PortletMode.VIEW);
 }
コード例 #17
0
 private void doCancel(ActionResponse response) throws PortletModeException {
   response.setPortletMode(PortletMode.VIEW);
 }
コード例 #18
0
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, java.io.IOException {
    String action = request.getParameter("action");
    if ("send".equals(action)) {
      String toEmail = request.getParameter("toEmail");
      String cc = request.getParameter("cc");
      String bcc = request.getParameter("bcc");
      String subject = request.getParameter("subject");
      String content = request.getParameter("content");
      if (subject == null || subject.length() <= 0 || toEmail == null || toEmail.length() <= 0) {
        request.setAttribute("error", "Message's to and subject are required field.");
        response.setPortletMode(PortletMode.EDIT);
        response.setRenderParameter("type", "create");
        return;
      }
      try {
        PortletPreferences portletPreferences = request.getPreferences();
        String fullName = portletPreferences.getValue("fullName", null);
        String incomingType = portletPreferences.getValue("incomingType", null);
        String incoming = portletPreferences.getValue("incoming", null);
        String incomingPort = portletPreferences.getValue("incomingPort", null);
        String incomingSSL = portletPreferences.getValue("incomingSSL", null);
        String outgoing = portletPreferences.getValue("outgoing", null);
        String outgoingPort = portletPreferences.getValue("outgoingPort", null);
        String outgoingSSL = portletPreferences.getValue("outgoingSSL", null);
        String email = portletPreferences.getValue("email", null);
        String password = portletPreferences.getValue("password", null);

        EmailClient client =
            new EmailClient(
                fullName,
                email,
                password,
                incomingType,
                incoming,
                incomingPort,
                incomingSSL,
                outgoing,
                outgoingPort,
                outgoingPort);
        client.sendMessage(toEmail, cc, bcc, subject, content);
      } catch (Exception e) {
        request.setAttribute("error", e.getMessage());
      }
    } else if ("reply".equals(action)) {
      String page = request.getParameter("pageId");
      if (page == null) page = "1";
      int pageId = Integer.parseInt(page);
      String toEmail = request.getParameter("toEmail");
      String subject = request.getParameter("subject");
      String content = request.getParameter("content");
      request.setAttribute("toEmail", toEmail);
      request.setAttribute("subject", "Re: " + subject);
      request.setAttribute("content", content);
      request.setAttribute("pageId", pageId);
      response.setPortletMode(PortletMode.EDIT);
      response.setRenderParameter("type", "create");
    } else if ("config".equals(action)) {
      String fullName = request.getParameter("fullName");
      String incomingType = request.getParameter("incomingType");
      String incoming = request.getParameter("incoming");
      String incomingPort = request.getParameter("incomingPort");
      String incomingSSL = request.getParameter("incomingSSL");
      String outgoing = request.getParameter("outgoing");
      String outgoingPort = request.getParameter("outgoingPort");
      String outgoingSSL = request.getParameter("outgoingSSL");
      String email = request.getParameter("email");
      String password = request.getParameter("password");
      String number = request.getParameter("number");
      if (incoming == null
          || incoming.length() <= 0
          || outgoing == null
          || outgoing.length() <= 0
          || email == null
          || email.length() <= 0
          || password == null
          || password.length() <= 0) {
        request.setAttribute("error", "Please input all required fields.");
        request.setAttribute("mode", "config");
        return;
      }
      PortletPreferences portletPreferences = request.getPreferences();
      portletPreferences.setValue("fullName", fullName);
      portletPreferences.setValue("incomingType", incomingType);
      portletPreferences.setValue("incoming", incoming);
      portletPreferences.setValue("incomingPort", incomingPort);
      portletPreferences.setValue("incomingSSL", incomingSSL);
      portletPreferences.setValue("outgoing", outgoing);
      portletPreferences.setValue("outgoingPort", outgoingPort);
      portletPreferences.setValue("outgoingSSL", outgoingSSL);
      portletPreferences.setValue("email", email);
      portletPreferences.setValue("password", password);
      portletPreferences.setValue("number", number);
      portletPreferences.store();
      request.getPortletSession().removeAttribute("mails", PortletSession.PORTLET_SCOPE);
    } else if ("delete".equals(action)) {
      if (request.getParameter("parameter") != null) {
        int index = Integer.parseInt(request.getParameter("parameter"));
        List<MailBean> mails =
            (List<MailBean>)
                request.getPortletSession().getAttribute("mails", PortletSession.PORTLET_SCOPE);
        PortletPreferences portletPreferences = request.getPreferences();
        String incomingType = portletPreferences.getValue("incomingType", null);
        String incoming = portletPreferences.getValue("incoming", null);
        String incomingPort = portletPreferences.getValue("incomingPort", null);
        String incomingSSL = portletPreferences.getValue("incomingSSL", null);
        String outgoing = portletPreferences.getValue("outgoing", null);
        String outgoingPort = portletPreferences.getValue("outgoingPort", null);
        String outgoingSSL = portletPreferences.getValue("outgoingSSL", null);
        String email = portletPreferences.getValue("email", null);
        String password = portletPreferences.getValue("password", null);
        EmailClient client =
            new EmailClient(
                email,
                password,
                incomingType,
                incoming,
                incomingPort,
                incomingSSL,
                outgoing,
                outgoingPort,
                outgoingPort);
        try {
          client.deleteMessage(mails.get(index).getMsg());
          request.getPortletSession().removeAttribute("mails", PortletSession.PORTLET_SCOPE);
        } catch (Exception e) {
          request.setAttribute("error", e.getMessage());
        }
      }
    } else {
      String showHtmlEditor = request.getParameter("htmlEditor");
      if (showHtmlEditor != null) request.setAttribute("showHtmlEditor", true);
      String toEmail = request.getParameter("toEmail");
      if (toEmail != null) {
        request.setAttribute("toEmail", toEmail);
      }
      String cc = request.getParameter("cc");
      if (cc != null) {
        request.setAttribute("cc", cc);
      }
      String bcc = request.getParameter("bcc");
      if (bcc != null) {
        request.setAttribute("subject", bcc);
      }
      String subject = request.getParameter("subject");
      if (subject != null) {
        request.setAttribute("subject", subject);
      }
      String content = request.getParameter("content");
      if (content != null) {
        request.setAttribute("content", content);
      }
      response.setRenderParameter("type", "create");
    }
  }