private String _getJavaScript() throws PortalException {
    String javaScript =
        "/com/liferay/frontend/image/editor/integration/document/library"
            + "/internal/display/context/dependencies"
            + "/edit_with_image_editor_js.ftl";

    Class<?> clazz = getClass();

    URLTemplateResource urlTemplateResource =
        new URLTemplateResource(javaScript, clazz.getResource(javaScript));

    Template template =
        TemplateManagerUtil.getTemplate(
            TemplateConstants.LANG_TYPE_FTL, urlTemplateResource, false);

    template.put("editLanguageKey", LanguageUtil.get(_request, "edit"));

    LiferayPortletResponse liferayPortletResponse = _getLiferayPortletResponse();

    template.put("namespace", liferayPortletResponse.getNamespace());

    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    template.processTemplate(unsyncStringWriter);

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

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    try {
      doSaveEntry(actionRequest, actionResponse);

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

      if (entryId <= 0) {
        SessionMessages.add(actionRequest, "announcementAdded");
      } else {
        SessionMessages.add(actionRequest, "announcementUpdated");
      }

      LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) actionResponse;

      PortletURL portletURL = liferayPortletResponse.createRenderURL();

      portletURL.setParameter("mvcPath", "/manage_entries.jsp");
      portletURL.setParameter(
          "distributionScope", ParamUtil.getString(actionRequest, "distributionScope"));

      jsonObject.put("redirect", portletURL.toString());

      jsonObject.put("success", true);
    } catch (Exception e) {
      String message = null;

      if (e instanceof EntryContentException) {
        message = "please-enter-valid-content";
      } else if (e instanceof EntryDisplayDateException) {
        message = "please-enter-a-valid-display-date";
      } else if (e instanceof EntryExpirationDateException) {
        message = "please-enter-a-valid-expiration-date";
      } else if (e instanceof EntryTitleException) {
        message = "please-enter-a-valid-title";
      } else if (e instanceof EntryURLException) {
        message = "please-enter-a-valid-url";
      } else {
        throw new PortletException(e);
      }

      SessionErrors.clear(actionRequest);

      jsonObject.put("message", translate(actionRequest, message));
      jsonObject.put("success", false);
    }

    writeJSON(actionRequest, actionResponse, jsonObject);
  }
