@Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

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

    if (!PropsValues.SETUP_WIZARD_ENABLED) {
      response.sendRedirect(themeDisplay.getPathMain());
    }

    String cmd = ParamUtil.getString(request, Constants.CMD);

    try {
      if (Validator.isNull(cmd)) {
        return mapping.findForward("portal.setup_wizard");
      } else if (cmd.equals(Constants.TRANSLATE)) {
        SetupWizardUtil.updateLanguage(request, response);

        return mapping.findForward("portal.setup_wizard");
      } else if (cmd.equals(Constants.TEST)) {
        testDatabase(request, response);

        return null;
      } else if (cmd.equals(Constants.UPDATE)) {
        SetupWizardUtil.updateSetup(request, response);
      }

      response.sendRedirect(themeDisplay.getPathMain() + "/portal/setup_wizard");

      return null;
    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(request, e.getClass());

        return mapping.findForward("portal.setup_wizard");
      } else {
        PortalUtil.sendError(e, request, response);

        return null;
      }
    }
  }
예제 #2
0
  /** @see SetupWizardUtil#_initPlugins */
  protected void initPlugins() throws Exception {

    // See LEP-2885. Don't flush hot deploy events until after the portal
    // has initialized.

    if (SetupWizardUtil.isSetupFinished()) {
      HotDeployUtil.setCapturePrematureEvents(false);

      PortalLifecycleUtil.flushInits();
    }
  }
  protected void testDatabase(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    try {
      SetupWizardUtil.testDatabase(request);

      jsonObject.put("success", true);

      putMessage(request, jsonObject, "database-connection-was-established-sucessfully");
    } catch (ClassNotFoundException cnfe) {
      putMessage(
          request, jsonObject, "database-driver-x-is-not-present", cnfe.getLocalizedMessage());
    } catch (SQLException sqle) {
      putMessage(request, jsonObject, "database-connection-could-not-be-established");
    }

    response.setContentType(ContentTypes.APPLICATION_JSON);
    response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE);

    ServletResponseUtil.write(response, jsonObject.toString());
  }