@Override
  public String execute(
      StrutsAction originalStrutsAction, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

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

    long entryId = ParamUtil.getLong(request, "entryId");

    response.sendRedirect(themeDisplay.getPathMain() + "/bookmarks/open_entry?entryId=" + entryId);

    return null;
  }
  @Override
  protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Company company = themeDisplay.getCompany();

    if (!company.isStrangers()) {
      throw new PrincipalException.MustBeEnabled(
          company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS);
    }

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

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) {
      throw new PrincipalException("Unable to create anonymous account");
    }

    if (actionRequest.getRemoteUser() != null) {
      actionResponse.sendRedirect(themeDisplay.getPathMain());

      return;
    }

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

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

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            actionRequest,
            LoginPortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect");
    portletURL.setParameter("emailAddress", emailAddress);
    portletURL.setParameter("anonymousUser", Boolean.TRUE.toString());
    portletURL.setWindowState(LiferayWindowState.POP_UP);

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    try {
      if (cmd.equals(Constants.ADD)) {
        addAnonymousUser(actionRequest, actionResponse);

        sendRedirect(actionRequest, actionResponse, portletURL.toString());
      } else if (cmd.equals(Constants.UPDATE)) {
        jsonObject = updateIncompleteUser(actionRequest, actionResponse);

        JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
      }
    } catch (Exception e) {
      if (cmd.equals(Constants.UPDATE)) {
        jsonObject.putException(e);

        JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
      } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) {

        User user =
            _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);

        if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) {
          SessionErrors.add(actionRequest, e.getClass());
        } else {
          sendRedirect(actionRequest, actionResponse, portletURL.toString());
        }
      } else if (e instanceof CaptchaConfigurationException
          || e instanceof CaptchaTextException
          || e instanceof CompanyMaxUsersException
          || e instanceof ContactNameException
          || e instanceof EmailAddressException
          || e instanceof GroupFriendlyURLException
          || e instanceof UserEmailAddressException) {

        SessionErrors.add(actionRequest, e.getClass(), e);
      } else {
        _log.error("Unable to create anonymous account", e);

        PortalUtil.sendError(e, actionRequest, actionResponse);
      }
    }
  }
예제 #3
0
  @Override
  protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    long plid = ParamUtil.getLong(request, "p_l_id");

    if (plid == LayoutConstants.DEFAULT_PLID) {
      plid = themeDisplay.getPlid();
    }

    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long organizationId = ParamUtil.getLong(request, "organizationId");
    int status = WorkflowConstants.STATUS_APPROVED;
    int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA);
    String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT);
    double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT);
    String displayStyle =
        ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT);

    String feedURL =
        themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?";

    String entryURL = feedURL;

    String rss = StringPool.BLANK;

    if (companyId > 0) {
      feedURL = StringPool.BLANK;

      rss =
          _blogsEntryService.getCompanyEntriesRSS(
              companyId,
              new Date(),
              status,
              max,
              type,
              version,
              displayStyle,
              feedURL,
              entryURL,
              themeDisplay);
    } else if (groupId > 0) {
      feedURL += "p_l_id=" + plid;

      entryURL = feedURL;

      rss =
          _blogsEntryService.getGroupEntriesRSS(
              groupId,
              new Date(),
              status,
              max,
              type,
              version,
              displayStyle,
              feedURL,
              entryURL,
              themeDisplay);
    } else if (organizationId > 0) {
      feedURL = StringPool.BLANK;

      rss =
          _blogsEntryService.getOrganizationEntriesRSS(
              organizationId,
              new Date(),
              status,
              max,
              type,
              version,
              displayStyle,
              feedURL,
              entryURL,
              themeDisplay);
    } else if (layout != null) {
      groupId = themeDisplay.getScopeGroupId();

      feedURL = themeDisplay.getPathMain() + "/blogs/rss";

      entryURL = feedURL;

      rss =
          _blogsEntryService.getGroupEntriesRSS(
              groupId,
              new Date(),
              status,
              max,
              type,
              version,
              displayStyle,
              feedURL,
              entryURL,
              themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
  }