tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1384313 - in /tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources: JarResourceSet.java StandardRoot.java
Date Thu, 13 Sep 2012 13:09:04 GMT
Author: markt
Date: Thu Sep 13 13:09:04 2012
New Revision: 1384313

URL: http://svn.apache.org/viewvc?rev=1384313&view=rev
Log:
Implement some more TODOs (untested)

Modified:
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java?rev=1384313&r1=1384312&r2=1384313&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
Thu Sep 13 13:09:04 2012
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Set;
 import java.util.jar.JarEntry;
@@ -89,8 +90,24 @@ public class JarResourceSet implements W
 
     @Override
     public String[] list(String path) {
-        // TODO Auto-generated method stub
-        return null;
+        ArrayList<String> result = new ArrayList<>();
+        if (path.startsWith(webAppMount)) {
+            String pathInJar =
+                    internalPath + path.substring(webAppMount.length());
+            Enumeration<JarEntry> entries = base.entries();
+            while (entries.hasMoreElements()) {
+                JarEntry entry = entries.nextElement();
+                String name = entry.getName();
+                if (name.startsWith(pathInJar)) {
+                    int i = name.lastIndexOf('/');
+                    if (i > -1) {
+                        name = name.substring(i);
+                    }
+                    result.add(name);
+                }
+            }
+        }
+        return result.toArray(new String[result.size()]);
     }
 
     @Override

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1384313&r1=1384312&r2=1384313&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java
Thu Sep 13 13:09:04 2012
@@ -95,17 +95,35 @@ public class StandardRoot extends Lifecy
     @Override
     public boolean mkdir(String path) {
         checkState();
-        // TODO Check pre-Resources for overrides
+
+        if (preResourceExists(path)) {
+            return false;
+        }
+
         return main.mkdir(path);
     }
 
     @Override
     public boolean write(String path, InputStream is) {
         checkState();
-        // TODO Check pre-Resources for overrides
+
+        if (preResourceExists(path)) {
+            return false;
+        }
+
         return main.write(path, is);
     }
 
+    private boolean preResourceExists(String path) {
+        for (WebResourceSet webResourceSet : preResources) {
+            WebResource webResource = webResourceSet.getResource(path);
+            if (webResource.exists()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     public WebResource getResource(String path) {
         checkState();



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


Mime
View raw message