public Optional<PluginInfo> run() throws PluginDocumentParseException { final PluginInfoDocumentParser pluginInfoDocumentParser = new PluginInfoDocumentParser(url); PluginInfo info = pluginInfoDocumentParser.parseDocument(b); if(!b.isPresent()) { info.setPluginDescriptor(null); return Optional.of(info); } if (info.getAvailableVersion().compareTo(PluginUtilities.getBundleVersion(b.get())) > 0) { // New version available! info.setPluginDescriptor(b.get()); return Optional.of(info); } return Optional.empty(); } }
UpdateChecker checker = new UpdateChecker(url, bundle); PluginInfo info = checker.run(); if (info != null && info.getAvailableVersion().compareTo(bundle.getVersion()) > 0) { info.setPluginDescriptor(bundle); plugins.add(info);
UpdateChecker checker = new UpdateChecker(url, bundle); PluginInfo info = checker.run(); if (info != null && info.getAvailableVersion().compareTo(bundle.getVersion()) > 0) { info.setPluginDescriptor(bundle); plugins.add(info);
private static Optional<File> copyPluginToInstallLocation(File downloadedPlugin, PluginInfo info) throws URISyntaxException { final Optional<File> backupFileName = moveExistingPluginToBackupLocation(info); final File pluginsFolder = new File(System.getProperty(ProtegeApplication.BUNDLE_DIR_PROP)); final String destinationFileName = String.format("%s-%s.jar", info.getId(), info.getAvailableVersion()); final File downloadedPluginDestination = new File(pluginsFolder, destinationFileName); try { FileUtils.copyFile(downloadedPlugin, downloadedPluginDestination); logger.info("Copied the {} plugin to {} in the plugins directory", info.getLabel(), downloadedPluginDestination.getName()); deletePluginBackup(backupFileName); return Optional.of(downloadedPluginDestination); } catch (IOException e) { try { File userPluginDirectory = ProtegeDirectories.getUserPluginDirectory(); logger.info("Could not copy the plugin to Protege plugins directory: {}", e.getMessage()); File userDirectoryPluginFile = new File(userPluginDirectory, info.getId() + ".jar"); FileUtils.copyFileToDirectory(downloadedPlugin, userDirectoryPluginFile); logger.info("Copied the {} plugin to the user plugin directory at {}. " + "This plugin will only be use-able by the current user.", info.getLabel(), userPluginDirectory); deletePluginBackup(backupFileName); return Optional.of(userDirectoryPluginFile); } catch (IOException ioe) { logger.error("An error occurred whilst attempting to save the plugin: {}", ioe.getMessage(), ioe); return Optional.empty(); } } }
if (bundle != null) { boolean newer = bundle.getVersion().compareTo(info.getAvailableVersion()) < 0; if(newer) { info.setPluginDescriptor(bundle);
if (pluginType == PluginRegistryType.PLUGIN_UPDATE_REGISTRY && bundle != null && bundle.getVersion().compareTo(info.getAvailableVersion()) < 0 && !selfUpdatingBundleIds.contains(info.getId())) { info.setPluginDescriptor(bundle);
if (pluginType == PluginRegistryType.PLUGIN_UPDATE_REGISTRY && bundle != null && bundle.getVersion().compareTo(info.getAvailableVersion()) < 0 && !selfUpdatingBundleIds.contains(info.getId())) { info.setPluginDescriptor(bundle);
return info.getAvailableVersion();
private InstallerResult install(PluginInfo info) { logger.info(LogBanner.start("Downloading and Installing Plugin")); BackgroundTask downloading = ProtegeApplication.getBackgroundTaskManager().startTask("downloading " + info.getLabel()); logger.info("Downloading the {} plugin (Version {})", info.getLabel(), info.getAvailableVersion()); try { Optional<File> downloadedPlugin = downloadPlugin(info); if (!downloadedPlugin.isPresent()) { logger.error("An error occurred whilst downloading the {} plugin. The plugin has not been installed.", info.getLabel()); return InstallerResult.ERROR; } Optional<File> installedPluginFile = copyPluginToInstallLocation(downloadedPlugin.get(), info); if (!installedPluginFile.isPresent()) { logger.error("There was an error whilst trying to install the {} plugin. It has not been installed", info.getLabel()); return InstallerResult.ERROR; } if (installPlugin(installedPluginFile.get(), info)) { return InstallerResult.INSTALLED; } else { return InstallerResult.DOWNLOADED; } } catch (IOException | URISyntaxException t) { logger.error("An error occurred whilst downloading and installing the {} plugin: {}", info.getLabel(), t.getMessage(), t); return InstallerResult.ERROR; } finally { logger.info(LogBanner.end()); ProtegeApplication.getBackgroundTaskManager().endTask(downloading); } }
public PluginInfo run() throws IOException, UpdateException { final PluginInfoDocument pluginInfoDocument = new PluginInfoDocument(url); if (pluginInfoDocument.isValid(b)) { PluginInfo info = pluginInfoDocument.getPluginInfo(); if (b == null || info.getAvailableVersion().compareTo(PluginUtilities.getBundleVersion(b)) > 0) { // New version available! info.setPluginDescriptor(b); return info; } } return null; } }
public PluginInfo run() throws IOException, UpdateException { final PluginInfoDocument pluginInfoDocument = new PluginInfoDocument(url); if (pluginInfoDocument.isValid(b)) { PluginInfo info = pluginInfoDocument.getPluginInfo(); if (b == null || info.getAvailableVersion().compareTo(PluginUtilities.getBundleVersion(b)) > 0) { // New version available! info.setPluginDescriptor(b); return info; } } return null; } }
public boolean isValid(Bundle bundle) throws UpdateException { if (info.getId() == null){ throw new UpdateException(info.getId(), updateFileLocation, "No plugin ID given"); } if (bundle != null){ final String pluginID = bundle.getSymbolicName(); if (!info.getId().equals(pluginID)){ throw new UpdateException(info.getId(), updateFileLocation, "ID does not match the plugin (" + pluginID + ")"); } } if (info.getAvailableVersion() == null){ throw new UpdateException(info.getId(), updateFileLocation, "Cannot find version"); } if (info.getDownloadURL() == null){ throw new UpdateException(info.getId(), updateFileLocation, "No download location given"); } return true; }
public boolean isValid(Bundle bundle) throws UpdateException { if (info.getId() == null){ throw new UpdateException(info.getId(), updateFileLocation, "No plugin ID given"); } if (bundle != null){ final String pluginID = bundle.getSymbolicName(); if (!info.getId().equals(pluginID)){ throw new UpdateException(info.getId(), updateFileLocation, "ID does not match the plugin (" + pluginID + ")"); } } if (info.getAvailableVersion() == null){ throw new UpdateException(info.getId(), updateFileLocation, "Cannot find version"); } if (info.getDownloadURL() == null){ throw new UpdateException(info.getId(), updateFileLocation, "No download location given"); } return true; }