Author: echatellier Date: 2014-07-24 12:19:39 +0200 (Thu, 24 Jul 2014) New Revision: 531 Url: http://forge.nuiton.org/projects/nuiton-js/repository/revisions/531 Log: fixes #3256: Nuiton js loading fails on windows Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java =================================================================== --- trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java 2014-07-24 08:20:32 UTC (rev 530) +++ trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/ImportWildcardXmlModelFactory.java 2014-07-24 10:19:39 UTC (rev 531) @@ -26,7 +26,9 @@ import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -35,6 +37,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; +import org.apache.commons.io.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.filefilter.TrueFileFilter; @@ -141,6 +144,11 @@ // log only LOG.warn("[FAIL] problem while trying to expand wildcard for the following resource uri: {}", uri); + } catch (URISyntaxException e) { + e.printStackTrace(); // DEBUG + // log only + LOG.warn("[FAIL] problem while trying to expand wildcard for the following resource uri: {}", + uri); } } else { final WildcardExpanderHandlerAware expandedHandler = (WildcardExpanderHandlerAware) wildcardStreamLocator; @@ -182,13 +190,18 @@ * @param url l'url du jar dans lequel il faut faire la recherche * @return la liste des fichiers du jar qui correspond * @throws IOException + * @throws URISyntaxException */ - protected List<String> listAcceptableFile(String pattern, URL url) throws IOException { + protected List<String> listAcceptableFile(String pattern, URL url) throws IOException, URISyntaxException { // le path du pattern (c-a-d: a/b/c/) String classPath = FilenameUtils.getPath(pattern); + // fix strange charaters on windows + String filePath = URLDecoder.decode(url.getPath(), "UTF-8"); + // recuperation du path du jar sans la partie query - String jarPath = StringUtils.substringBefore(url.getPath(), "!"); + // use toURI to fix windows bugs with space path + String jarPath = StringUtils.substringBefore(filePath, "!"); if (jarPath.startsWith("file:")) { jarPath = StringUtils.substringAfter(jarPath, "file:"); } @@ -207,7 +220,7 @@ } } else if (FilenameUtils.isExtension(jarPath, new String[]{"jar", "zip", "war"})) { - String prefix = "jar:" + StringUtils.substringBefore(url.getPath(), "!") + "!/"; + String prefix = "jar:" + StringUtils.substringBefore(filePath, "!") + "!/"; JarFile file = null; try {