You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-dev@portals.apache.org by wo...@apache.org on 2014/07/15 05:46:52 UTC
svn commit: r1610570 - in
/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2:
chain/ impl/ servlet/
Author: woonsan
Date: Tue Jul 15 03:46:52 2014
New Revision: 1610570
URL: http://svn.apache.org/r1610570
Log:
APA-63: refines exception handling and clean ups
Added:
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/AbstractProxyCommand.java
- copied, changed from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AbstractProxyCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyContext.java
- copied, changed from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyContext.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyProcessingChain.java
- copied, changed from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyProcessingChain.java
Removed:
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AbstractProxyCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyContext.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyProcessingChain.java
Modified:
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddCookiesToResponseCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeaderToHttpRequestCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeadersToResponseCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/CleanupCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ExecuteHttpClientCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleNotModifiedCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleRedirectionCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpClientCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpRequestCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitializationCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveContentRewriterCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveLocalPathCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveProxyMappingCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveRemoteURICommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/SerializeHttpEntityContentCommand.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/DefaultReverseProxyService.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/DefaultReverseProxyServlet.java
portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/SimpleReverseProxyServlet.java
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddCookiesToResponseCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddCookiesToResponseCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddCookiesToResponseCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddCookiesToResponseCommand.java Tue Jul 15 03:46:52 2014
@@ -16,21 +16,29 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+import java.net.URI;
import java.util.Date;
import java.util.List;
import javax.servlet.http.Cookie;
+import org.apache.commons.lang.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.portals.applications.webcontent2.proxy2.ProxyMapping;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyHttpClient;
public class AddCookiesToResponseCommand extends AbstractProxyCommand
{
+ private static final String REMOTE_BASE_URI = AddCookiesToResponseCommand.class.getName() + ".remote.base.uri";
+
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpClient httpClient = context.getHttpClient();
@@ -40,14 +48,14 @@ public class AddCookiesToResponseCommand
if (!responseCookies.isEmpty())
{
- boolean isSecureRequest = context.getRequestContext().isSecure();
- ProxyMapping resolvedMapping = context.getResolvedMapping();
- String rewrittenCookiePath = context.getRequestContext().getRequestBasePath() + resolvedMapping.getLocalBasePath();
+ final boolean isSecureRequest = context.getRequestContext().isSecure();
+ String reverseCookiePath = null;
for (org.apache.http.cookie.Cookie cookie : responseCookies)
{
String cookieName = cookie.getName();
Cookie responseCookie = new Cookie(cookieName, cookie.getValue());
+ responseCookie.setSecure(isSecureRequest && cookie.isSecure());
responseCookie.setVersion(cookie.getVersion());
responseCookie.setComment(cookie.getComment());
Date expireDate = cookie.getExpiryDate();
@@ -58,10 +66,11 @@ public class AddCookiesToResponseCommand
responseCookie.setMaxAge(maxAgeSeconds);
}
- responseCookie.setSecure(isSecureRequest && cookie.isSecure());
- responseCookie.setVersion(cookie.getVersion());
+ reverseCookiePath = getReverseCookiePath(context, cookie);
- responseCookie.setPath(rewrittenCookiePath);
+ if (reverseCookiePath != null) {
+ responseCookie.setPath(reverseCookiePath);
+ }
context.getRequestContext().addCookie(responseCookie);
}
@@ -71,4 +80,42 @@ public class AddCookiesToResponseCommand
return false;
}
+ protected URI getRemoteBaseAsURI(final ProxyContext context)
+ {
+ URI remoteBaseURI = (URI) context.get(REMOTE_BASE_URI);
+
+ if (remoteBaseURI == null)
+ {
+ remoteBaseURI = (URI) context.put(REMOTE_BASE_URI, URI.create(context.getResolvedMapping().getRemoteBaseURI()));
+ }
+
+ return remoteBaseURI;
+ }
+
+ protected String getReverseCookiePath(final ProxyContext context, final org.apache.http.cookie.Cookie responseCookie)
+ {
+ String responseCookiePath = responseCookie.getPath();
+ URI remoteBaseURI = getRemoteBaseAsURI(context);
+ String remoteBaseURIPath = remoteBaseURI.getPath();
+
+ if (StringUtils.isEmpty(remoteBaseURIPath))
+ {
+ remoteBaseURIPath = "/";
+ }
+
+ ProxyMapping resolvedMapping = context.getResolvedMapping();
+ String localBasePath = context.getRequestContext().getRequestBasePath() + resolvedMapping.getLocalBasePath();
+ String cookiePath = localBasePath;
+
+ if (responseCookiePath != null && responseCookiePath.startsWith(remoteBaseURIPath))
+ {
+ String subPath = StringUtils.removeStart(responseCookiePath.substring(remoteBaseURIPath.length()), "/");
+
+ if (StringUtils.isNotEmpty(subPath)) {
+ cookiePath = StringUtils.removeEnd(localBasePath, "/") + "/" + subPath;
+ }
+ }
+
+ return cookiePath;
+ }
}
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeaderToHttpRequestCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeaderToHttpRequestCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeaderToHttpRequestCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeaderToHttpRequestCommand.java Tue Jul 15 03:46:52 2014
@@ -16,11 +16,15 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
import java.util.Enumeration;
import org.apache.commons.lang.StringUtils;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.protocol.HTTP;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,7 +35,7 @@ public class AddHeaderToHttpRequestComma
private static Logger log = LoggerFactory.getLogger(AddHeaderToHttpRequestCommand.class);
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpRequestBase httpRequest = context.getHttpRequest();
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeadersToResponseCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeadersToResponseCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeadersToResponseCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AddHeadersToResponseCommand.java Tue Jul 15 03:46:52 2014
@@ -16,6 +16,8 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
@@ -23,6 +25,9 @@ import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.protocol.HTTP;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
public class AddHeadersToResponseCommand extends AbstractProxyCommand
@@ -31,7 +36,7 @@ public class AddHeadersToResponseCommand
private String hostHeaderValue;
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpResponse httpResponse = context.getHttpResponse();
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/CleanupCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/CleanupCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/CleanupCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/CleanupCommand.java Tue Jul 15 03:46:52 2014
@@ -16,14 +16,74 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class CleanupCommand extends AbstractProxyCommand
{
+ private static Logger log = LoggerFactory.getLogger(CleanupCommand.class);
+
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
+ HttpRequestBase httpRequest = context.getHttpRequest();
+
+ if (httpRequest != null)
+ {
+ try
+ {
+ httpRequest.abort();
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.warn("Failed to abort http request.", e);
+ }
+ else
+ {
+ log.warn("Failed to abort http request. " + e);
+ }
+ }
+ }
+
+ HttpResponse httpResponse = context.getHttpResponse();
+
+ if (httpResponse != null)
+ {
+ HttpEntity httpEntity = httpResponse.getEntity();
+
+ if (httpEntity != null)
+ {
+ try
+ {
+ httpEntity.consumeContent();
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.warn("Failed to consume http entity.", e);
+ }
+ else
+ {
+ log.warn("Failed to consume http entity. " + e);
+ }
+ }
+ }
+ }
+
return false;
}
}
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ExecuteHttpClientCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ExecuteHttpClientCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ExecuteHttpClientCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ExecuteHttpClientCommand.java Tue Jul 15 03:46:52 2014
@@ -16,9 +16,14 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -29,7 +34,7 @@ public class ExecuteHttpClientCommand ex
private static Logger log = LoggerFactory.getLogger(ExecuteHttpClientCommand.class);
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpRequestBase httpRequest = context.getHttpRequest();
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleNotModifiedCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleNotModifiedCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleNotModifiedCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleNotModifiedCommand.java Tue Jul 15 03:46:52 2014
@@ -16,10 +16,15 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpResponse;
import org.apache.http.protocol.HTTP;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +35,7 @@ public class HandleNotModifiedCommand ex
private static Logger log = LoggerFactory.getLogger(HandleNotModifiedCommand.class);
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpResponse httpResponse = context.getHttpResponse();
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleRedirectionCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleRedirectionCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleRedirectionCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/HandleRedirectionCommand.java Tue Jul 15 03:46:52 2014
@@ -16,14 +16,16 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
import java.net.URI;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
-import org.apache.portals.applications.webcontent2.proxy.HttpReverseProxyConstants;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +36,7 @@ public class HandleRedirectionCommand ex
private static Logger log = LoggerFactory.getLogger(HandleRedirectionCommand.class);
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpResponse httpResponse = context.getHttpResponse();
@@ -48,7 +50,7 @@ public class HandleRedirectionCommand ex
}
String location = null;
- Header locationHeader = httpResponse.getFirstHeader(HttpReverseProxyConstants.HTTP_HEADER_LOCATION);
+ Header locationHeader = httpResponse.getFirstHeader("Location");
if (locationHeader != null)
{
@@ -63,7 +65,7 @@ public class HandleRedirectionCommand ex
// According to rfc2616, "Location" header value must be an absolute URI.
// However, in case it is not, prepend the host URI of the proxy target URL.
if (location.startsWith("/")) {
- URI targetURI = new URI(context.getRemoteURI());
+ URI targetURI = URI.create(context.getRemoteURI());
String scheme = targetURI.getScheme();
int port = targetURI.getPort();
StringBuilder uriBuilder = new StringBuilder(40).append(targetURI.getScheme()).append("://").append(targetURI.getHost());
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpClientCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpClientCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpClientCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpClientCommand.java Tue Jul 15 03:46:52 2014
@@ -16,10 +16,15 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import org.apache.http.client.params.ClientPNames;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.params.HttpParams;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyHttpClient;
@@ -36,7 +41,7 @@ public class InitHttpClientCommand exten
private HttpRoutePlanner httpRoutePlanner;
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
ProxyHttpClient httpClient = new ProxyHttpClient(clientConnectionManager, httpClientParams);
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpRequestCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpRequestCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpRequestCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitHttpRequestCommand.java Tue Jul 15 03:46:52 2014
@@ -16,6 +16,8 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.math.NumberUtils;
@@ -31,13 +33,15 @@ import org.apache.http.client.methods.Ht
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.protocol.HTTP;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
public class InitHttpRequestCommand extends AbstractProxyCommand
{
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpRequestBase httpRequest = null;
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitializationCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitializationCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitializationCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/InitializationCommand.java Tue Jul 15 03:46:52 2014
@@ -16,6 +16,11 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,7 +32,7 @@ public class InitializationCommand exten
private static Logger log = LoggerFactory.getLogger(InitializationCommand.class);
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
log.debug("Reverse-proxying {}", context.getRequestContext().getPathInfo());
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveContentRewriterCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveContentRewriterCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveContentRewriterCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveContentRewriterCommand.java Tue Jul 15 03:46:52 2014
@@ -16,13 +16,18 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import org.apache.portals.applications.webcontent2.proxy2.ProxyMapping;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
public class ResolveContentRewriterCommand extends AbstractProxyCommand
{
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
ProxyMapping resolvedMapping = context.getResolvedMapping();
// TODO:
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveLocalPathCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveLocalPathCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveLocalPathCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveLocalPathCommand.java Tue Jul 15 03:46:52 2014
@@ -16,13 +16,19 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
+
public class ResolveLocalPathCommand extends AbstractProxyCommand
{
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
String localPath = context.getRequestContext().getPathInfo();
context.setLocalPath(localPath);
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveProxyMappingCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveProxyMappingCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveProxyMappingCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveProxyMappingCommand.java Tue Jul 15 03:46:52 2014
@@ -16,10 +16,14 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletResponse;
import org.apache.portals.applications.webcontent2.proxy2.ProxyMapping;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
public class ResolveProxyMappingCommand extends AbstractProxyCommand
{
@@ -27,7 +31,7 @@ public class ResolveProxyMappingCommand
private ProxyMapping [] proxyMappings;
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
final String localPath = context.getLocalPath();
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveRemoteURICommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveRemoteURICommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveRemoteURICommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ResolveRemoteURICommand.java Tue Jul 15 03:46:52 2014
@@ -16,10 +16,14 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
+
import javax.servlet.http.HttpServletResponse;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
import org.apache.portals.applications.webcontent2.proxy2.URICleaner;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
public class ResolveRemoteURICommand extends AbstractProxyCommand
@@ -28,7 +32,7 @@ public class ResolveRemoteURICommand ext
private URICleaner uriCleaner;
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
String localPath = context.getLocalPath();
String remoteURI = context.getResolvedMapping().resolveRemoteFromLocal(localPath);
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/SerializeHttpEntityContentCommand.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/SerializeHttpEntityContentCommand.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/SerializeHttpEntityContentCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/SerializeHttpEntityContentCommand.java Tue Jul 15 03:46:52 2014
@@ -16,13 +16,17 @@
*/
package org.apache.portals.applications.webcontent2.proxy2.chain;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
import org.apache.portals.applications.webcontent2.proxy2.impl.HttpEntitySource;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyContext;
import org.apache.portals.applications.webcontent2.rewriter2.ContentRewriter;
import org.apache.portals.applications.webcontent2.rewriter2.Sink;
import org.apache.portals.applications.webcontent2.rewriter2.Source;
@@ -32,7 +36,7 @@ public class SerializeHttpEntityContentC
{
@Override
- protected boolean executeInternal(final ProxyContext context) throws Exception
+ protected boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException
{
HttpEntity httpEntity = null;
Copied: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/AbstractProxyCommand.java (from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AbstractProxyCommand.java)
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/AbstractProxyCommand.java?p2=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/AbstractProxyCommand.java&p1=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AbstractProxyCommand.java&r1=1610566&r2=1610570&rev=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/AbstractProxyCommand.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/AbstractProxyCommand.java Tue Jul 15 03:46:52 2014
@@ -14,40 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.portals.applications.webcontent2.proxy2.chain;
+package org.apache.portals.applications.webcontent2.proxy2.impl;
+
+import java.io.IOException;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
public abstract class AbstractProxyCommand implements Command
{
- private static Logger log = LoggerFactory.getLogger(AbstractProxyCommand.class);
-
- private Boolean executionResult;
+ private Boolean forcedResult;
public void initialize()
{
}
- public final boolean execute(Context context)
+ public final boolean execute(Context context) throws ReverseProxyException, IOException
{
- boolean savedResult = false;
-
- try
- {
- savedResult = executeInternal((ProxyContext) context);
- }
- catch (Exception e)
- {
- log.error("Failed to execute command processing " + ((ProxyContext) context).getLocalPath(), e);
- }
+ boolean savedResult = executeInternal((ProxyContext) context);
- if (executionResult != null)
+ if (forcedResult != null)
{
- return executionResult.booleanValue();
+ return forcedResult.booleanValue();
}
else
{
@@ -55,20 +45,20 @@ public abstract class AbstractProxyComma
}
}
- protected abstract boolean executeInternal(final ProxyContext context) throws Exception;
+ protected abstract boolean executeInternal(final ProxyContext context) throws ReverseProxyException, IOException;
public void destroy()
{
}
- public boolean isExecutionResult()
+ public Boolean getForcedResult()
{
- return executionResult;
+ return forcedResult;
}
- public void setExecutionResult(boolean executionResult)
+ public void setForcedResult(Boolean forcedResult)
{
- this.executionResult = executionResult;
+ this.forcedResult = forcedResult;
}
}
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/DefaultReverseProxyService.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/DefaultReverseProxyService.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/DefaultReverseProxyService.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/DefaultReverseProxyService.java Tue Jul 15 03:46:52 2014
@@ -1,14 +1,13 @@
package org.apache.portals.applications.webcontent2.proxy2.impl;
import java.io.IOException;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.chain.Command;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyService;
-import org.apache.portals.applications.webcontent2.proxy2.chain.ProxyContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,24 +16,56 @@ public class DefaultReverseProxyService
private static Logger log = LoggerFactory.getLogger(DefaultReverseProxyService.class);
- private final Command proxyServiceCommand;
+ private final ProxyProcessingChain proxyProcessingChain;
- public DefaultReverseProxyService(final Command proxyServiceCommand)
+ public DefaultReverseProxyService(final ProxyProcessingChain proxyProcessingChain)
{
- this.proxyServiceCommand = proxyServiceCommand;
+ this.proxyProcessingChain = proxyProcessingChain;
}
public void invoke(HttpServletRequest request, HttpServletResponse response) throws ReverseProxyException, IOException
{
- try
+ ProxyContext context = new ProxyContext();
+ context.setRequestContext(new ServletRequestContext(request, response));
+ proxyProcessingChain.execute(context);
+
+ if (context.hasException())
+ {
+ logExceptions(context.getExceptions());
+
+ Exception e = context.getExceptions().get(0);
+
+ if (e instanceof ReverseProxyException)
+ {
+ throw (ReverseProxyException) e;
+ }
+ else if (e instanceof IOException)
+ {
+ throw (IOException) e;
+ }
+ else
+ {
+ throw new ReverseProxyException(e);
+ }
+ }
+ }
+
+ // TODO: use location-aware logger
+ protected void logExceptions(List<Exception> exceptions)
+ {
+ if (log.isDebugEnabled())
{
- ProxyContext context = new ProxyContext();
- context.setRequestContext(new ServletRequestContext(request, response));
- proxyServiceCommand.execute(context);
+ for (Exception ex : exceptions)
+ {
+ log.error("Reverse proxy service error.", ex);
+ }
}
- catch (Exception e)
+ else
{
- log.error("Failed to execute proxy service for " + request.getRequestURI(), e);
+ for (Exception ex : exceptions)
+ {
+ log.error("Reverse proxy service error. " + ex);
+ }
}
}
}
Copied: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyContext.java (from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyContext.java)
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyContext.java?p2=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyContext.java&p1=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyContext.java&r1=1610566&r2=1610570&rev=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyContext.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyContext.java Tue Jul 15 03:46:52 2014
@@ -14,8 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.portals.applications.webcontent2.proxy2.chain;
+package org.apache.portals.applications.webcontent2.proxy2.impl;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import org.apache.commons.chain.impl.ContextBase;
@@ -40,6 +42,8 @@ public class ProxyContext extends Contex
private HttpResponse httpResponse;
private ContentRewriter contentRewriter;
+ private List<Exception> exceptions;
+
public ProxyContext()
{
super();
@@ -130,4 +134,23 @@ public class ProxyContext extends Contex
this.contentRewriter = contentRewriter;
}
+ public boolean hasException()
+ {
+ return (exceptions != null && !exceptions.isEmpty());
+ }
+
+ public void addException(Exception e)
+ {
+ if (exceptions == null)
+ {
+ exceptions = new LinkedList<Exception>();
+ }
+
+ exceptions.add(e);
+ }
+
+ public List<Exception> getExceptions()
+ {
+ return exceptions;
+ }
}
Copied: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyProcessingChain.java (from r1610566, portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyProcessingChain.java)
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyProcessingChain.java?p2=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyProcessingChain.java&p1=portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyProcessingChain.java&r1=1610566&r2=1610570&rev=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/chain/ProxyProcessingChain.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/impl/ProxyProcessingChain.java Tue Jul 15 03:46:52 2014
@@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.portals.applications.webcontent2.proxy2.chain;
+package org.apache.portals.applications.webcontent2.proxy2.impl;
+import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -23,14 +24,11 @@ import java.util.List;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
import org.apache.commons.chain.impl.ChainBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.portals.applications.webcontent2.proxy2.ReverseProxyException;
public class ProxyProcessingChain extends ChainBase
{
- private Logger log = LoggerFactory.getLogger(ProxyProcessingChain.class);
-
public ProxyProcessingChain()
{
super();
@@ -52,7 +50,7 @@ public class ProxyProcessingChain extend
}
@Override
- public boolean execute(Context context) throws Exception
+ public boolean execute(Context context) throws ReverseProxyException, IOException
{
try
{
@@ -60,7 +58,7 @@ public class ProxyProcessingChain extend
}
catch (Exception e)
{
- log.error("Failed to execute chain.", e);
+ ((ProxyContext) context).addException(e);
}
return false;
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/DefaultReverseProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/DefaultReverseProxyServlet.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/DefaultReverseProxyServlet.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/DefaultReverseProxyServlet.java Tue Jul 15 03:46:52 2014
@@ -86,7 +86,15 @@ public class DefaultReverseProxyServlet
{
if (e.getStatusCode() > 0)
{
- log.error("Response proxy processing exception occurred.", e);
+ if (log.isDebugEnabled())
+ {
+ log.error("Response proxy processing exception occurred.", e);
+ }
+ else
+ {
+ log.error("Response proxy processing exception occurred. " + e);
+ }
+
response.sendError(e.getStatusCode(), e.getLocalizedMessage());
}
else
@@ -94,6 +102,14 @@ public class DefaultReverseProxyServlet
throw new ServletException(e);
}
}
+ catch (IOException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw new ServletException(e);
+ }
}
}
Modified: portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/SimpleReverseProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/SimpleReverseProxyServlet.java?rev=1610570&r1=1610569&r2=1610570&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/SimpleReverseProxyServlet.java (original)
+++ portals/applications/webcontent/trunk/reverse-proxy/src/main/java/org/apache/portals/applications/webcontent2/proxy2/servlet/SimpleReverseProxyServlet.java Tue Jul 15 03:46:52 2014
@@ -31,7 +31,6 @@ import org.apache.http.impl.conn.tsccm.T
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.portals.applications.webcontent2.proxy2.ProxyMapping;
-import org.apache.portals.applications.webcontent2.proxy2.chain.AbstractProxyCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.AddCookiesToResponseCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.AddHeaderToHttpRequestCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.AddHeadersToResponseCommand;
@@ -42,13 +41,14 @@ import org.apache.portals.applications.w
import org.apache.portals.applications.webcontent2.proxy2.chain.InitHttpClientCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.InitHttpRequestCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.InitializationCommand;
-import org.apache.portals.applications.webcontent2.proxy2.chain.ProxyProcessingChain;
import org.apache.portals.applications.webcontent2.proxy2.chain.ResolveContentRewriterCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.ResolveLocalPathCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.ResolveProxyMappingCommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.ResolveRemoteURICommand;
import org.apache.portals.applications.webcontent2.proxy2.chain.SerializeHttpEntityContentCommand;
+import org.apache.portals.applications.webcontent2.proxy2.impl.AbstractProxyCommand;
import org.apache.portals.applications.webcontent2.proxy2.impl.DefaultReverseProxyService;
+import org.apache.portals.applications.webcontent2.proxy2.impl.ProxyProcessingChain;
import org.apache.portals.applications.webcontent2.proxy2.impl.SimpleProxyMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;