public void deleteLayout(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    long selPlid = ParamUtil.getLong(actionRequest, "selPlid");

    if (selPlid <= 0) {
      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long layoutId = ParamUtil.getLong(actionRequest, "layoutId");

      Layout layout = layoutLocalService.getLayout(groupId, privateLayout, layoutId);

      selPlid = layout.getPlid();
    }

    Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse);

    if (selPlid == themeDisplay.getRefererPlid()) {
      long newRefererPlid = (Long) returnValue[2];

      redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);
      redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid", 0);
    }

    actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
  }
  public void EditPreferenceAction(ActionRequest req, ActionResponse res) {
    String cmd = ParamUtil.getString(req, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    PortletPreferences prefs = req.getPreferences();
    int displayStyle = ParamUtil.getInteger(req, "displayStyle");
    // String styleSelected = ParamUtil.getString(req, "displayStyle","1");
    String[] selectCategories = req.getParameterValues("selectCategories");
    String defaultSize = ParamUtil.getString(req, "defaultSize");
    String widthSize = ParamUtil.getString(req, "widthSize");
    String heightSize = ParamUtil.getString(req, "heightSize");
    try {
      prefs.setValues("selectCategories", selectCategories);
      prefs.setValue("displayStyleExt", String.valueOf(displayStyle));
      prefs.setValue("defaultSize", defaultSize);
      prefs.setValue("widthSize", widthSize);
      prefs.setValue("heightSize", heightSize);

      prefs.store();
      res.setRenderParameter("jspPage", "/html/portlet/view_vclip/view.jsp");
    } catch (Exception e) {
      // TODO: handle exception
    }
  }
  protected String getSaveAndContinueRedirect(
      ActionRequest actionRequest, BlogsEntry entry, String redirect) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    String backURL = ParamUtil.getString(actionRequest, "backURL");

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/blogs/edit_entry");

    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("backURL", backURL, false);
    portletURL.setParameter("groupId", String.valueOf(entry.getGroupId()), false);
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
 public Registrant(ActionRequest request) {
   super();
   isMale = false;
   password = request.getParameter(PortalConstants.PASSWORD);
   password2 = request.getParameter(PortalConstants.PASSWORD_REPEAT);
   setWantsMailNotification(true);
 }
 private void doPage(ActionRequest request, ActionResponse response) {
   // System.out.println("[BrowserPortlet.doPage]");
   String url = request.getParameter("url");
   WebPage _page = new WebPage();
   URI _access = new URI();
   _access.setEffectiveURI(url);
   _page.setAccess(_access);
   _page.setContextCreation("PortletWebBrowser");
   _page.setCreation(new Date());
   // TODO pour l'instant on se fout du contenu de la page
   // _page.setHTMLContent(HTMLmanager.getCleanHTML(url));
   HTMLPage page = new HTMLPage();
   page.setURL(url);
   try {
     page.extractTitle();
   } catch (ParserException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   String title = page.getTitle();
   // String title = HTMLmanager.getTitlePage(url) ;
   _page.setLabel(title);
   _page.setPrincipalURL(_access);
   _page.setRepresentsResource(_access);
   this.sendEvent("page", _page, response);
   // response.setRenderParameter("url", url);
   request.getPortletSession().setAttribute("current_url", url);
 }
Exemple #6
0
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig config,
      ActionRequest req,
      ActionResponse res)
      throws Exception {

    String cmd = req.getParameter(Constants.CMD);

    if ((cmd != null) && (cmd.equals(Constants.ADD))) {
      try {
        _import(req, res);
      } catch (Exception e) {
        if (e != null && e instanceof ContactEmailAddressException
            || e instanceof ContactFirstNameException
            || e instanceof ContactLastNameException
            || e instanceof DuplicateContactException
            || e instanceof UploadException) {

          SessionErrors.add(req, e.getClass().getName());

          setForward(req, "portlet.address_book.import_export");
        } else {
          req.setAttribute(PageContext.EXCEPTION, e);

          setForward(req, Constants.COMMON_ERROR);
        }
      }
    } else {
      setForward(req, "portlet.address_book.import_export");
    }
  }
  public void editConfiguration(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String settingsScope = ParamUtil.getString(actionRequest, "settingsScope");

    PortletPreferences portletPreferences =
        getPortletPreferences(themeDisplay, portlet.getPortletId(), settingsScope);

    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences);

    ConfigurationAction configurationAction = getConfigurationAction(portlet);

    if (configurationAction == null) {
      return;
    }

    configurationAction.processAction(portletConfig, actionRequest, actionResponse);

    Layout layout = themeDisplay.getLayout();

    PortletLayoutListener portletLayoutListener = portlet.getPortletLayoutListenerInstance();

    if (portletLayoutListener != null) {
      portletLayoutListener.onSetup(portlet.getPortletId(), layout.getPlid());
    }
  }
  protected String getSaveAndContinueRedirect(
      ActionRequest actionRequest, JournalArticle article, String redirect) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String referringPortletResource =
        ParamUtil.getString(actionRequest, "referringPortletResource");

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            JournalPortletKeys.JOURNAL,
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_article.jsp");
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("referringPortletResource", referringPortletResource, false);
    portletURL.setParameter("resourcePrimKey", String.valueOf(article.getResourcePrimKey()), false);
    portletURL.setParameter("groupId", String.valueOf(article.getGroupId()), false);
    portletURL.setParameter("folderId", String.valueOf(article.getFolderId()), false);
    portletURL.setParameter("articleId", article.getArticleId(), false);
    portletURL.setParameter("version", String.valueOf(article.getVersion()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
  protected void updateConfiguration(ActionRequest req, PortletPreferences prefs) throws Exception {

    String[] urls = req.getParameterValues("url");
    String[] titles = req.getParameterValues("title");
    int entriesPerFeed = ParamUtil.getInteger(req, "entriesPerFeed", 4);
    boolean showFeedTitle = ParamUtil.getBoolean(req, "showFeedTitle");
    boolean showFeedPublishedDate = ParamUtil.getBoolean(req, "showFeedPublishedDate");
    boolean showFeedDescription = ParamUtil.getBoolean(req, "showFeedDescription");
    boolean showFeedImage = ParamUtil.getBoolean(req, "showFeedImage");
    String feedImageAlignment = ParamUtil.getString(req, "feedImageAlignment");
    long headerArticleResouceId = ParamUtil.getLong(req, "headerArticleResouceId");
    long footerArticleResouceId = ParamUtil.getLong(req, "footerArticleResouceId");

    if (urls != null && titles != null) {
      prefs.setValues("urls", urls);
      prefs.setValues("titles", titles);
    } else {
      prefs.setValues("urls", new String[0]);
      prefs.setValues("titles", new String[0]);
    }

    prefs.setValue("items-per-channel", String.valueOf(entriesPerFeed));
    prefs.setValue("show-feed-title", String.valueOf(showFeedTitle));
    prefs.setValue("show-feed-published-date", String.valueOf(showFeedPublishedDate));
    prefs.setValue("show-feed-description", String.valueOf(showFeedDescription));
    prefs.setValue("show-feed-image", String.valueOf(showFeedImage));
    prefs.setValue("feed-image-alignment", String.valueOf(feedImageAlignment));
    prefs.setValue("header-article-resouce-id", String.valueOf(headerArticleResouceId));
    prefs.setValue("footer-article-resouce-id", String.valueOf(footerArticleResouceId));
  }
  protected String getOldScopeName(ActionRequest actionRequest, Portlet portlet) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    PortletPreferences portletPreferences = actionRequest.getPreferences();

    String scopeType = GetterUtil.getString(portletPreferences.getValue("lfrScopeType", null));

    if (Validator.isNull(scopeType)) {
      return null;
    }

    String scopeName = null;

    if (scopeType.equals("company")) {
      scopeName = themeDisplay.translate("global");
    } else if (scopeType.equals("layout")) {
      String scopeLayoutUuid =
          GetterUtil.getString(portletPreferences.getValue("lfrScopeLayoutUuid", null));

      Layout scopeLayout =
          _layoutLocalService.fetchLayoutByUuidAndGroupId(
              scopeLayoutUuid, layout.getGroupId(), layout.isPrivateLayout());

      if (scopeLayout != null) {
        scopeName = scopeLayout.getName(themeDisplay.getLocale());
      }
    } else {
      throw new IllegalArgumentException("Scope type " + scopeType + " is invalid");
    }

    return scopeName;
  }
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      FileEntry fileEntry,
      String redirect)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/document_library/edit_file_entry");
    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("groupId", String.valueOf(fileEntry.getGroupId()), false);
    portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()), false);
    portletURL.setParameter("version", String.valueOf(fileEntry.getVersion()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
  public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Enumeration<String> enu = actionRequest.getParameterNames();

    Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (!name.startsWith("priority")) {
        continue;
      }

      double priority = ParamUtil.getDouble(actionRequest, name);

      long resourcePrimKey = GetterUtil.getLong(name.substring(8));

      resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority);
    }

    KBArticleServiceUtil.updateKBArticlesPriorities(
        themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap);
  }
  // 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  ====");
  }
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig, ActionRequest actionRequest, DDMStructure structure)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/dynamic_data_mapping/copy_structure");

    long classNameId = PortalUtil.getClassNameId(DDMStructure.class);

    portletURL.setParameter("classNameId", String.valueOf(classNameId), false);

    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()), false);
    portletURL.setParameter(
        "copyFormTemplates", ParamUtil.getString(actionRequest, "copyFormTemplates"), false);
    portletURL.setParameter(
        "copyDisplayTemplates", ParamUtil.getString(actionRequest, "copyDisplayTemplates"), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
 @SuppressWarnings("unchecked")
 @ProcessAction(name = "addBookAction")
 public void addBook(ActionRequest request, ActionResponse response)
     throws PortletException, IOException {
   logger.info("addBook action invoked");
   if (!request.isUserInRole("administrator")) {
     response.setRenderParameter("myaction", "error");
     response.setRenderParameter(
         "exceptionMsg",
         "You are not authorized for this action. You must have Administrator role.");
     return;
   }
   request.setAttribute("myaction", "addBookAction");
   PortletRequestDispatcher dispatcher =
       request
           .getPortletSession()
           .getPortletContext()
           .getRequestDispatcher(response.encodeURL("/myservlet/bookServlet"));
   dispatcher.include(request, response);
   Map<String, String> map = (Map<String, String>) request.getAttribute("errors");
   if (map != null && !map.isEmpty()) {
     response.setRenderParameter("myaction", "addBookAction");
   } else {
     response.setRenderParameter("myaction", "showCatalog");
   }
 }
  /**
   * Redefine method, we have to check stuff.
   *
   * @see de.ingrid.portal.portlets.admin.ContentPortlet#doActionSave(javax.portlet.ActionRequest)
   */
  protected void doActionSave(ActionRequest request) {
    AdminCMSForm af =
        (AdminCMSForm) Utils.getActionForm(request, AdminCMSForm.SESSION_KEY, AdminCMSForm.class);
    af.populate(request);
    af.validate();
    if (af.hasErrors()) {
      return;
    }

    IngridCMS cmsEntry = new IngridCMS();
    cmsEntry.setItemChanged(new Date());
    cmsEntry.setItemChangedBy(request.getUserPrincipal().getName());
    cmsEntry.setItemDescription(af.getInput(AdminCMSForm.FIELD_DESCRIPTION));
    cmsEntry.setItemKey(af.getInput(AdminCMSForm.FIELD_KEY));

    HashSet localizedItems = new HashSet();

    String[] languages = Utils.getLanguagesShortAsArray();
    for (String lang : languages) {
      IngridCMSItem item = new IngridCMSItem();
      item.setItemLang(lang);
      item.setItemTitle(af.getInput(AdminCMSForm.FIELD_TITLE + lang));
      item.setItemValue(af.getInput(AdminCMSForm.FIELD_VALUE + lang));
      item.setItemChanged(new Date());
      item.setItemChangedBy(request.getUserPrincipal().getName());
      localizedItems.add(item);
    }

    cmsEntry.setLocalizedItems(localizedItems);

    UtilsDB.saveDBObject(cmsEntry);

    af.addMessage("admin.cms.save.success");
  }
  /**
   * @see de.ingrid.portal.portlets.admin.ContentPortlet#processAction(javax.portlet.ActionRequest,
   *     javax.portlet.ActionResponse)
   */
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {

    if (request.getParameter(PARAMV_ACTION_DB_DO_SAVE) != null) {
      AdminCMSForm f =
          (AdminCMSForm) Utils.getActionForm(request, AdminCMSForm.SESSION_KEY, AdminCMSForm.class);
      f.clear();
      f.clearMessages();
      // call sub method
      doActionSave(request);
      response.setRenderParameter(Settings.PARAM_ACTION, PARAMV_ACTION_DB_DO_SAVE);
      response.setRenderParameter("cmd", "action processed");
    } else if (request.getParameter(PARAMV_ACTION_DB_DO_UPDATE) != null) {
      AdminCMSForm f =
          (AdminCMSForm) Utils.getActionForm(request, AdminCMSForm.SESSION_KEY, AdminCMSForm.class);
      f.clear();
      f.clearMessages();
      // call sub method
      doActionUpdate(request);
      response.setRenderParameter(Settings.PARAM_ACTION, PARAMV_ACTION_DB_DO_UPDATE);
      response.setRenderParameter("cmd", "action processed");
    } else {
      super.processAction(request, response);
    }
  }
  protected void updateWorkflowDefinition(ActionRequest actionRequest) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title");

    File file = uploadPortletRequest.getFile("file");

    WorkflowDefinition workflowDefinition = null;

    if (file == null) {
      String name = ParamUtil.getString(actionRequest, "name");
      int version = ParamUtil.getInteger(actionRequest, "version");

      workflowDefinition =
          WorkflowDefinitionManagerUtil.getWorkflowDefinition(
              themeDisplay.getCompanyId(), name, version);

      WorkflowDefinitionManagerUtil.updateTitle(
          themeDisplay.getCompanyId(), themeDisplay.getUserId(), name, version, getTitle(titleMap));
    } else {
      workflowDefinition =
          WorkflowDefinitionManagerUtil.deployWorkflowDefinition(
              themeDisplay.getCompanyId(), themeDisplay.getUserId(),
              getTitle(titleMap), FileUtil.getBytes(file));
    }

    actionRequest.setAttribute(WebKeys.WORKFLOW_DEFINITION, workflowDefinition);
  }
  /*
   * 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);
    }
  }
  /**
   * Takes a submitted contact and adds it to the database if it passes validation.
   *
   * @param request
   * @param response
   */
  public void registerContact(ActionRequest request, ActionResponse response) throws Exception {

    _log.debug("registerContact");

    Contact contact = ActionUtil.contactFromRequest(request);
    ArrayList<String> errors = new ArrayList();
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String community = "";
    try {
      community = themeDisplay.getScopeGroupName();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    boolean regValid = ContactMeRegValidator.validateRegistration(contact, errors);

    if (regValid) {

      long userId = themeDisplay.getUserId();

      contact.setCreateDate(new Date(System.currentTimeMillis()));
      contact.setUserId(userId);
      contact.setStatus(Constants.CONTACT_RECEIVED);
      contact.setCommunity(community);

      ContactLocalServiceUtil.addContact(contact);
      SessionMessages.add(request, "thank-you-message");

      PortletPreferences preferences = request.getPreferences();

      long companyId = PortalUtil.getCompanyId(request);

      Message message = new Message();

      message.put("from-name", preferences.getValue("fromName", ""));
      message.put("from-address", preferences.getValue("fromEMail", ""));
      message.put("subject", preferences.getValue("subject", ""));
      message.put("body", preferences.getValue("body", ""));
      message.put("signature", preferences.getValue("signature", ""));
      message.put("to-name", contact.getFullname());
      message.put("to-address", contact.getEmail());
      message.put("community", contact.getCommunity());
      message.put("companyId", companyId);

      MessageBusUtil.sendMessage("liferay/contactme", message);

      response.setRenderParameter("jspPage", viewThankYouJSP);

    } else {
      for (String error : errors) {
        SessionErrors.add(request, error);
      }
      SessionErrors.add(request, "error-saving-contact");
      response.setRenderParameter("jspPage", viewAddContactJSP);
      request.setAttribute("cmContact", contact);
    }
  }
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
    _log.info("***processAction****");

    boolean error = false;

    String saveButton = (String) request.getParameter("saveButton");
    String resetButton = (String) request.getParameter("resetButton");

    _log.info("saveButton: " + saveButton);
    _log.info("resetButton: " + resetButton);

    String nameTelescope = (String) request.getParameter("nameTelescope");
    String nameObservatory = (String) request.getParameter("nameObservatory");
    String briefDescription = (String) request.getParameter("briefDescription");
    String nameCountry = (String) request.getParameter("nameCountry");
    String nameCity = (String) request.getParameter("nameCity");
    String latitude = (String) request.getParameter("latitude");
    String longitude = (String) request.getParameter("longitude");
    String urlTelescope = (String) request.getParameter("urlTelescope");

    _log.info("nameTelescope: " + nameTelescope);
    _log.info("nameObservatory: " + nameObservatory);
    _log.info("briefDescription: " + briefDescription);
    _log.info("nameCountry: " + nameCountry);
    _log.info("nameCity: " + nameCity);
    _log.info("latitude: " + latitude);
    _log.info("longitude: " + longitude);
    _log.info("urlTelescope: " + urlTelescope);

    ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    User user = td.getUser();
    _log.info("user: "******"error01");
    }

    try {
      repository.registerObservatory(nameObservatory, nameCity, nameCountry);
    } catch (RTRepositoryException_Exception e) {
      error = true;
      _log.error(e.getMessage());
    } catch (Exception e) {
      _log.error(e.getMessage());
    } finally {
      SessionErrors.add(request, "error01");
    }

    if (!error) SessionMessages.add(request, "success");
  }
 private String generateHighlightId(ActionRequest request) {
   int nb_highlight = 0;
   if (request.getPortletSession().getAttribute("nb_highlight") != null) {
     nb_highlight = (Integer) request.getPortletSession().getAttribute("nb_highlight");
     int _new_value = nb_highlight + 1;
     request.getPortletSession().setAttribute("nb_highlight", _new_value);
   } else request.getPortletSession().setAttribute("nb_highlight", 1);
   return request.getPortletSession().getId() + this.getPortletName() + nb_highlight;
 }
 /*
  * Process Action.
  */
 @Override
 public void processAction(ActionRequest request, ActionResponse response)
     throws PortletException {
   if (request.getParameter(SUBMIT_FINISHED) != null) {
     processEditFinishedAction(request, response);
   } else if (request.getParameter(SUBMIT_CANCEL) != null) {
     processEditCancelAction(request, response);
   }
 }
  /**
   * This method inserts new TerminationReason record into the database table
   *
   * @param actionRequest
   * @param actionResponse
   * @throws IOException
   * @throws PortletException
   * @throws SystemException
   */
  public void saveTerminationReasons(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    try {
      TerminationReasons terminationReasons =
          TerminationReasonsLocalServiceUtil.createTerminationReasons(
              CounterLocalServiceUtil.increment());

      String id = ParamUtil.getString(actionRequest, "terminationreasonsId");
      String name = ParamUtil.getString(actionRequest, "terminationreasonsName");
      String terminationReason = name.trim();
      if (terminationReason.equals("") || terminationReason == null) {

        System.out.println("Empty value in TerminationReason...");
        SessionMessages.add(actionRequest.getPortletSession(), "termination-form-error");
        actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp");
      } else {

        System.out.println("id == " + id + "Name = " + name);
        if (id == "" || id == null) {

          DynamicQuery dynamicQuery =
              DynamicQueryFactoryUtil.forClass(
                  TerminationReasons.class, PortalClassLoaderUtil.getClassLoader());

          dynamicQuery.add(RestrictionsFactoryUtil.eq("terminationreasonsName", name));
          List<TerminationReasons> list =
              TerminationReasonsLocalServiceUtil.dynamicQuery(dynamicQuery);

          if (list.size() > 0) {
            TerminationReasons terminationReasons2 = list.get(0);

            if (terminationReasons2 != null) {

              SessionMessages.add(
                  actionRequest.getPortletSession(), "termination-form-duplicate-error");
              actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp");
            }
          } else {

            terminationReasons.setTerminationreasonsName(
                ParamUtil.getString(actionRequest, "terminationreasonsName"));
            terminationReasons.setCreateDate(date);
            terminationReasons.setModifiedDate(date);
            terminationReasons.setCompanyId(themeDisplay.getCompanyId());
            terminationReasons.setGroupId(themeDisplay.getCompanyGroupId());
            terminationReasons.setUserId(themeDisplay.getUserId());
            terminationReasons =
                TerminationReasonsLocalServiceUtil.addTerminationReasons(terminationReasons);
          }
        }
      }
    } catch (SystemException e) {

      e.printStackTrace();
    }
  }
  protected void getLatestOrder(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    ShoppingOrder order =
        ShoppingOrderLocalServiceUtil.getLatestOrder(
            themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

    actionRequest.setAttribute(WebKeys.SHOPPING_ORDER, order);
  }
  @Override
  public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet processAction entry");

    portletResp.setRenderParameters(portletReq.getParameterMap());
    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    StringWriter writer = new StringWriter();
  }
  private void _deleteScheduler(
      ActionRequest req, ActionResponse res, PortletConfig config, ActionForm form, User user)
      throws Exception {
    ContentImporterForm contentImporterForm = (ContentImporterForm) form;

    if (UtilMethods.isSet(contentImporterForm.getJobGroup()))
      QuartzUtils.removeJob(contentImporterForm.getJobName(), contentImporterForm.getJobGroup());
    else QuartzUtils.removeJob(req.getParameter("name"), req.getParameter("group"));

    SessionMessages.add(req, "message", "message.Scheduler.delete");
  }
  @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");
  }
 /**
  * Pass all the action request parameters to the render phase by putting them into the action
  * response object. This may not be called when the action will call {@link
  * javax.portlet.ActionResponse#sendRedirect sendRedirect}.
  *
  * @param request the current action request
  * @param response the current action response
  * @see javax.portlet.ActionResponse#setRenderParameter
  */
 public static void passAllParametersToRenderPhase(
     ActionRequest request, ActionResponse response) {
   try {
     Enumeration<String> en = request.getParameterNames();
     while (en.hasMoreElements()) {
       String param = en.nextElement();
       String values[] = request.getParameterValues(param);
       response.setRenderParameter(param, values);
     }
   } catch (IllegalStateException ex) {
     // Ignore in case sendRedirect was already set.
   }
 }
  /**
   * Navigate to the ContactMe page.
   *
   * @param request
   * @param response
   */
  public void addContact(ActionRequest request, ActionResponse response) {

    _log.debug("addContact");

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long companyId = themeDisplay.getCompanyId();

    Contact contact = new ContactImpl();

    request.setAttribute("cmContact", contact);
    response.setRenderParameter("jspPage", viewAddContactJSP);
  }