Example usage for com.liferay.portal.kernel.theme ThemeDisplay getPlid

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPlid

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getPlid.

Prototype

public long getPlid() 

Source Link

Document

Returns the primary key of the page.

Usage

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static long getPreviewPlid(JournalArticle article, ThemeDisplay themeDisplay) throws Exception {

    if (article != null) {
        Layout layout = article.getLayout();

        if (layout != null) {
            return layout.getPlid();
        }/*from w ww . j a v a 2 s.c  o  m*/
    }

    Layout layout = LayoutLocalServiceUtil.fetchFirstLayout(themeDisplay.getScopeGroupId(), false,
            LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);

    if (layout == null) {
        layout = LayoutLocalServiceUtil.fetchFirstLayout(themeDisplay.getScopeGroupId(), true,
                LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
    }

    if (layout != null) {
        return layout.getPlid();
    }

    return themeDisplay.getPlid();
}

From source file:com.liferay.journal.web.asset.JournalArticleAssetRenderer.java

License:Open Source License

@Override
public PortletURL getURLExport(LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse) throws Exception {

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

    PortletURL portletURL = PortletURLFactoryUtil.create(liferayPortletRequest, JournalPortletKeys.JOURNAL,
            themeDisplay.getPlid(), PortletRequest.RESOURCE_PHASE);

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    liferayPortletURL.setParameter("groupId", String.valueOf(_article.getGroupId()));
    liferayPortletURL.setParameter("articleId", _article.getArticleId());
    liferayPortletURL.setResourceID("exportArticle");

    return liferayPortletURL;
}

From source file:com.liferay.login.authentication.iam.web.internal.portlet.action.IAMLoginAction.java

License:Apache License

/**
 * Send the user to the page after login.
 *
 * @param request The servlet request/*from  ww  w.ja v  a2s .c  o  m*/
 * @param response The servlet response
 * @throws Exception If the user cannot be redirect
 */
protected final void sendLoginRedirect(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {

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

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect");
    portletURL.setWindowState(LiferayWindowState.POP_UP);

    response.sendRedirect(portletURL.toString());
}

From source file:com.liferay.login.authentication.iam.web.internal.portlet.action.IAMLoginAction.java

License:Apache License

/**
 * Send the user to the update account page.
 *
 * @param request The servlet request/*from  ww w  .  j  a v  a  2s.  co  m*/
 * @param response The servlet response
 * @param user The user to update
 * @throws Exception If the update page cannot be created
 */
protected final void sendUpdateAccountRedirect(final HttpServletRequest request,
        final HttpServletResponse response, final User user) throws Exception {

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

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());
    portletURL.setParameter("mvcRenderCommandName", "/login/associate_iam_user");

    PortletURL redirectURL = PortletURLFactoryUtil.create(request, PortletKeys.LOGIN, themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    redirectURL.setParameter("mvcRenderCommandName", "/login/login_redirect");
    redirectURL.setParameter("emailAddress", user.getEmailAddress());
    redirectURL.setParameter("anonymousUser", Boolean.FALSE.toString());
    redirectURL.setPortletMode(PortletMode.VIEW);
    redirectURL.setWindowState(LiferayWindowState.POP_UP);

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

    portletURL.setParameter("userId", String.valueOf(user.getUserId()));
    portletURL.setParameter("emailAddress", user.getEmailAddress());
    portletURL.setParameter("firstName", user.getFirstName());
    portletURL.setParameter("lastName", user.getLastName());
    portletURL.setPortletMode(PortletMode.VIEW);
    portletURL.setWindowState(LiferayWindowState.POP_UP);

    response.sendRedirect(portletURL.toString());
}

From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java

License:Open Source License

protected void sendRedirect(ActionRequest actionRequest, ActionResponse actionResponse,
        ThemeDisplay themeDisplay, User user, String password) throws Exception {

    String login = null;//from w w w  .  j av  a 2s . c o  m

    Company company = themeDisplay.getCompany();

    String authType = company.getAuthType();

    if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
        login = String.valueOf(user.getUserId());
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
        login = user.getScreenName();
    } else {
        login = user.getEmailAddress();
    }

    HttpServletRequest request = _portal.getHttpServletRequest(actionRequest);

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

    if (Validator.isNotNull(redirect)) {
        HttpServletResponse response = _portal.getHttpServletResponse(actionResponse);

        _authenticatedSessionManager.login(request, response, login, password, false, null);
    } else {
        PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid());

        loginURL.setParameter("login", login);

        redirect = loginURL.toString();
    }

    actionResponse.sendRedirect(redirect);
}

From source file:com.liferay.marketplace.app.manager.web.internal.util.MarketplaceAppDisplay.java

License:Open Source License

@Override
public String getStoreURL(HttpServletRequest request) {
    try {//from  w  ww  .  ja v  a2 s.c  om
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

        PortletURL portletURL = PortletURLFactoryUtil.create(request,
                MarketplaceStorePortletKeys.MARKETPLACE_STORE, themeDisplay.getPlid(),
                PortletRequest.RENDER_PHASE);

        portletURL.setParameter("appEntryId", String.valueOf(_app.getRemoteAppId()));
        portletURL.setWindowState(LiferayWindowState.MAXIMIZED);

        return portletURL.toString();
    } catch (Exception e) {
    }

    return StringPool.BLANK;
}

