com.liferay.commerce.channel.web.internal.display.context.BaseCommerceChannelDisplayContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.commerce.channel.web
Show all versions of com.liferay.commerce.channel.web
Liferay Commerce Channel Web
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.commerce.channel.web.internal.display.context;
import com.liferay.commerce.product.display.context.helper.CPRequestHelper;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.portlet.LiferayPortletRequest;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.portlet.PortalPreferences;
import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Validator;
import javax.portlet.PortletURL;
import javax.servlet.http.HttpServletRequest;
/**
* @author Alec Sloan
*/
public abstract class BaseCommerceChannelDisplayContext {
public BaseCommerceChannelDisplayContext(
HttpServletRequest httpServletRequest) {
this.httpServletRequest = httpServletRequest;
portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(
this.httpServletRequest);
cpRequestHelper = new CPRequestHelper(httpServletRequest);
liferayPortletRequest = cpRequestHelper.getLiferayPortletRequest();
liferayPortletResponse = cpRequestHelper.getLiferayPortletResponse();
}
public PortletURL getPortletURL() throws PortalException {
PortletURL portletURL = liferayPortletResponse.createRenderURL();
String redirect = ParamUtil.getString(httpServletRequest, "redirect");
if (Validator.isNotNull(redirect)) {
portletURL.setParameter("redirect", redirect);
}
return portletURL;
}
protected final CPRequestHelper cpRequestHelper;
protected final HttpServletRequest httpServletRequest;
protected final LiferayPortletRequest liferayPortletRequest;
protected final LiferayPortletResponse liferayPortletResponse;
protected final PortalPreferences portalPreferences;
}