Example usage for com.liferay.portal.kernel.util PortalUtil getPortalURL

List of usage examples for com.liferay.portal.kernel.util PortalUtil getPortalURL

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortalUtil getPortalURL.

Prototype

public static String getPortalURL(ThemeDisplay themeDisplay) throws PortalException 

Source Link

Usage

From source file:com.liferay.blogs.web.internal.portlet.action.ViewEntryMVCRenderCommand.java

License:Open Source License

@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {

    long assetCategoryId = ParamUtil.getLong(renderRequest, "categoryId");
    String assetCategoryName = ParamUtil.getString(renderRequest, "tag");

    if ((assetCategoryId > 0) || Validator.isNotNull(assetCategoryName)) {
        return "/blogs/view.jsp";
    }/* w w  w . ja  v a 2 s .  co  m*/

    try {
        ActionUtil.getEntry(renderRequest);

        if (PropsValues.BLOGS_PINGBACK_ENABLED) {
            BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

            if ((entry != null) && entry.isAllowPingbacks()) {
                HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

                response.addHeader("X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
            }
        }
    } catch (Exception e) {
        if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass());

            return "/blogs/error.jsp";
        } else {
            throw new PortletException(e);
        }
    }

    return "/blogs/view_entry.jsp";
}

From source file:com.liferay.exportimport.content.processor.base.BaseTextExportImportContentProcessor.java

License:Open Source License

protected void validateDLReferences(long groupId, String content) throws PortalException {

    String portalURL = PortalUtil.getPathContext();

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    if ((serviceContext != null) && (serviceContext.getThemeDisplay() != null)) {

        ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();

        portalURL = PortalUtil.getPortalURL(themeDisplay) + PortalUtil.getPathContext();
    }/*from ww  w  .java  2 s  .co  m*/

    String[] patterns = { portalURL.concat("/c/document_library/get_file?"), portalURL.concat("/documents/"),
            portalURL.concat("/image/image_gallery?") };

    String[] completePatterns = new String[patterns.length];

    long[] companyIds = PortalUtil.getCompanyIds();

    for (long companyId : companyIds) {
        Company company = CompanyLocalServiceUtil.getCompany(companyId);

        String webId = company.getWebId();

        int i = 0;

        for (String pattern : patterns) {
            completePatterns[i] = webId.concat(pattern);

            i++;
        }

        int beginPos = -1;
        int endPos = content.length();

        while (true) {
            beginPos = StringUtil.lastIndexOfAny(content, completePatterns, endPos);

            if (beginPos == -1) {
                break;
            }

            Map<String, String[]> dlReferenceParameters = getDLReferenceParameters(groupId, content,
                    beginPos + portalURL.length() + webId.length(), endPos);

            FileEntry fileEntry = getFileEntry(dlReferenceParameters);

            if (fileEntry == null) {
                throw new NoSuchFileEntryException();
            }

            endPos = beginPos - 1;
        }
    }
}

From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java

License:Open Source License

@Override
public ServiceContext getServiceContext() {

    ServiceContext serviceContext = new ServiceContext();
    ThemeDisplay themeDisplay = getThemeDisplay();
    serviceContext.setCompanyId(themeDisplay.getCompanyId());
    serviceContext.setLanguageId(themeDisplay.getLanguageId());
    serviceContext.setPathMain(PortalUtil.getPathMain());
    serviceContext.setPlid(themeDisplay.getPlid());
    serviceContext.setPortalURL(PortalUtil.getPortalURL(getPortletRequest()));
    serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId());
    serviceContext.setUserId(themeDisplay.getUserId());

    try {/* ww w. j  av a 2 s .c o m*/
        serviceContext.setLayoutFullURL(PortalUtil.getLayoutFullURL(themeDisplay));
        serviceContext.setLayoutURL(PortalUtil.getLayoutURL(themeDisplay));
        serviceContext.setUserDisplayURL(themeDisplay.getUser().getDisplayURL(themeDisplay));
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

    return serviceContext;
}

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

License:Apache License

/**
 * Retrieves the URI to send the user after authentication on IAM.
 *
 * @param request The servlet request/*from   w ww .j a v  a 2s  .co  m*/
 * @return The URI
 */
protected final String getReturnRequestUri(final HttpServletRequest request) {
    return PortalUtil.getPortalURL(request) + PortalUtil.getPathMain() + REDIRECT_URI;
}