Search in sources :

Example 1 with PortletResponseWrapper

use of javax.portlet.filter.PortletResponseWrapper in project liferay-faces-bridge-impl by liferay.

the class PortletContainerDetectorUtil method isPlutoPortletResponse.

/**
 * Determines whether or not the specified {@link javax.portlet.PortletResponse} is one created by Pluto Portal. If
 * the specified {@link javax.portlet.PortletResponse} is an instance of {@link
 * javax.portlet.filter.PortletResponseWrapper} then it will work with the wrapped {@link
 * javax.portlet.PortletResponse}.
 *
 * @param   portletResponse  The current {@link javax.portlet.PortletResponse}.
 *
 * @return  true if the specified portletResponse was created by Pluto.
 */
public static boolean isPlutoPortletResponse(PortletResponse portletResponse) {
    if (portletResponse != null) {
        while (portletResponse instanceof PortletResponseWrapper) {
            PortletResponseWrapper portletResponseWrapper = (PortletResponseWrapper) portletResponse;
            portletResponse = portletResponseWrapper.getResponse();
        }
        return portletResponse.getClass().getName().startsWith("org.apache.pluto");
    } else {
        return false;
    }
}
Also used : PortletResponseWrapper(javax.portlet.filter.PortletResponseWrapper)

Example 2 with PortletResponseWrapper

use of javax.portlet.filter.PortletResponseWrapper in project liferay-faces-bridge-ext by liferay.

the class PortletRequestDispatcherBridgeLiferayImpl method include.

@Override
public void include(PortletRequest portletRequest, PortletResponse portletResponse) throws PortletException, IOException {
    boolean unwrapRequest = false;
    PortletSession portletSession = portletRequest.getPortletSession();
    PortletContext portletContext = portletSession.getPortletContext();
    ProductFactory productFactory = (ProductFactory) BridgeFactoryFinder.getFactory(portletContext, ProductFactory.class);
    final Product LIFERAY_PORTAL = productFactory.getProductInfo(Product.Name.LIFERAY_PORTAL);
    final int LIFERAY_PORTAL_MAJOR_VERSION = LIFERAY_PORTAL.getMajorVersion();
    // For more info, see https://issues.liferay.com/browse/LPS-3311
    if (LIFERAY_PORTAL_MAJOR_VERSION < 6) {
        unwrapRequest = true;
    } else // https://github.com/liferay/liferay-portal/commit/093dabbb252e2bba5404cddbcb600d787ef0b010
    if (LIFERAY_PORTAL_MAJOR_VERSION == 6) {
        final int LIFERAY_PORTAL_MINOR_VERSION = LIFERAY_PORTAL.getMinorVersion();
        if (LIFERAY_PORTAL_MINOR_VERSION == 0) {
            unwrapRequest = true;
        } else if (LIFERAY_PORTAL_MINOR_VERSION == 1) {
            final int LIFERAY_PORTAL_PATCH_VERSION = LIFERAY_PORTAL.getPatchVersion();
            // CE
            if (LIFERAY_PORTAL_PATCH_VERSION < 10) {
                unwrapRequest = (LIFERAY_PORTAL_PATCH_VERSION < 2);
            } else // EE
            if (LIFERAY_PORTAL_PATCH_VERSION < 30) {
                unwrapRequest = true;
            }
        }
    }
    if (unwrapRequest) {
        portletRequest = unwrapPortletRequest(portletRequest);
    }
    // PortletResponseWrapper.
    if ((portletResponse instanceof HttpServletResponseWrapper) || (portletResponse instanceof PortletResponseWrapper)) {
        portletResponse = unwrapPortletResponse(portletResponse);
    }
    super.include(portletRequest, portletResponse);
}
Also used : ProductFactory(com.liferay.faces.util.product.ProductFactory) PortletSession(javax.portlet.PortletSession) HttpServletResponseWrapper(javax.servlet.http.HttpServletResponseWrapper) Product(com.liferay.faces.util.product.Product) PortletContext(javax.portlet.PortletContext) PortletResponseWrapper(javax.portlet.filter.PortletResponseWrapper)

Aggregations

PortletResponseWrapper (javax.portlet.filter.PortletResponseWrapper)2 Product (com.liferay.faces.util.product.Product)1 ProductFactory (com.liferay.faces.util.product.ProductFactory)1 PortletContext (javax.portlet.PortletContext)1 PortletSession (javax.portlet.PortletSession)1 HttpServletResponseWrapper (javax.servlet.http.HttpServletResponseWrapper)1