Beispiel #3
0
  public Map<Long, Map<String, PortletURL>> getScopeAddPortletURLs(int max) throws Exception {

    long[] groupIds = getGroupIds();

    if (groupIds.length == 0) {
      return Collections.emptyMap();
    }

    Map<Long, Map<String, PortletURL>> scopeAddPortletURLs = new HashMap();

    LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) _portletResponse;

    PortletURL redirectURL = liferayPortletResponse.createRenderURL();

    redirectURL.setParameter("hideDefaultSuccessMessage", Boolean.TRUE.toString());
    redirectURL.setParameter("mvcPath", "/add_asset_redirect.jsp");

    LiferayPortletRequest liferayPortletRequest = (LiferayPortletRequest) _portletRequest;

    PortletURL currentURLObj =
        PortletURLUtil.getCurrent(liferayPortletRequest, liferayPortletResponse);

    redirectURL.setParameter("redirect", currentURLObj.toString());

    redirectURL.setWindowState(LiferayWindowState.POP_UP);

    String redirect = redirectURL.toString();

    for (long groupId : groupIds) {
      Map<String, PortletURL> addPortletURLs =
          AssetUtil.getAddPortletURLs(
              liferayPortletRequest,
              liferayPortletResponse,
              groupId,
              getClassNameIds(),
              getClassTypeIds(),
              getAllAssetCategoryIds(),
              getAllAssetTagNames(),
              redirect);

      if (MapUtil.isNotEmpty(addPortletURLs)) {
        scopeAddPortletURLs.put(groupId, addPortletURLs);
      }

      if (scopeAddPortletURLs.size() > max) {
        break;
      }
    }

    return scopeAddPortletURLs;
  }
  public void deauthorize(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    oAuthManager.deleteAccessToken(themeDisplay.getUser());

    LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) actionResponse;

    PortletURL portletURL = liferayPortletResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "/view.jsp");

    actionResponse.sendRedirect(portletURL.toString());
  }
  @Override
  public PortletURL getURLViewDiffs(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.JOURNAL,
            PortletRequest.RENDER_PHASE);

    JournalArticle previousApprovedArticle =
        JournalArticleLocalServiceUtil.getPreviousApprovedArticle(_article);

    if (previousApprovedArticle.getVersion() == _article.getVersion()) {
      return null;
    }

    portletURL.setParameter("struts_action", "/journal/compare_versions");
    portletURL.setParameter("groupId", String.valueOf(_article.getGroupId()));
    portletURL.setParameter("articleId", _article.getArticleId());
    portletURL.setParameter("sourceVersion", String.valueOf(previousApprovedArticle.getVersion()));
    portletURL.setParameter("targetVersion", String.valueOf(_article.getVersion()));

    return portletURL;
  }
  @Override
  public String getEditStructureDefaultValuesURL(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      DDMStructure structure,
      String redirectURL,
      String backURL)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.JOURNAL,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/journal/edit_article");
    portletURL.setParameter("redirect", redirectURL);
    portletURL.setParameter("backURL", backURL);
    portletURL.setParameter("groupId", String.valueOf(structure.getGroupId()));
    portletURL.setParameter(
        "classNameId", String.valueOf(PortalUtil.getClassNameId(DDMStructure.class)));
    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()));
    portletURL.setParameter("structureId", structure.getStructureKey());
    portletURL.setWindowState(LiferayWindowState.POP_UP);

    return portletURL.toString();
  }
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    PortletURL editPortletURL = liferayPortletResponse.createRenderURL(PortletKeys.BLOGS);

    editPortletURL.setParameter("struts_action", "/blogs/edit_entry");
    editPortletURL.setParameter("entryId", String.valueOf(_entry.getEntryId()));

    return editPortletURL;
  }
  private String _getOnclickMethod() {
    String imageEditorPortletId =
        PortletProviderUtil.getPortletId(Image.class.getName(), PortletProvider.Action.EDIT);

    PortletURL imageEditorURL =
        PortletURLFactoryUtil.create(_request, imageEditorPortletId, PortletRequest.RENDER_PHASE);

    imageEditorURL.setParameter("mvcRenderCommandName", "/image_editor/view");

    try {
      imageEditorURL.setWindowState(LiferayWindowState.POP_UP);
    } catch (Exception e) {
      throw new SystemException("Unable to set window state", e);
    }

    LiferayPortletResponse liferayPortletResponse = _getLiferayPortletResponse();

    PortletURL editURL = liferayPortletResponse.createActionURL();

    editURL.setParameter(
        ActionRequest.ACTION_NAME, "/document_library/edit_file_entry_with_image_editor");

    editURL.setParameter("fileEntryId", String.valueOf(_fileEntry.getFileEntryId()));

    String fileEntryPreviewURL =
        DLUtil.getPreviewURL(_fileEntry, _fileVersion, _themeDisplay, StringPool.BLANK);

    StringBundler sb = new StringBundler(10);

    sb.append(liferayPortletResponse.getNamespace());
    sb.append("editWithImageEditor('");
    sb.append(imageEditorURL.toString());
    sb.append("', '");
    sb.append(editURL.toString());
    sb.append("', '");
    sb.append(_fileEntry.getFileName());
    sb.append("', '");
    sb.append(fileEntryPreviewURL);
    sb.append("');");

    return sb.toString();
  }
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    PortletURL editPortletURL = liferayPortletResponse.createRenderURL(PortletKeys.IMAGE_GALLERY);

    editPortletURL.setParameter("struts_action", "/image_gallery/edit_image");
    editPortletURL.setParameter("folderId", String.valueOf(_image.getFolderId()));
    editPortletURL.setParameter("imageId", String.valueOf(_image.getImageId()));

    return editPortletURL;
  }
  @Override
  public PortletURL getURLExport(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    PortletURL portletURL = liferayPortletResponse.createActionURL();

    portletURL.setParameter("struts_action", "/asset_publisher/export_journal_article");
    portletURL.setParameter("groupId", String.valueOf(_article.getGroupId()));
    portletURL.setParameter("articleId", _article.getArticleId());

    return portletURL;
  }
  @Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse) {

    PortletURL portletURL = liferayPortletResponse.createRenderURL(PortletKeys.DOCUMENT_LIBRARY);

    portletURL.setParameter("struts_action", "/document_library/edit_file_entry");
    portletURL.setParameter(
        "folderId",
        String.valueOf(
            AssetPublisherUtil.getRecentFolderId(liferayPortletRequest, getClassName())));

    return portletURL;
  }
  @Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long classTypeId) {

    PortletURL portletURL = liferayPortletResponse.createRenderURL(BookmarksPortletKeys.BOOKMARKS);

    portletURL.setParameter("struts_action", "/bookmarks/edit_entry");
    portletURL.setParameter(
        "folderId", String.valueOf(BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID));

    return portletURL;
  }
  @Override
  public PortletURL getURLView(
      LiferayPortletResponse liferayPortletResponse, WindowState windowState) {

    LiferayPortletURL liferayPortletURL =
        liferayPortletResponse.createLiferayPortletURL(
            PortletKeys.BOOKMARKS, PortletRequest.RENDER_PHASE);

    try {
      liferayPortletURL.setWindowState(windowState);
    } catch (WindowStateException wse) {
    }

    return liferayPortletURL;
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.DOCUMENT_LIBRARY,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/document_library/edit_file_entry");
    portletURL.setParameter("fileEntryId", String.valueOf(_fileEntry.getFileEntryId()));

    return portletURL;
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.USERS_ADMIN,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/users_admin/edit_user");
    portletURL.setParameter("p_u_i_d", String.valueOf(_user.getUserId()));

    return portletURL;
  }
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect)
      throws Exception {

    PortletURL viewPortletURL = liferayPortletResponse.createRenderURL(PortletKeys.IMAGE_GALLERY);

    viewPortletURL.setWindowState(WindowState.MAXIMIZED);

    viewPortletURL.setParameter("struts_action", "/image_gallery/view");
    viewPortletURL.setParameter("groupId", String.valueOf(_image.getGroupId()));
    viewPortletURL.setParameter("folderId", String.valueOf(_image.getFolderId()));

    return viewPortletURL.toString();
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.MESSAGE_BOARDS,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/message_boards/edit_message");
    portletURL.setParameter("messageId", String.valueOf(_message.getMessageId()));

    return portletURL;
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            BookmarksPortletKeys.BOOKMARKS_ADMIN,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/bookmarks/edit_entry");
    portletURL.setParameter("folderId", String.valueOf(_entry.getFolderId()));
    portletURL.setParameter("entryId", String.valueOf(_entry.getEntryId()));

    return portletURL;
  }
  @Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long classTypeId) {

    PortletURL portletURL =
        liferayPortletResponse.createRenderURL(DDLPortletKeys.DYNAMIC_DATA_LISTS);

    portletURL.setParameter("mvcPath", "/edit_record.jsp");

    if (classTypeId > 0) {
      portletURL.setParameter("recordSetId", String.valueOf(classTypeId));
    }

    return portletURL;
  }
  @Override
  public PortletURL getURLExport(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.DOCUMENT_LIBRARY,
            PortletRequest.ACTION_PHASE);

    portletURL.setParameter("javax.portlet.action", "/document_library/get_file");
    portletURL.setParameter("groupId", String.valueOf(_fileEntry.getRepositoryId()));
    portletURL.setParameter("folderId", String.valueOf(_fileEntry.getFolderId()));
    portletURL.setParameter("title", String.valueOf(_fileEntry.getTitle()));

    return portletURL;
  }
  @Override
  public PortletURL getURLEdit(
      LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

    PortletURL portletURL =
        liferayPortletResponse.createLiferayPortletURL(
            getControlPanelPlid(liferayPortletRequest),
            PortletKeys.JOURNAL,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/journal/edit_article");
    portletURL.setParameter("groupId", String.valueOf(_article.getGroupId()));
    portletURL.setParameter("articleId", _article.getArticleId());
    portletURL.setParameter("version", String.valueOf(_article.getVersion()));

    return portletURL;
  }
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, LiferayPortletResponse liferayPortletResponse)
      throws Exception {

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

    PortletURL portletURL = liferayPortletResponse.createRenderURL();

    portletURL.setParameter("struts_action", "/document_library/view");
    portletURL.setParameter("viewEntries", Boolean.TRUE.toString());
    portletURL.setParameter("viewFolders", Boolean.TRUE.toString());

    Map<String, Object> data = new HashMap<String, Object>();

    data.put("folder-id", _getDefaultFolderId(request));

    PortalUtil.addPortletBreadcrumbEntry(
        request, themeDisplay.translate("home"), portletURL.toString(), data);

    addPortletBreadcrumbEntries(folder, request, portletURL);
  }
  protected void sendOpenIdRequest(
      ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
    HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);
    HttpSession session = request.getSession();

    LiferayPortletResponse liferayPortletResponse =
        PortalUtil.getLiferayPortletResponse(actionResponse);

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

    PortletURL portletURL = liferayPortletResponse.createActionURL();

    portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());
    portletURL.setParameter(Constants.CMD, Constants.READ);
    portletURL.setParameter("struts_action", "/login/open_id");

    List<DiscoveryInformation> discoveryInformationList = _consumerManager.discover(openId);

    DiscoveryInformation discoveryInformation =
        _consumerManager.associate(discoveryInformationList);

    session.setAttribute(OpenIdWebKeys.OPEN_ID_DISCO, discoveryInformation);

    AuthRequest authRequest =
        _consumerManager.authenticate(
            discoveryInformation, portletURL.toString(), themeDisplay.getPortalURL());

    if (_userLocalService.fetchUserByOpenId(themeDisplay.getCompanyId(), openId) != null) {

      response.sendRedirect(authRequest.getDestinationUrl(true));

      return;
    }

    String screenName = getScreenName(openId);

    User user = _userLocalService.fetchUserByScreenName(themeDisplay.getCompanyId(), screenName);

    if (user != null) {
      _userLocalService.updateOpenId(user.getUserId(), openId);

      response.sendRedirect(authRequest.getDestinationUrl(true));

      return;
    }

    FetchRequest fetchRequest = FetchRequest.createFetchRequest();

    OpenIdProvider openIdProvider =
        _openIdProviderRegistry.getOpenIdProvider(discoveryInformation.getOPEndpoint());

    Map<String, String> openIdAXTypes = openIdProvider.getAxTypes();

    for (String openIdAXType : openIdAXTypes.keySet()) {
      fetchRequest.addAttribute(openIdAXType, openIdAXTypes.get(openIdAXType), true);
    }

    authRequest.addExtension(fetchRequest);

    SRegRequest sRegRequest = SRegRequest.createFetchRequest();

    sRegRequest.addAttribute(_OPEN_ID_SREG_ATTR_EMAIL, true);
    sRegRequest.addAttribute(_OPEN_ID_SREG_ATTR_FULLNAME, true);

    authRequest.addExtension(sRegRequest);

    response.sendRedirect(authRequest.getDestinationUrl(true));
  }
  @Override
  protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    if (PropsValues.AUTH_LOGIN_DISABLED) {
      actionResponse.sendRedirect(
          themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

      return;
    }

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

    	return;
    }*/

    try {
      login(themeDisplay, actionRequest, actionResponse);

      boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

      if (doActionAfterLogin) {
        LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) actionResponse;

        PortletURL renderURL = liferayPortletResponse.createRenderURL();

        renderURL.setParameter("mvcRenderCommandName", "/login/login_redirect");

        actionRequest.setAttribute(WebKeys.REDIRECT, renderURL.toString());
      }
    } catch (Exception e) {
      if (e instanceof AuthException) {
        Throwable cause = e.getCause();

        if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

          SessionErrors.add(actionRequest, cause.getClass(), cause);
        } else {
          if (_log.isInfoEnabled()) {
            _log.info("Authentication failed");
          }

          SessionErrors.add(actionRequest, e.getClass());
        }
      } else if (e instanceof CompanyMaxUsersException
          || e instanceof CookieNotSupportedException
          || e instanceof NoSuchUserException
          || e instanceof PasswordExpiredException
          || e instanceof UserEmailAddressException
          || e instanceof UserIdException
          || e instanceof UserLockoutException
          || e instanceof UserPasswordException
          || e instanceof UserScreenNameException) {

        SessionErrors.add(actionRequest, e.getClass(), e);
      } else {
        _log.error(e, e);

        PortalUtil.sendError(e, actionRequest, actionResponse);

        return;
      }

      postProcessAuthFailure(actionRequest, actionResponse);
    }
  }
  protected String exportToRSS(
      ResourceRequest resourceRequest,
      ResourceResponse resourceResponse,
      String title,
      String description,
      String format,
      double version,
      String displayStyle,
      List<SocialActivity> socialActivities,
      ServiceContext serviceContext)
      throws Exception {

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

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setDescription(GetterUtil.getString(description, title));

    List<SyndEntry> syndEntries = new ArrayList<>();

    syndFeed.setEntries(syndEntries);

    for (SocialActivity socialActivity : socialActivities) {
      SocialActivityFeedEntry socialActivityFeedEntry =
          _socialActivityInterpreterLocalService.interpret(
              StringPool.BLANK, socialActivity, serviceContext);

      if (socialActivityFeedEntry == null) {
        continue;
      }

      SyndEntry syndEntry = new SyndEntryImpl();

      SyndContent syndContent = new SyndContentImpl();

      syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

      String value = null;

      if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
        value = StringPool.BLANK;
      } else {
        value = socialActivityFeedEntry.getBody();
      }

      syndContent.setValue(value);

      syndEntry.setDescription(syndContent);

      if (Validator.isNotNull(socialActivityFeedEntry.getLink())) {
        syndEntry.setLink(socialActivityFeedEntry.getLink());
      }

      syndEntry.setPublishedDate(new Date(socialActivity.getCreateDate()));
      syndEntry.setTitle(HtmlUtil.extractText(socialActivityFeedEntry.getTitle()));
      syndEntry.setUri(syndEntry.getLink());

      syndEntries.add(syndEntry);
    }

    syndFeed.setFeedType(RSSUtil.getFeedType(format, version));

    List<SyndLink> syndLinks = new ArrayList<>();

    syndFeed.setLinks(syndLinks);

    SyndLink selfSyndLink = new SyndLinkImpl();

    syndLinks.add(selfSyndLink);

    LiferayPortletResponse liferayPortletResponse = (LiferayPortletResponse) resourceResponse;

    ResourceURL rssURL = liferayPortletResponse.createResourceURL();

    rssURL.setParameter("feedTitle", title);
    rssURL.setResourceID("rss");

    selfSyndLink.setHref(rssURL.toString());

    selfSyndLink.setRel("self");

    SyndLink alternateSyndLink = new SyndLinkImpl();

    syndLinks.add(alternateSyndLink);

    alternateSyndLink.setHref(PortalUtil.getLayoutFullURL(themeDisplay));
    alternateSyndLink.setRel("alternate");

    syndFeed.setPublishedDate(new Date());
    syndFeed.setTitle(title);
    syndFeed.setUri(rssURL.toString());

    return RSSUtil.export(syndFeed);
  }
  @Override
  public void sendRequest(
      ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse)
      throws PortalException {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

    request = PortalUtil.getOriginalServletRequest(request);

    HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

    HttpSession session = request.getSession();

    LiferayPortletResponse liferayPortletResponse =
        PortalUtil.getLiferayPortletResponse(actionResponse);

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

    PortletURL portletURL = liferayPortletResponse.createActionURL();

    portletURL.setParameter(ActionRequest.ACTION_NAME, "/login/openid");
    portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());
    portletURL.setParameter("mvcRenderCommandName", "/login/openid");
    portletURL.setParameter(Constants.CMD, Constants.READ);

    try {
      List<DiscoveryInformation> discoveryInformationList = _consumerManager.discover(openId);

      DiscoveryInformation discoveryInformation =
          _consumerManager.associate(discoveryInformationList);

      session.setAttribute(OpenIdWebKeys.OPEN_ID_DISCO, discoveryInformation);

      AuthRequest authRequest =
          _consumerManager.authenticate(
              discoveryInformation, portletURL.toString(), themeDisplay.getPortalURL());

      if (_userLocalService.fetchUserByOpenId(themeDisplay.getCompanyId(), openId) != null) {

        response.sendRedirect(authRequest.getDestinationUrl(true));

        return;
      }

      String screenName = getScreenName(openId);

      User user = _userLocalService.fetchUserByScreenName(themeDisplay.getCompanyId(), screenName);

      if (user != null) {
        _userLocalService.updateOpenId(user.getUserId(), openId);

        response.sendRedirect(authRequest.getDestinationUrl(true));

        return;
      }

      FetchRequest fetchRequest = FetchRequest.createFetchRequest();

      OpenIdProvider openIdProvider =
          _openIdProviderRegistry.getOpenIdProvider(discoveryInformation.getOPEndpoint());

      Map<String, String> openIdAXTypes = openIdProvider.getAxTypes();

      for (String openIdAXType : openIdAXTypes.keySet()) {
        fetchRequest.addAttribute(openIdAXType, openIdAXTypes.get(openIdAXType), true);
      }

      authRequest.addExtension(fetchRequest);

      SRegRequest sRegRequest = SRegRequest.createFetchRequest();

      sRegRequest.addAttribute(_OPEN_ID_SREG_ATTR_EMAIL, true);
      sRegRequest.addAttribute(_OPEN_ID_SREG_ATTR_FULLNAME, true);

      authRequest.addExtension(sRegRequest);

      response.sendRedirect(authRequest.getDestinationUrl(true));
    } catch (ConsumerException ce) {
      throw new OpenIdServiceException.ConsumerException(ce.getMessage(), ce);
    } catch (DiscoveryException de) {
      throw new OpenIdServiceException.DiscoveryException(de.getMessage(), de);
    } catch (MessageException me) {
      throw new OpenIdServiceException.MessageException(me.getMessage(), me);
    } catch (IOException ioe) {
      throw new SystemException("Unable to communicate with OpenId provider", ioe);
    }
  }