if (element.getName().equals(TYPE)) {
// Plugin name
String name = element.getAttributeValue("name");
if (name == null || name.equals("")) {
throw new ExtensionException(ExtensionException.FAILED_TO_PROCESS_DESCRIPTOR,
"The name attribute must be supplied for <languagePack> elements.");
}
// Create the definition
packDefinition = new LanguagePackDefinition(descriptor, name);
LanguagePackManager.getInstance().addLanguagePackDefinition(packDefinition);
for (Iterator i = element.getChildren().iterator(); i.hasNext();) {
Element el = (Element) i.next();
if (el.getName().equals("classpath")) {
String path = Util.trimmedBothOrBlank(el.getText());
if (path != null && !path.equals("")) {
File f = new File(descriptor.getApplicationBundle().getBaseDir(), path);
if (f.exists()) {
try {
URL u = f.toURL();
if (log.isInfoEnabled())
log.info("Adding " + u + " to classpath");
packDefinition.addClassPath(u);
} catch (MalformedURLException murle) {
}
} else {
if (!"true".equals(SystemProperties.get("adito.useDevConfig"))) {
log.warn("Plugin classpath element " + f.getAbsolutePath() + " does not exist.");
}
}
}
} else if (el.getName().equals("date")) {
String date = Util.trimmedBothOrBlank(el.getText());
if (Util.isNullOrTrimmedBlank(date)) {
throw new ExtensionException(ExtensionException.FAILED_TO_PROCESS_DESCRIPTOR,
"The content of the <date> must contain the creation date of the language in the pack.");
}
packDefinition.setDate(date);
} else if (el.getName().equals("language")) {
String code = el.getAttributeValue("code");
if (code == null || code.equals("")) {
throw new ExtensionException(ExtensionException.FAILED_TO_PROCESS_DESCRIPTOR,
"The code attribute must be supplied for <language> elements.");
}
String description = Util.trimmedBothOrBlank(el.getText());
if (Util.isNullOrTrimmedBlank(description)) {
throw new ExtensionException(ExtensionException.FAILED_TO_PROCESS_DESCRIPTOR,
"The content of the <language> must contain the description of the language in the pack.");
}
packDefinition.addLanguage(new Language(packDefinition, code, description));
} else {
throw new ExtensionException(ExtensionException.FAILED_TO_PROCESS_DESCRIPTOR,
"The <language> element only supports the nested <classpath> elements");
}
}
// Now add the classpath. We will only do this once until the dynamic classloader is written