public PluginList(File file, File defaultDir, String targetArch)
throws PluginException, MalformedURLException {
this.defaultDir = defaultDir;
descrList = new ArrayList<URL>();
pluginList = new ArrayList<URL>();
final XMLElement root = new XMLElement(new Hashtable<Object, Object>(), true, false);
try {
final FileReader r = new FileReader(file);
try {
root.parseFromReader(r);
} finally {
r.close();
}
} catch (IOException ex) {
throw new PluginException(ex);
}
if (!root.getName().equals("plugin-list")) {
throw new PluginException("plugin-list element expected");
}
this.name = (String) root.getAttribute("name");
if (name == null) {
throw new PluginException("name attribute is missing in " + file);
}
for (Iterator<?> i = root.getChildren().iterator(); i.hasNext();) {
final XMLElement e = (XMLElement) i.next();
if (e.getName().equals("plugin")) {
final String id = e.getStringAttribute("id");
if (id == null) {
throw new PluginException("id attribute expected on "
+ e.getName());
}
// version attribute is optional
// if not specified, then the latest version found will be used.
final String version = e.getStringAttribute("version");
addPlugin(descrList, pluginList, id, version);
} else if (e.getName().equals("manifest")) {
manifest = parseManifest(e);
} else if (e.getName().equals("include")) {
parseInclude(e, file.getParentFile(), defaultDir, targetArch,
descrList, pluginList);
} else {
throw new PluginException("Unknown element " + e.getName());
}
}
}