tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r353887 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/core/ApplicationContext.java webapps/docs/changelog.xml
Date Sun, 04 Dec 2005 18:41:24 GMT
Author: markt
Date: Sun Dec  4 10:41:19 2005
New Revision: 353887

URL: http://svn.apache.org/viewcvs?rev=353887&view=rev
Log:
Fix bug 13040. getContext() now allows retrieval of an external context that is
a sub-context of the current context.
Ported from TC4.

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java?rev=353887&r1=353886&r2=353887&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationContext.java
Sun Dec  4 10:41:19 2005
@@ -208,22 +208,9 @@
         if ((uri == null) || (!uri.startsWith("/")))
             return (null);
 
-        // Return the current context if requested
-        String contextPath = context.getPath();
-        if (!contextPath.endsWith("/"))
-            contextPath = contextPath + "/";
-
-        if (((contextPath.length() > 1) && (uri.startsWith(contextPath))) ||
-            ((contextPath.equals("/")) && (uri.equals("/")))) {
-            return (this);
-        }
-
-        // Return other contexts only if allowed
-        if (!context.getCrossContext())
-            return (null);
+        Context child = null;
         try {
             Host host = (Host) context.getParent();
-            Context child = null;
             String mapuri = uri;
             while (true) {
                 child = (Context) host.findChild(mapuri);
@@ -234,17 +221,23 @@
                     break;
                 mapuri = mapuri.substring(0, slash);
             }
-            if (child == null) {
-                child = (Context) host.findChild("");
-            }
-            if (child != null)
-                return (child.getServletContext());
-            else
-                return (null);
         } catch (Throwable t) {
             return (null);
         }
 
+        if (child == null)
+            return (null);
+
+        if (context.getCrossContext()) {
+            // If crossContext is enabled, can always return the context
+            return child.getServletContext();
+        } else if (child == context) {
+            // Can still return the current context
+            return context.getServletContext();
+        } else {
+            // Nothing to return
+            return (null);
+        }
     }
 
 
@@ -929,28 +922,6 @@
             }
         }
         parameters = results;
-
-    }
-
-
-    /**
-     * List resource paths (recursively), and store all of them in the given
-     * Set.
-     */
-    private static void listPaths(Set set, DirContext resources, String path)
-        throws NamingException {
-
-        Enumeration childPaths = resources.listBindings(path);
-        while (childPaths.hasMoreElements()) {
-            Binding binding = (Binding) childPaths.nextElement();
-            String name = binding.getName();
-            String childPath = path + "/" + name;
-            set.add(childPath);
-            Object object = binding.getObject();
-            if (object instanceof DirContext) {
-                listPaths(set, resources, childPath);
-            }
-        }
 
     }
 

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=353887&r1=353886&r2=353887&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Sun Dec  4 10:41:19 2005
@@ -22,6 +22,10 @@
 
   <subsection name="Catalina">
     <changelog>
+      <fix>
+        <bug>13040</bug>Fix getContext() when used to obtain a context that is
a sub-context
+        of the current context. Ported from TC4. (markt) 
+      </fix>
     </changelog>
   </subsection>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message