Skip to content

Commit

Permalink
LPS-39315 CDI Portlet Bridge does not consult the underlying HttpServ…
Browse files Browse the repository at this point in the history
…letRequest during lifecycle incongruities
  • Loading branch information
ngriffin7a authored and brianchandotcom committed Sep 6, 2013
1 parent b9c199a commit 765a4e1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion shared/cdi-portlet-bridge-shared/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<property name="ivy.pom.developer.name" value="Neil Griffin" />
<property name="ivy.pom.name" value="Liferay CDI Portlet Bridge" />

<property name="plugin.version" value="1" />
<property name="plugin.version" value="2" />

<import file="../build-common-shared.xml" />
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.liferay.cdi.portlet.bridge;

import com.liferay.portal.util.PortalUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand All @@ -33,10 +35,12 @@
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
Expand All @@ -49,6 +53,7 @@ public class HttpServletRequestAdapterImpl

public HttpServletRequestAdapterImpl(PortletRequest portletRequest) {
_portletRequest = portletRequest;
_httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
}

@Override
Expand Down Expand Up @@ -79,7 +84,7 @@ public String getAuthType() {
@Override
public String getCharacterEncoding() {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getCharacterEncoding();
}

ClientDataRequest clientDataRequest =
Expand All @@ -91,7 +96,7 @@ public String getCharacterEncoding() {
@Override
public int getContentLength() {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getContentLength();
}

ClientDataRequest clientDataRequest =
Expand All @@ -103,7 +108,7 @@ public int getContentLength() {
@Override
public String getContentType() {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getContentType();
}

ClientDataRequest clientDataRequest =
Expand All @@ -124,34 +129,34 @@ public Cookie[] getCookies() {

@Override
public long getDateHeader(String name) {
throw new UnsupportedOperationException();
return _httpServletRequest.getDateHeader(name);
}

@Override
public DispatcherType getDispatcherType() {
throw new UnsupportedOperationException();
return _httpServletRequest.getDispatcherType();
}

@Override
public String getHeader(String name) {
throw new UnsupportedOperationException();
return _httpServletRequest.getHeader(name);
}

@Override
public Enumeration<String> getHeaderNames() {
throw new UnsupportedOperationException();
return _httpServletRequest.getHeaderNames();
}

@Override
public Enumeration<String> getHeaders(String name) {
throw new UnsupportedOperationException();
return _httpServletRequest.getHeaders(name);
}

@Override
public ServletInputStream getInputStream() {
public ServletInputStream getInputStream() throws IOException {
if (_servletInputStream == null) {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getInputStream();
}

ClientDataRequest clientDataRequest =
Expand All @@ -166,12 +171,12 @@ public ServletInputStream getInputStream() {

@Override
public int getIntHeader(String name) {
throw new UnsupportedOperationException();
return _httpServletRequest.getIntHeader(name);
}

@Override
public String getLocalAddr() {
throw new UnsupportedOperationException();
return _httpServletRequest.getLocalAddr();
}

@Override
Expand Down Expand Up @@ -199,7 +204,7 @@ public int getLocalPort() {
@Override
public String getMethod() {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getMethod();
}

ClientDataRequest clientDataRequest =
Expand Down Expand Up @@ -229,23 +234,23 @@ public String[] getParameterValues(String name) {
}

@Override
public Part getPart(String name) {
throw new UnsupportedOperationException();
public Part getPart(String name) throws IOException, ServletException {
return _httpServletRequest.getPart(name);
}

@Override
public Collection<Part> getParts() {
throw new UnsupportedOperationException();
public Collection<Part> getParts() throws IOException, ServletException {
return _httpServletRequest.getParts();
}

@Override
public String getPathInfo() {
throw new UnsupportedOperationException();
return _httpServletRequest.getPathInfo();
}

@Override
public String getPathTranslated() {
throw new UnsupportedOperationException();
return _httpServletRequest.getPathTranslated();
}

@Override
Expand All @@ -255,18 +260,18 @@ public PortletRequest getPortletRequest() {

@Override
public String getProtocol() {
throw new UnsupportedOperationException();
return _httpServletRequest.getProtocol();
}

@Override
public String getQueryString() {
throw new UnsupportedOperationException();
return _httpServletRequest.getQueryString();
}

@Override
public BufferedReader getReader() throws IOException {
if (!(_portletRequest instanceof ClientDataRequest)) {
throw new UnsupportedOperationException();
return _httpServletRequest.getReader();
}

ClientDataRequest clientDataRequest =
Expand All @@ -277,22 +282,22 @@ public BufferedReader getReader() throws IOException {

@Override
public String getRealPath(String path) {
throw new UnsupportedOperationException();
return _httpServletRequest.getRealPath(path);
}

@Override
public String getRemoteAddr() {
throw new UnsupportedOperationException();
return _httpServletRequest.getRemoteAddr();
}

@Override
public String getRemoteHost() {
throw new UnsupportedOperationException();
return _httpServletRequest.getRemoteHost();
}

@Override
public int getRemotePort() {
throw new UnsupportedOperationException();
return _httpServletRequest.getRemotePort();
}

@Override
Expand All @@ -302,7 +307,7 @@ public String getRemoteUser() {

@Override
public RequestDispatcher getRequestDispatcher(String path) {
throw new UnsupportedOperationException();
return _httpServletRequest.getRequestDispatcher(path);
}

@Override
Expand All @@ -312,12 +317,12 @@ public String getRequestedSessionId() {

@Override
public String getRequestURI() {
throw new UnsupportedOperationException();
return _httpServletRequest.getRequestURI();
}

@Override
public StringBuffer getRequestURL() {
throw new UnsupportedOperationException();
return _httpServletRequest.getRequestURL();
}

@Override
Expand All @@ -337,12 +342,12 @@ public int getServerPort() {

@Override
public ServletContext getServletContext() {
throw new UnsupportedOperationException();
return _httpServletRequest.getServletContext();
}

@Override
public String getServletPath() {
throw new UnsupportedOperationException();
return _httpServletRequest.getServletPath();
}

@Override
Expand Down Expand Up @@ -386,22 +391,22 @@ public boolean isAsyncSupported() {

@Override
public boolean isRequestedSessionIdFromCookie() {
return false;
return _httpServletRequest.isRequestedSessionIdFromCookie();
}

@Override
public boolean isRequestedSessionIdFromUrl() {
return false;
return _httpServletRequest.isRequestedSessionIdFromUrl();
}

@Override
public boolean isRequestedSessionIdFromURL() {
return false;
return _httpServletRequest.isRequestedSessionIdFromURL();
}

@Override
public boolean isRequestedSessionIdValid() {
throw new UnsupportedOperationException();
return _httpServletRequest.isRequestedSessionIdValid();
}

@Override
Expand Down Expand Up @@ -460,6 +465,7 @@ public AsyncContext startAsync(
throw new UnsupportedOperationException();
}

private HttpServletRequest _httpServletRequest;
private PortletRequest _portletRequest;
private CDISession _portletSession;
private ServletInputStream _servletInputStream;
Expand Down

0 comments on commit 765a4e1

Please sign in to comment.