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

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

Introduction

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

Prototype

public static String getPathMain() 

Source Link

Usage

From source file:com.liferay.bookmarks.asset.BookmarksEntryAssetRenderer.java

License:Open Source License

@Override
public String getURLView(LiferayPortletResponse liferayPortletResponse, WindowState windowState)
        throws Exception {

    return PortalUtil.getPathMain() + "/bookmarks/open_entry?entryId=" + _entry.getEntryId();
}

From source file:com.liferay.document.library.web.internal.portlet.action.GetFileActionHelper.java

License:Open Source License

protected void processPrincipalException(Throwable t, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    User user = permissionChecker.getUser();

    if ((user != null) && !user.isDefaultUser()) {
        PortalUtil.sendError(HttpServletResponse.SC_UNAUTHORIZED, (Exception) t, request, response);

        return;/*from  w ww  .  j av a  2  s . c o m*/
    }

    String redirect = PortalUtil.getPathMain() + "/portal/login";

    String currentURL = PortalUtil.getCurrentURL(request);

    redirect = HttpUtil.addParameter(redirect, "redirect", currentURL);

    response.sendRedirect(redirect);
}

From source file:com.liferay.exportimport.messaging.BasePublisherMessageListener.java

License:Open Source License

protected void initThreadLocals(long userId, Map<String, String[]> parameterMap) throws PortalException {

    User user = UserLocalServiceUtil.getUserById(userId);

    CompanyThreadLocal.setCompanyId(user.getCompanyId());

    PrincipalThreadLocal.setName(userId);

    PermissionChecker permissionChecker = null;

    try {/* w  w w  .j  av  a2  s . c  o m*/
        permissionChecker = PermissionCheckerFactoryUtil.create(user);
    } catch (Exception e) {
        throw new SystemException("Unable to initialize thread locals because an error occured "
                + "when creating a permission checker for user " + userId, e);
    }

    PermissionThreadLocal.setPermissionChecker(permissionChecker);

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setCompanyId(user.getCompanyId());
    serviceContext.setPathMain(PortalUtil.getPathMain());
    serviceContext.setSignedIn(!user.isDefaultUser());
    serviceContext.setUserId(user.getUserId());

    Map<String, Serializable> attributes = new HashMap<>();

    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
        String param = entry.getKey();
        String[] values = entry.getValue();

        if (ArrayUtil.isNotEmpty(values)) {
            if (values.length == 1) {
                attributes.put(param, values[0]);
            } else {
                attributes.put(param, values);
            }
        }
    }

    serviceContext.setAttributes(attributes);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);
}

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 {/* w  ww.  j  a v  a2 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   www  . j  ava2 s.  c o m
 * @return The URI
 */
protected final String getReturnRequestUri(final HttpServletRequest request) {
    return PortalUtil.getPortalURL(request) + PortalUtil.getPathMain() + REDIRECT_URI;
}

From source file:com.liferay.subscription.web.internal.util.UnsubscribeHooks.java

License:Open Source License

private String _getUnsubscribeURL(User user, Ticket ticket) {
    StringBuilder sb = new StringBuilder();

    sb.append(_subscriptionSender.getContextAttribute("[$PORTAL_URL$]"));
    sb.append(PortalUtil.getPathMain());
    sb.append("/portal/unsubscribe?key=");
    sb.append(ticket.getKey());/*w w w.j av  a2 s .c o  m*/
    sb.append("&userId=");
    sb.append(user.getUserId());

    return sb.toString();
}