Update of
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl
In directory
james.mmbase.org:/tmp/cvs-serv25993/cmsc/portal/src/java/com/finalist/cmsc/portalImpl
Modified Files:
Tag: v1_3
PortalErrorServlet.java
Log Message:
Backported some logic from the 1.4 which handles error pages for applications
deployed in the root of the webserver.
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl
Index: PortalErrorServlet.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl/PortalErrorServlet.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -b -r1.6 -r1.6.2.1
--- PortalErrorServlet.java 8 Jun 2007 14:58:07 -0000 1.6
+++ PortalErrorServlet.java 18 Feb 2008 11:12:13 -0000 1.6.2.1
@@ -12,6 +12,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
+import java.util.regex.Pattern;
import javax.servlet.*;
import javax.servlet.http.*;
@@ -39,6 +40,9 @@
public static final String ERROR_EXCEPTION =
"javax.servlet.error.exception";
public static final String ERROR_REQUEST_URI =
"javax.servlet.error.request_uri";
+ private static final String SIMPLE_404 =
"(.*/editors/.*[.](jpg$|gif$|png$|css$|js$|ico$))|robots.txt";
+ private final Pattern excludePattern = Pattern.compile(SIMPLE_404);
+
protected ServletConfig config;
protected static final String[] vars = {
@@ -58,9 +62,32 @@
public void service(HttpServletRequest request, HttpServletResponse
response) throws IOException {
log.debug("===>PortalErrorServlet.doGet START!");
+ // fail fast on static resources which are in the editors
+ if (request.getHeader("Referer") != null) {
+ int statusCode = (Integer) request.getAttribute(ERROR_STATUS_CODE);
+ if (statusCode == 404) {
+ String path = (String) request.getAttribute(ERROR_REQUEST_URI);
+ if (path != null) {
+ if (excludePattern != null &&
excludePattern.matcher(path).find()) {
+ return;
+ }
+ }
+ }
+ }
+
if (PortletContainerFactory.getPortletContainer().isInitialized()) {
+ String errorUri = (String)
request.getAttribute(ERROR_REQUEST_URI);
+ if (errorUri != null) {
+ if (request.getContextPath() != null &&
!request.getContextPath().equals("/")) {
+ errorUri =
errorUri.substring(request.getContextPath().length());
+ }
+ }
+ // The incoming request has a servletPath of /PortalError. The
mapped url to this servlet.
+ // Pretend it is the uri which has the error in itss
+ HttpServletRequest errorUriRequest = new
ErrorHttpServletRequest(request, errorUri);
+
// PortalRegistry reg = PortalRegistry.getPortalRegistry(request);
- PortalEnvironment env = new PortalEnvironment(request, response,
config);
+ PortalEnvironment env = new PortalEnvironment(errorUriRequest,
response, config);
PortalURL currentURL = env.getRequestedPortalURL();
try {
String path = extractPath(request, currentURL);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs