Example usage for com.liferay.portal.util LayoutURLUtil getLayoutURL

List of usage examples for com.liferay.portal.util LayoutURLUtil getLayoutURL

Introduction

In this page you can find the example usage for com.liferay.portal.util LayoutURLUtil getLayoutURL.

Prototype

public static String getLayoutURL(long groupId, String portletId, ServiceContext serviceContext)
            throws PortalException 

Source Link

Usage

From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

protected String getEntryURL(BlogsEntry entry, ServiceContext serviceContext) throws PortalException {

    String entryURL = GetterUtil.getString(serviceContext.getAttribute("entryURL"));

    if (Validator.isNotNull(entryURL)) {
        return entryURL;
    }//  w  w  w  .jav  a 2s. co  m

    HttpServletRequest request = serviceContext.getRequest();

    if (request == null) {
        return StringPool.BLANK;
    }

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    if (Validator.isNotNull(portletId)) {
        String layoutURL = LayoutURLUtil.getLayoutURL(entry.getGroupId(), portletId, serviceContext);

        if (Validator.isNotNull(layoutURL)) {
            return layoutURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs" + StringPool.SLASH + entry.getEntryId();
        }
    }

    portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE);

    if (Validator.isNull(portletId)) {
        return StringPool.BLANK;
    }

    PortletURL portletURL = PortalUtil.getControlPanelPortletURL(request, portletId,
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry");
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()));

    return portletURL.toString();
}

From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

protected String getPageURL(WikiPage page, ServiceContext serviceContext) throws PortalException {

    HttpServletRequest request = serviceContext.getRequest();

    if (request == null) {
        return StringPool.BLANK;
    }/*from   www  .  j av  a 2  s.com*/

    String layoutFullURL = LayoutURLUtil.getLayoutURL(page.getGroupId(), WikiPortletKeys.WIKI, serviceContext);

    if (Validator.isNotNull(layoutFullURL)) {
        return layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "wiki/" + page.getNodeId() + StringPool.SLASH
                + HttpUtil.encodeURL(WikiEscapeUtil.escapeName(page.getTitle()));
    } else {
        PortletURL portletURL = PortalUtil.getControlPanelPortletURL(request, WikiPortletKeys.WIKI_ADMIN,
                PortletRequest.RENDER_PHASE);

        portletURL.setParameter("mvcRenderCommandName", "/wiki/view_page_activities");
        portletURL.setParameter("nodeId", String.valueOf(page.getNodeId()));
        portletURL.setParameter("title", page.getTitle());

        return portletURL.toString();
    }
}