root.setAttribute("xmlns", NAMESPACE);
doc.appendChild(root);
for (Iterator it = plugins.iterator(); it.hasNext();) {
Artifact plugin = (Artifact) it.next();
System.out.println("Including plugin data for "+plugin);
PluginMetadata data = installer.getPluginMetadata(plugin);
if(data == null) {
throw new IllegalArgumentException("Invalid plugin file; Log4J output for a specific error.");
}
File file = destRepo.getLocation(plugin);
Element config = doc.createElement("plugin");
root.appendChild(config);
createText(doc, config, "name", data.getName());
createText(doc, config, "module-id", data.getModuleId().toString());
createText(doc, config, "category", data.getCategory());
createText(doc, config, "description", data.getDescription());
if(data.getPluginURL() != null) {
createText(doc, config, "url", data.getPluginURL());
}
if(data.getAuthor() != null) {
createText(doc, config, "author", data.getAuthor());
}
for (int i = 0; i < data.getLicenses().length; i++) {
PluginMetadata.License license = data.getLicenses()[i];
Element lic = doc.createElement("license");
lic.appendChild(doc.createTextNode(license.getName()));
lic.setAttribute("osi-approved", license.isOsiApproved() ? "true" : "false");
config.appendChild(lic);
}
if(data.getHash() != null) {
Element hash = doc.createElement("hash");
hash.setAttribute("type", data.getHash().getType());
hash.appendChild(doc.createTextNode(data.getHash().getValue()));
config.appendChild(hash);
} else if(file.isFile() && file.canRead()) {
Element hash = doc.createElement("hash");
hash.setAttribute("type", "SHA-1");
hash.appendChild(doc.createTextNode(ConfigurationStoreUtil.getActualChecksum(file)));
config.appendChild(hash);
}
for (int i = 0; i < data.getGeronimoVersions().length; i++) {
String version = data.getGeronimoVersions()[i];
createText(doc, config, "geronimo-version", version);
}
for (int i = 0; i < data.getJvmVersions().length; i++) {
String version = data.getJvmVersions()[i];
createText(doc, config, "jvm-version", version);
}
for (int i = 0; i < data.getPrerequisites().length; i++) {
PluginMetadata.Prerequisite prereq = data.getPrerequisites()[i];
writePrerequisite(doc, config, prereq);
}
for (int i = 0; i < data.getDependencies().length; i++) {
String version = data.getDependencies()[i];
createText(doc, config, "dependency", version);
}
for (int i = 0; i < data.getObsoletes().length; i++) {
String version = data.getObsoletes()[i];
createText(doc, config, "obsoletes", version);
}
// Skip the repository, we'll specify that at the top level
// for (int i = 0; i < data.getRepositories().length; i++) {
// URL url = data.getRepositories()[i];
// createText(doc, config, "source-repository", url.toString());
// }
for (int i = 0; i < data.getFilesToCopy().length; i++) {
PluginMetadata.CopyFile copyFile = data.getFilesToCopy()[i];
Element copy = doc.createElement("copy-file");
copy.setAttribute("relative-to", copyFile.isRelativeToVar() ? "server" : "geronimo");
copy.setAttribute("dest-dir", copyFile.getDestDir());
copy.appendChild(doc.createTextNode(copyFile.getSourceFile()));
config.appendChild(copy);
}
if(data.getConfigXmls().length > 0) {
Element content = doc.createElement("config-xml-content");
for (int i = 0; i < data.getConfigXmls().length; i++) {
GBeanOverride override = data.getConfigXmls()[i];
Element gbean = override.writeXml(doc, content);
gbean.setAttribute("xmlns", "http://geronimo.apache.org/xml/ns/attributes-1.1");
}
config.appendChild(content);
}