On Feb 2, 2011, at 5:49 PM, sdumitriu (SVN) wrote:
Author: sdumitriu
Date: 2011-02-02 17:49:50 +0100 (Wed, 02 Feb 2011)
New Revision: 34371
Modified:
platform/core/trunk/xwiki-extension/xwiki-extension-api/src/main/java/org/xwiki/extension/repository/internal/DefaultCoreExtensionRepository.java
Log:
XWIKI-5946: Extension manager fails on JBoss AS 5
Fixed.
Modified:
platform/core/trunk/xwiki-extension/xwiki-extension-api/src/main/java/org/xwiki/extension/repository/internal/DefaultCoreExtensionRepository.java
===================================================================
---
platform/core/trunk/xwiki-extension/xwiki-extension-api/src/main/java/org/xwiki/extension/repository/internal/DefaultCoreExtensionRepository.java 2011-02-02
16:24:38 UTC (rev 34370)
+++
platform/core/trunk/xwiki-extension/xwiki-extension-api/src/main/java/org/xwiki/extension/repository/internal/DefaultCoreExtensionRepository.java 2011-02-02
16:49:50 UTC (rev 34371)
@@ -21,8 +21,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -76,6 +78,8 @@
{
Set<URL> basURLs =
ClasspathHelper.getUrlsForPackagePrefix("META-INF.maven");
+ basURLs = filterURLs(basURLs);
+
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setScanners(new ResourcesScanner());
configurationBuilder.setUrls(basURLs);
@@ -166,6 +170,27 @@
}
}
+ private Set<URL> filterURLs(Set<URL> urls)
would benefit from a javadoc to explain why we have to do this....
Thanks
-Vincent
+ {
+ Set<URL> results = new HashSet<URL>(urls.size());
+ for (URL url : urls) {
+ String cleanURL = url.toString();
+ // Fix JBoss URLs
+ if (url.getProtocol().startsWith("vfszip:")) {
+ cleanURL = cleanURL.replaceFirst("vfszip:",
"file:");
+ } else if (url.getProtocol().startsWith("vfsfile:")) {
+ cleanURL = cleanURL.replaceFirst("vfsfile:",
"file:");
+ }
+ cleanURL = cleanURL.replaceFirst("\\.jar/", ".jar!/");
+ try {
+ results.add(new URL(cleanURL));
+ } catch (MalformedURLException ex) {
+ // Shouldn't happen, but we can't do more to fix this URL.
+ }
+ }
+ return results;
+ }
+
private String packagingToType(String packaging)
{
// support bundle packaging