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 = path.split("!");
try {
log.debug("Discovering the Publisher XML data files in jar: " + paths[0]);
Enumeration<JarEntry> en = new JarFile(new File(new URI(paths[0]))).entries();
while (en.hasMoreElements()) {
String name = en.nextElement().getName();
if (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);
}
}
}
} catch (IOException e) {
throw new ConfigurationException(e);
} catch (URISyntaxException e) {
throw new ConfigurationException(e);
}
}
return publishers;
}