Example usage for com.liferay.portal.kernel.servlet HttpHeaders LOCATION

List of usage examples for com.liferay.portal.kernel.servlet HttpHeaders LOCATION

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet HttpHeaders LOCATION.

Prototype

String LOCATION

To view the source code for com.liferay.portal.kernel.servlet HttpHeaders LOCATION.

Click Source Link

Usage

From source file:com.liferay.marketplace.store.web.internal.portlet.RemoteMVCPortlet.java

License:Open Source License

protected void remoteProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

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

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, getServerPortletURL());

    setRequestParameters(actionRequest, actionResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "1");
    addOAuthParameter(oAuthRequest, "p_p_state", WindowState.NORMAL.toString());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    if (response.getCode() == HttpServletResponse.SC_FOUND) {
        String redirectLocation = response.getHeader(HttpHeaders.LOCATION);

        actionResponse.sendRedirect(redirectLocation);
    } else {/*from   w  w  w .jav a2s.  c o m*/
        HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse);

        httpServletResponse.setContentType(response.getHeader(HttpHeaders.CONTENT_TYPE));

        ServletResponseUtil.write(httpServletResponse, response.getStream());
    }
}