Author: markt Date: Sun Sep 30 19:48:36 2012 New Revision: 1392099 URL: http://svn.apache.org/viewvc?rev=1392099&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53854 Get directory listings working with aliases
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/WARDirContext.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1392098 Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=1392099&r1=1392098&r2=1392099&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/BaseDirContext.java Sun Sep 30 19:48:36 2012 @@ -48,6 +48,7 @@ import javax.naming.directory.SearchResu import org.apache.naming.NameParserImpl; import org.apache.naming.NamingContextBindingsEnumeration; +import org.apache.naming.NamingContextEnumeration; import org.apache.naming.NamingEntry; import org.apache.naming.StringManager; @@ -658,7 +659,7 @@ public abstract class BaseDirContext imp * @exception NamingException if a naming exception is encountered */ @Override - public NamingEnumeration<NameClassPair> list(Name name) + public final NamingEnumeration<NameClassPair> list(Name name) throws NamingException { return list(name.toString()); } @@ -674,8 +675,44 @@ public abstract class BaseDirContext imp * @exception NamingException if a naming exception is encountered */ @Override - public abstract NamingEnumeration<NameClassPair> list(String name) - throws NamingException; + public final NamingEnumeration<NameClassPair> list(String name) + throws NamingException { + + if (!aliases.isEmpty()) { + AliasResult result = findAlias(name); + if (result.dirContext != null) { + return result.dirContext.list(result.aliasName); + } + } + + // Next do a standard lookup + List<NamingEntry> bindings = doListBindings(name); + + // Check the alternate locations + List<NamingEntry> altBindings = null; + + for (DirContext altDirContext : altDirContexts) { + if (altDirContext instanceof BaseDirContext) { + altBindings = ((BaseDirContext) altDirContext).doListBindings( + "/META-INF/resources" + name); + } + if (altBindings != null) { + if (bindings == null) { + bindings = altBindings; + } else { + bindings.addAll(altBindings); + } + } + } + + if (bindings != null) { + return new NamingContextEnumeration(bindings.iterator()); + } + + // Really not found + throw new NameNotFoundException( + sm.getString("resources.notFound", name)); + } /** Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java?rev=1392099&r1=1392098&r2=1392099&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java Sun Sep 30 19:48:36 2012 @@ -30,7 +30,6 @@ import java.util.Hashtable; import java.util.List; import javax.naming.NameAlreadyBoundException; -import javax.naming.NameClassPair; import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -41,7 +40,6 @@ import javax.naming.directory.Modificati import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; -import org.apache.naming.NamingContextEnumeration; import org.apache.naming.NamingEntry; import org.apache.tomcat.util.http.RequestUtil; @@ -279,34 +277,6 @@ public class FileDirContext extends Base /** - * Enumerates the names bound in the named context, along with the class - * names of objects bound to them. The contents of any subcontexts are - * not included. - * <p> - * If a binding is added to or removed from this context, its effect on - * an enumeration previously returned is undefined. - * - * @param name the name of the context to list - * @return an enumeration of the names and class names of the bindings in - * this context. Each element of the enumeration is of type NameClassPair. - * @exception NamingException if a naming exception is encountered - */ - @Override - public NamingEnumeration<NameClassPair> list(String name) - throws NamingException { - - File file = file(name); - - if (file == null) - throw new NameNotFoundException - (sm.getString("resources.notFound", name)); - - return new NamingContextEnumeration(list(file).iterator()); - - } - - - /** * Enumerates the names bound in the named context, along with the * objects bound to them. The contents of any subcontexts are not * included. Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/WARDirContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/WARDirContext.java?rev=1392099&r1=1392098&r2=1392099&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/WARDirContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/WARDirContext.java Sun Sep 30 19:48:36 2012 @@ -34,8 +34,6 @@ import java.util.zip.ZipFile; import javax.naming.CompositeName; import javax.naming.InvalidNameException; import javax.naming.Name; -import javax.naming.NameClassPair; -import javax.naming.NameNotFoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.OperationNotSupportedException; @@ -45,7 +43,6 @@ import javax.naming.directory.Modificati import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; -import org.apache.naming.NamingContextEnumeration; import org.apache.naming.NamingEntry; /** @@ -271,52 +268,6 @@ public class WARDirContext extends BaseD /** - * Enumerates the names bound in the named context, along with the class - * names of objects bound to them. The contents of any subcontexts are - * not included. - * <p> - * If a binding is added to or removed from this context, its effect on - * an enumeration previously returned is undefined. - * - * @param name the name of the context to list - * @return an enumeration of the names and class names of the bindings in - * this context. Each element of the enumeration is of type NameClassPair. - * @exception NamingException if a naming exception is encountered - */ - @Override - public NamingEnumeration<NameClassPair> list(String name) - throws NamingException { - return list(getEscapedJndiName(name)); - } - - - /** - * Enumerates the names bound in the named context, along with the class - * names of objects bound to them. The contents of any subcontexts are - * not included. - * <p> - * If a binding is added to or removed from this context, its effect on - * an enumeration previously returned is undefined. - * - * @param name the name of the context to list - * @return an enumeration of the names and class names of the bindings in - * this context. Each element of the enumeration is of type NameClassPair. - * @exception NamingException if a naming exception is encountered - */ - @Override - public NamingEnumeration<NameClassPair> list(Name name) - throws NamingException { - if (name.isEmpty()) - return new NamingContextEnumeration(list(entries).iterator()); - Entry entry = treeLookup(name); - if (entry == null) - throw new NameNotFoundException - (sm.getString("resources.notFound", name)); - return new NamingContextEnumeration(list(entry).iterator()); - } - - - /** * Enumerates the names bound in the named context, along with the * objects bound to them. The contents of any subcontexts are not * included. Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1392099&r1=1392098&r2=1392099&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Sep 30 19:48:36 2012 @@ -90,6 +90,10 @@ of garbage and uses significant CPU time. A cache has been added that significantly reduces the overhead of this parser. (markt) </fix> + <fix> + <bug>53854</bug>: Make directory listings work correctly when aliases + are used. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org