* @throws org.apache.geronimo.kernel.repository.MissingDependencyException
* if plugin requires a dependency that is not present
*/
public boolean validatePlugin(PluginType plugin) throws MissingDependencyException {
if (plugin.getPluginArtifact().size() != 1) {
throw new MissingDependencyException("A plugin configuration must include one plugin artifact, not " + plugin.getPluginArtifact().size(), null, (Stack<Artifact>) null);
}
PluginArtifactType metadata = plugin.getPluginArtifact().get(0);
// 1. Check that it's not already installed
if (metadata.getModuleId() != null) { // that is, it's a real configuration not a plugin list
Artifact artifact = toArtifact(metadata.getModuleId());
//plugin groups don't get registered with configManager
if (plugin.isPluginGroup() != null && plugin.isPluginGroup()) {
if (installedArtifacts.contains(artifact)) {
log.debug("Configuration {} is already installed", artifact);
return false;
}
} else {
if (configManager.isInstalled(artifact)) {
boolean upgrade = false;
for (ArtifactType obsolete : metadata.getObsoletes()) {
Artifact test = toArtifact(obsolete);
if (test.matches(artifact)) {
upgrade = true;
break;
}
}
if (!upgrade && installedArtifacts.contains(artifact)) {
log.debug("Configuration {} is already installed", artifact);
return false;
}
}
}
}
// 2. Check that we meet the Geronimo, JVM versions
if (metadata.getGeronimoVersion().size() > 0 && !checkGeronimoVersions(metadata.getGeronimoVersion())) {
log.debug("Plugin " + toArtifact(metadata.getModuleId()) + " is not installable on Geronimo " + serverInfo.getVersion());
throw new MissingDependencyException(
"Plugin is not installable on Geronimo " + serverInfo.getVersion(), toArtifact(metadata.getModuleId()), (Stack<Artifact>) null);
}
if (metadata.getJvmVersion().size() > 0 && !checkJVMVersions(metadata.getJvmVersion())) {
log.debug("Plugin " + toArtifact(metadata.getModuleId()) + " is not installable on JVM " + System.getProperty("java.version"));
throw new MissingDependencyException(
"Plugin is not installable on JVM " + System.getProperty("java.version"), toArtifact(metadata.getModuleId()), (Stack<Artifact>) null);
}
return true;
}