store = getDownloadableExtensionStoreDescriptor(true);
if (store == null) {
throw new ExtensionException(ExtensionException.INTERNAL_ERROR, "No downloadable applications.");
}
ExtensionBundle bundle = store.getApplicationBundle(id);
if (bundle == null) {
throw new ExtensionException(ExtensionException.INVALID_EXTENSION, id);
}
// Check host version
Context context = ContextHolder.getContext();
if (bundle.getRequiredHostVersion() != null && bundle.getRequiredHostVersion().compareTo(context.getVersion()) > 0) {
throw new ExtensionException(ExtensionException.INSUFFICIENT_ADITO_HOST_VERSION,
bundle.getId(),
bundle.getRequiredHostVersion().toString());
}
// Install all dependencies
if (bundle.getDependencies() != null) {
for (String dep : bundle.getDependencies()) {
if (isExtensionBundleLoaded(dep)) {
ExtensionBundle current = getExtensionBundle(dep);
ExtensionBundle available = store.getApplicationBundle(dep);
if(available != null) {
if (!current.isDevExtension() && isNewerVersionAvailable(available, current)) {
if (log.isInfoEnabled())
log.info("Found a dependency (" + dep + "), that needs upgrading. " + current.getVersion().toString() + " is the current version, " + available.getVersion().toString() + " is available. Installing now");
installExtensionFromStore(current.getId(), available.getVersion().toString(), request);
}
}
} else {
try {
if (log.isInfoEnabled())