private List<String> findUpdateCandidates() throws Exception { List<ExtendedPluginInfo> updateCandidates = executeList().getPluginList(); Iterables.removeIf(updateCandidates, new Predicate<ExtendedPluginInfo>() { @Override public boolean apply(ExtendedPluginInfo pluginInfo) { return !pluginInfo.isInstalled() || !pluginInfo.canUninstall() || !pluginInfo.isOutdated(); } }); return Lists.transform(updateCandidates, new Function<ExtendedPluginInfo, String>() { @Override public String apply(ExtendedPluginInfo pluginInfo) { return pluginInfo.getLocalPluginInfo().getPluginId(); } }); }
if (removeResult.getResultCode() == PluginResultCode.NOK) { logger.log(Level.SEVERE, "Unable to remove " + pluginId + " during the update process"); erroneousPlugins.add(pluginId); PluginOperationResult installResult = executeInstallFromApiHost(pluginId); if (installResult.getResultCode() == PluginResultCode.NOK) { logger.log(Level.SEVERE, "Unable to install " + pluginId + " during the update process"); erroneousPlugins.add(pluginId); result.setResultCode(PluginResultCode.NOK); result.setResultCode(PluginResultCode.OK); result.setUpdatedPluginIds(updateablePlugins); result.setErroneousPluginIds(erroneousPlugins); result.setDelayedPluginIds(delayedPlugins);
public PluginOperation(Config config, PluginOperationOptions options) { super(config); this.options = options; this.result = new PluginOperationResult(); this.eventBus = LocalEventBus.getInstance(); }
private void printResultUpdate(final PluginOperationResult operationResult) { // Print regular result if (operationResult.getResultCode() == PluginResultCode.OK) { if (operationResult.getUpdatedPluginIds().size() == 0) { out.println("All plugins are up to date."); } else { Iterables.removeAll(operationResult.getUpdatedPluginIds(), operationResult.getErroneousPluginIds()); Iterables.removeAll(operationResult.getUpdatedPluginIds(), operationResult.getDelayedPluginIds()); if (operationResult.getDelayedPluginIds().size() > 0) { out.printf("Plugins to be updated: %s\n", StringUtil.join(operationResult.getDelayedPluginIds(), ", ")); } if (operationResult.getUpdatedPluginIds().size() > 0) { out.printf("Plugins successfully updated: %s\n", StringUtil.join(operationResult.getUpdatedPluginIds(), ", ")); } if (operationResult.getErroneousPluginIds().size() > 0) { out.printf("Failed to update %s. Try -d to get more details\n", StringUtil.join(operationResult.getErroneousPluginIds(), ", ")); } out.println(); } } else { out.println("Plugin update failed. Try -d to get more details."); out.println(); } }
private void printResultInstall(PluginOperationResult operationResult) { // Print minimal result if (minimalOutput) { if (operationResult.getResultCode() == PluginResultCode.OK) { out.println("OK"); } else { out.println("NOK"); } } // Print regular result else { if (operationResult.getResultCode() == PluginResultCode.OK) { out.printf("Plugin successfully installed from %s\n", operationResult.getSourcePluginPath()); out.printf("Install location: %s\n", operationResult.getTargetPluginPath()); out.println(); printPluginDetails(operationResult.getAffectedPluginInfo()); printPluginConflictWarning(operationResult); } else { out.println("Plugin installation failed. Try -d to get more details."); out.println(); } } }
private void printResultList(PluginOperationResult operationResult) { if (operationResult.getResultCode() == PluginResultCode.OK) { List<String[]> tableValues = new ArrayList<String[]>(); int thirdPartyCount = 0; for (ExtendedPluginInfo extPluginInfo : operationResult.getPluginList()) { PluginInfo pluginInfo = (extPluginInfo.isInstalled()) ? extPluginInfo.getLocalPluginInfo() : extPluginInfo.getRemotePluginInfo();
@Override public void run() { try { PluginOperation pluginOperation = new PluginOperation(null, concreteRequest.getOptions()); PluginOperationResult operationResult = pluginOperation.execute(); switch (operationResult.getResultCode()) { case OK: eventBus.post(new PluginManagementResponse(PluginManagementResponse.OK, operationResult, request.getId())); break; case NOK: eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_FAILED_UNKNOWN, operationResult, request.getId())); break; } } catch (Exception e) { logger.log(Level.WARNING, "Error executing plugin management request.", e); eventBus.post(new PluginManagementResponse(PluginManagementResponse.NOK_OPERATION_FAILED, new PluginOperationResult(), request.getId())); } } }, "PlugRq/" + concreteRequest.getOptions().getAction());
private void printResultRemove(PluginOperationResult operationResult) { // Print minimal result if (minimalOutput) { if (operationResult.getResultCode() == PluginResultCode.OK) { out.println("OK"); } else { out.println("NOK"); } } // Print regular result else { if (operationResult.getResultCode() == PluginResultCode.OK) { out.printf("Plugin successfully removed.\n"); out.printf("Original local was %s\n", operationResult.getSourcePluginPath()); out.println(); } else { out.println("Plugin removal failed."); out.println(); out.println("Note: Plugins shipped with the application or additional packages"); out.println(" cannot be removed. These plugin are marked 'Global' in the list."); out.println(); } } }
private void printPluginConflictWarning(PluginOperationResult operationResult) { List<String> conflictingPluginIds = operationResult.getConflictingPluginIds(); if (conflictingPluginIds != null && conflictingPluginIds.size() > 0) { out.println("---------------------------------------------------------------------------"); out.printf(" WARNING: The installed plugin '%s' conflicts with other installed:\n", operationResult.getAffectedPluginInfo().getPluginId()); out.printf(" plugin(s): %s\n", StringUtil.join(conflictingPluginIds, ", ")); out.println(); out.println(" If you'd like to use these plugins in the daemon, it is VERY likely"); out.println(" that parts of the application WILL CRASH. Data corruption might occur!"); out.println(); out.println(" Using the plugins outside of the daemon (sy <command> ...) might also"); out.println(" be an issue. Details about this in issue #154."); out.println("---------------------------------------------------------------------------"); out.println(); } }
@Override public void printResults(OperationResult operationResult) { PluginOperationResult concreteOperationResult = (PluginOperationResult) operationResult; switch (concreteOperationResult.getAction()) { case LIST: printResultList(concreteOperationResult); return; case INSTALL: printResultInstall(concreteOperationResult); return; case REMOVE: printResultRemove(concreteOperationResult); return; case UPDATE: printResultUpdate(concreteOperationResult); return; default: out.println("Unknown action: " + concreteOperationResult.getAction()); } }