Commits

Anonymous committed dc7bfaf

cleaning up old wildcard handling code

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1976e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 23de2cb

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java

         return finalDocs;
     }
 
-    private void handleWildCardIncludes(String includeFileName, List<Document> docs, Element child) {
-        // check for star*, pedantic
-        if (includeFileName.indexOf('*') == -1) {
-            throw new XWorkException("handleWildCardIncludes called with name not containing wildcard");
-        }
-        LOG.info("encountered wildcard include, checking for - " + includeFileName);
-        URL[] curDirUrls;
-
-        // curDirUrls = ClassLoaderUtil.getResources("/", this.getClass(), true);
-        ClassLoader cl = XmlConfigurationProvider.class.getClassLoader();
-        URLClassLoader ucl;
-        if (cl instanceof URLClassLoader) {
-            ucl = (URLClassLoader) cl;
-        } else {
-            throw new XWorkException("cannot create an URLClassLoader from current classloader");
-        }
-        curDirUrls = ucl.getURLs();
-
-        String fileNamePrefix = null;
-        if (!includeFileName.startsWith("*")) {
-            fileNamePrefix = includeFileName.substring(0, includeFileName.indexOf('*'));
-        }
-
-        String fileNameSuffix = null;
-        if (!includeFileName.endsWith("*")) {
-            fileNameSuffix = includeFileName.substring(includeFileName.lastIndexOf('*') + 1);
-        }
-
-        String relativeDir = null;
-
-        if (includeFileName.contains("/")) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("includeFileName contains a /");
-            }
-            if (includeFileName.lastIndexOf('/') > includeFileName.indexOf('*')) {
-                throw new XWorkException("wildcard includes does not support wildcard directories");
-            }
-            fileNamePrefix = includeFileName.substring(includeFileName.lastIndexOf('/') + 1, includeFileName.indexOf('*'));
-            relativeDir = includeFileName.substring(0, includeFileName.lastIndexOf('/'));
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("relativeDir = " + relativeDir + ", fileNameMask = " + fileNamePrefix);
-            }
-        }
-
-        for (URL baseSearchURL : curDirUrls) {
-            if (!"file".equals(baseSearchURL.getProtocol())) {
-                continue;
-            }
-
-            File searchDir;
-
-            if (relativeDir != null) {
-                if (relativeDir.startsWith("/")) {
-                    relativeDir = relativeDir.substring(relativeDir.indexOf('/') + 1);
-                }
-                File parent;
-                try {
-                    parent = new File(baseSearchURL.toURI());
-                } catch (URISyntaxException e) {
-                    throw new XWorkException("bad URI for searchDir - " + baseSearchURL.toString());
-                }
-                if (!parent.isDirectory()) {
-                    continue;
-                }
-                searchDir = new File(parent, relativeDir);
-            } else {
-                try {
-                    searchDir = new File(baseSearchURL.toURI());
-                } catch (URISyntaxException e) {
-                    throw new XWorkException("bad URI for searchDir - " + baseSearchURL.toString());
-                }
-            }
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("using - " + searchDir.toURI().toString() + ", as searchDir");
-            }
-            if (searchDir != null && searchDir.isDirectory()) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("getting searchDir file list");
-                }
-                String[] filesInDir = searchDir.list();
-                if (filesInDir == null) {
-                    throw new XWorkException("unable to find any files in include directory");
-                }
-                for (String fileInDir : filesInDir) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("checking - " + fileInDir);
-                    }
-                    boolean fileMatches = false;
-                    if (fileNameSuffix != null || fileNamePrefix != null) {
-                        fileMatches = (fileNameSuffix != null && fileNamePrefix != null &&
-                                fileNameSuffix.length() + fileNamePrefix.length() < fileInDir.length() &&
-                                fileInDir.startsWith(fileNamePrefix) && fileInDir.endsWith(fileNameSuffix));
-                        fileMatches = fileMatches ||
-                                (fileNamePrefix == null &&
-                                        fileInDir.endsWith(fileNameSuffix));
-                        fileMatches = fileMatches ||
-                                (fileNameSuffix == null &&
-                                        fileInDir.startsWith(fileNamePrefix));
-                    }
-
-                    if (fileMatches) {
-                        if (relativeDir != null) {
-                            if (!relativeDir.endsWith("/")) {
-                                relativeDir = relativeDir.concat("/");
-                            }
-                            if (LOG.isDebugEnabled()) {
-                                LOG.debug("calling load on - " + relativeDir + fileInDir);
-                            }
-                            docs.addAll(loadConfigurationFiles(relativeDir + fileInDir, child));
-                        } else {
-                            if (LOG.isDebugEnabled()) {
-                                LOG.debug("calling load on - " + fileInDir);
-                            }
-                            docs.addAll(loadConfigurationFiles(fileInDir, child));
-                        }
-                    }
-                }
-            }
-        }
-    }
-
     protected Iterator<URL> getConfigurationUrls(String fileName) throws IOException {
         return ClassLoaderUtil.getResources(fileName, XmlConfigurationProvider.class, false);
     }