String path = null;
if ("vfsfile".equals(url.getProtocol())) {
try {
path = url.toURI().getPath() ;
} catch (URISyntaxException e) {
throw new ConfigurationException(e);
}
} else {
path = url.getPath();
}
File dir = new File(path);
String rootPublisherStr = config.getString(Property.JUDDI_ROOT_PUBLISHER);
if (dir.exists()) {
log.debug("Discovering the Publisher XML data files in directory: " + path);
File[] files = dir.listFiles(new PublisherFileFilter());
for (File f : files)
{
String publisher = f.getName().substring(0,f.getName().indexOf(FILE_PUBLISHER));
if (! rootPublisherStr.equalsIgnoreCase(publisher)) {
publishers.add(publisher);
}
}
} else {
String[] paths = {};
Enumeration<JarEntry> en = null;
try {
if (path.indexOf("!") > 0) {
paths = path.split("!");
en = new JarFile(new File(new URI(paths[0]))).entries();
} else {
// Handle Windows / jboss-5.1.0 case
if (path.indexOf(".jar") > 0) {
paths = path.split(".jar");
paths[0] = paths[0] + ".jar";
en = new JarFile(new File(paths[0])).entries();
}
}
if (paths.length > 0) {
log.debug("Discovering the Publisher XML data files in jar: " + paths[0]);
while (en.hasMoreElements()) {
String name = en.nextElement().getName();
if (name.startsWith(basePath)&& name.endsWith(FILE_PUBLISHER)) {
log.debug("Found publisher file=" + name);
String publisher = name.substring(basePath.length(),name.indexOf(FILE_PUBLISHER));
if (! rootPublisherStr.equalsIgnoreCase(publisher)) {
publishers.add(publisher);
}
}
}
} else {
log.info("No custom configuration files where found in " + path);
}
} catch (IOException e) {
throw new ConfigurationException(e);
} catch (URISyntaxException e) {
throw new ConfigurationException(e);
}
}
return publishers;
}