From source file:com.liferay.message.boards.web.internal.portlet.action.RSSAction.java

License:Open Source License

@Override
protected byte[] getRSS(HttpServletRequest request) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

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

    if (plid == LayoutConstants.DEFAULT_PLID) {
        plid = themeDisplay.getPlid();
    }//  ww w .  j a v a  2s . co  m

    long companyId = ParamUtil.getLong(request, "companyId");
    long groupId = ParamUtil.getLong(request, "groupId");
    long userId = ParamUtil.getLong(request, "userId");
    long categoryId = ParamUtil.getLong(request, "mbCategoryId");
    long threadId = ParamUtil.getLong(request, "threadId");
    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 entryURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
            + "/message_boards/find_message?p_l_id=" + plid;

    String rss = StringPool.BLANK;

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

        rss = _mbMessageService.getCompanyMessagesRSS(companyId, WorkflowConstants.STATUS_APPROVED, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (groupId > 0) {
        String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName");

        String feedURL = null;

        if (mvcRenderCommandName.equals("/message_boards/view_recent_posts")) {

            feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                    + "/message_boards/find_recent_posts?p_l_id=" + plid;
        } else {
            feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                    + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId;
        }

        if (userId > 0) {
            rss = _mbMessageService.getGroupMessagesRSS(groupId, userId, WorkflowConstants.STATUS_APPROVED, max,
                    type, version, displayStyle, feedURL, entryURL, themeDisplay);
        } else {
            rss = _mbMessageService.getGroupMessagesRSS(groupId, WorkflowConstants.STATUS_APPROVED, max, type,
                    version, displayStyle, feedURL, entryURL, themeDisplay);
        }
    } else if (categoryId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId;

        rss = _mbMessageService.getCategoryMessagesRSS(groupId, categoryId, WorkflowConstants.STATUS_APPROVED,
                max, type, version, displayStyle, feedURL, entryURL, themeDisplay);
    } else if (threadId > 0) {
        String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain()
                + "/message_boards/find_thread?p_l_id=" + plid + "&threadId=" + threadId;

        rss = _mbMessageService.getThreadMessagesRSS(threadId, WorkflowConstants.STATUS_APPROVED, max, type,
                version, displayStyle, feedURL, entryURL, themeDisplay);
    }

    return rss.getBytes(StringPool.UTF8);
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    try {/*from   w  w  w .  j  a  v  a  2s  .c  om*/
        String returnToFullPageURL = ParamUtil.getString(portletRequest, "returnToFullPageURL");

        PortletURL portletURL = PortletProviderUtil.getPortletURL(portletRequest,
                PortletConfigurationApplicationType.PortletConfiguration.CLASS_NAME,
                PortletProvider.Action.VIEW);

        portletURL.setParameter("mvcPath", "/edit_permissions.jsp");
        portletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
        portletURL.setParameter("portletConfiguration", Boolean.TRUE.toString());

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

        PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

        portletURL.setParameter("portletResource", portletDisplay.getId());
        portletURL.setParameter("resourcePrimKey",
                PortletPermissionUtil.getPrimaryKey(themeDisplay.getPlid(), portletDisplay.getId()));

        portletURL.setWindowState(LiferayWindowState.POP_UP);

        return portletURL.toString();
    } catch (Exception e) {
    }

    return StringPool.BLANK;
}

From source file:com.liferay.site.navigation.admin.web.internal.portlet.action.AddSiteNavigationMenuMVCActionCommand.java

License:Open Source License

private String _getRedirectURL(ActionRequest actionRequest, long siteNavigationMenuId) {

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

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

    PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest,
            SiteNavigationAdminPortletKeys.SITE_NAVIGATION_ADMIN, themeDisplay.getPlid(),
            ActionRequest.RENDER_PHASE);

    redirectURL.setParameter("mvcPath", "/edit_site_navigation_menu.jsp");
    redirectURL.setParameter("redirect", redirect);
    redirectURL.setParameter("siteNavigationMenuId", String.valueOf(siteNavigationMenuId));

    return redirectURL.toString();
}

From source file:com.liferay.site.navigation.admin.web.internal.portlet.action.EditSiteNavigationMenuItemParentMVCActionCommand.java

License:Open Source License

private String _getRedirect(ActionRequest actionRequest, SiteNavigationMenuItem siteNavigationMenuItem) {

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

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

    PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest,
            SiteNavigationAdminPortletKeys.SITE_NAVIGATION_ADMIN, themeDisplay.getPlid(),
            ActionRequest.RENDER_PHASE);

    redirectURL.setParameter("mvcPath", "/edit_site_navigation_menu.jsp");
    redirectURL.setParameter("redirect", redirect);
    redirectURL.setParameter("siteNavigationMenuId",
            String.valueOf(siteNavigationMenuItem.getSiteNavigationMenuId()));
    redirectURL.setParameter("selectedSiteNavigationMenuItemId",
            String.valueOf(siteNavigationMenuItem.getSiteNavigationMenuItemId()));

    return redirectURL.toString();
}