Author: markt
Date: Sun Sep 30 19:45:00 2012
New Revision: 1392098
URL: http://svn.apache.org/viewvc?rev=1392098&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53854
Get directory listings working with aliases
Modified:
tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java
tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java
tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java
Modified: tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=1392098&r1=1392097&r2=1392098&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java Sun Sep
30 19:45:00 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;
@@ -651,7 +652,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());
}
@@ -667,8 +668,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/trunk/java/org/apache/naming/resources/FileDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java?rev=1392098&r1=1392097&r2=1392098&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/FileDirContext.java Sun Sep
30 19:45:00 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/trunk/java/org/apache/naming/resources/WARDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java?rev=1392098&r1=1392097&r2=1392098&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/WARDirContext.java Sun Sep 30
19:45:00 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;
/**
@@ -273,52 +270,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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]