Example usage for com.liferay.portal.kernel.portlet LiferayPortletResponse getProperties

List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletResponse getProperties

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet LiferayPortletResponse getProperties.

Prototype

public Map<String, String[]> getProperties();

Source Link

Usage

From source file:com.liferay.portlet.InvokerPortletImpl.java

License:Open Source License

protected void invoke(LiferayPortletRequest portletRequest, LiferayPortletResponse portletResponse,
        String lifecycle, List<? extends PortletFilter> filters) throws IOException, PortletException {

    FilterChain filterChain = new FilterChainImpl(_portlet, filters);

    if (_portletConfigImpl.isWARFile()) {
        String invokerPortletName = _portletConfigImpl.getInitParameter(INIT_INVOKER_PORTLET_NAME);

        if (invokerPortletName == null) {
            invokerPortletName = _portletConfigImpl.getPortletName();
        }/* w  ww  . ja v a  2s .  c  om*/

        String path = StringPool.SLASH + invokerPortletName + "/invoke";

        RequestDispatcher requestDispatcher = _portletContextImpl.getServletContext()
                .getRequestDispatcher(path);

        HttpServletRequest request = portletRequest.getHttpServletRequest();
        HttpServletResponse response = portletResponse.getHttpServletResponse();

        request.setAttribute(JavaConstants.JAVAX_PORTLET_PORTLET, _portlet);
        request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle);
        request.setAttribute(PortletServlet.PORTLET_SERVLET_FILTER_CHAIN, filterChain);

        try {

            // Resource phase must be a forward because includes do not
            // allow you to specify the content type or headers

            if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {
                requestDispatcher.forward(request, response);
            } else {
                requestDispatcher.include(request, response);
            }
        } catch (ServletException se) {
            Throwable cause = se.getRootCause();

            if (cause instanceof PortletException) {
                throw (PortletException) cause;
            }

            throw new PortletException(cause);
        }
    } else {
        PortletFilterUtil.doFilter(portletRequest, portletResponse, lifecycle, filterChain);
    }

    portletResponse.transferMarkupHeadElements();

    Map<String, String[]> properties = portletResponse.getProperties();

    if ((properties != null) && (properties.size() > 0)) {
        if (_expCache != null) {
            String[] expCache = properties.get(RenderResponse.EXPIRATION_CACHE);

            if ((expCache != null) && (expCache.length > 0) && (expCache[0] != null)) {

                _expCache = new Integer(GetterUtil.getInteger(expCache[0]));
            }
        }
    }
}