org.netbeans.api.autoupdate.InstallSupport.Validator Java Examples
The following examples show how to use
org.netbeans.api.autoupdate.InstallSupport.Validator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateDisabledModuleTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testSelf() throws Exception { File f = new File(new File(new File(ud, "config"), "Modules"), "com-example-testmodule-cluster.xml"); f.delete(); assertFalse("No Config file before: " + f, f.exists()); MockServices.setServices(UP.class); UpdateUnit update = UpdateManagerImpl.getInstance().getUpdateUnit(moduleCodeNameBaseForTest()); assertNotNull("There is an NBM to update", update); OperationContainer<InstallSupport> oc = OperationContainer.createForUpdate(); oc.add(update, update.getAvailableUpdates().get(0)); final InstallSupport support = oc.getSupport(); Validator down = support.doDownload(null, true); Installer inst = support.doValidate(down, null); Restarter res = support.doInstall(inst, null); System.setProperty("netbeans.close.no.exit", "true"); support.doRestart(res, null); UpdaterInternal.update(null, null, null); assertFalse("No Config file created in for upgrade: " + f, f.exists()); }
Example #2
Source File: InstallStep.java From netbeans with Apache License 2.0 | 5 votes |
private Validator handleDownload(final InstallSupport support) { if (canceled) { log.fine("Quit handleDownload() because an previous installation was canceled."); return null; } validator = null; boolean finish = false; while (! finish) { finish = tryPerformDownload(support); } return validator; }
Example #3
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Validator doDownload(InstallSupport support) throws OperationException { final String displayName = "Downloading new version of WakaTime plugin..."; ProgressHandle downloadHandle = ProgressHandleFactory.createHandle( displayName, new Cancellable () { @Override public boolean cancel () { return true; } } ); return support.doDownload(downloadHandle, true); }
Example #4
Source File: UpdateHandler.java From netbeans-wakatime with BSD 3-Clause "New" or "Revised" License | 5 votes |
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException { final String displayName = "Validating WakaTime plugin..."; ProgressHandle validateHandle = ProgressHandleFactory.createHandle( displayName, new Cancellable () { @Override public boolean cancel () { return true; } } ); Installer installer = support.doValidate(validator, validateHandle); return installer; }
Example #5
Source File: InstallSupportImpl.java From netbeans with Apache License 2.0 | 4 votes |
@SuppressWarnings("ThrowableResultIgnored") public boolean doValidate (final Validator validator, final ProgressHandle progress/*or null*/) throws OperationException { assert validator != null; Callable<Boolean> validationCallable = new Callable<Boolean>() { @Override public Boolean call() throws Exception { synchronized(LOCK) { assert currentStep != STEP.FINISHED; if (currentStep == STEP.CANCEL) return false; currentStep = STEP.VALIDATION; } final OperationContainer<InstallSupport> container = support.getContainer(); assert container.listInvalid ().isEmpty () : support + ".listInvalid().isEmpty() but " + container.listInvalid () + "\ncontainer: " + container; // start progress if (progress != null) { progress.start (wasDownloaded); } int aggregateVerified = 0; try { for (OperationInfo info : infos) { if (cancelled()) return false; UpdateElementImpl toUpdateImpl = Trampoline.API.impl(info.getUpdateElement()); boolean hasCustom = toUpdateImpl.getInstallInfo().getCustomInstaller() != null; if (hasCustom) { // XXX: validation of custom installed assert false : "InstallSupportImpl cannot support CustomInstaller!"; } else { aggregateVerified += doValidate (info, progress, aggregateVerified); } } } finally { // end progress if (progress != null) { progress.progress(""); progress.finish(); } } return true; } }; boolean retval = false; try { runningTask = getExecutionService ().submit (validationCallable); retval = runningTask.get (); } catch (CancellationException ex) { LOG.log (Level.FINE, "InstallSupport.doValidate was cancelled", ex); // NOI18N return false; } catch(InterruptedException iex) { if (iex.getCause() instanceof OperationException) { throw (OperationException) iex.getCause(); } Exceptions.printStackTrace(iex); } catch(ExecutionException iex) { if (iex.getCause() instanceof SecurityException) { throw new OperationException(OperationException.ERROR_TYPE.MODIFIED, iex.getLocalizedMessage()); } else { if (iex.getCause() instanceof OperationException) { throw (OperationException) iex.getCause(); } Exceptions.printStackTrace(iex); } } return retval; }
Example #6
Source File: ModuleOptions.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "# {0} - module name", "# {1} - module version", "MSG_Installing=Installing {0}@{1}", "# {0} - paterns", "MSG_InstallNoMatch=Cannot install. No match for {0}." }) private void install(final Env env, String... pattern) throws CommandException { if (! initialized()) { refresh(env); } Pattern[] pats = findMatcher(env, pattern); List<UpdateUnit> units = UpdateManager.getDefault().getUpdateUnits(); OperationContainer<InstallSupport> operate = OperationContainer.createForInstall(); for (UpdateUnit uu : units) { if (uu.getInstalled() != null) { continue; } if (!matches(uu.getCodeName(), pats)) { continue; } if (uu.getAvailableUpdates().isEmpty()) { continue; } UpdateElement ue = uu.getAvailableUpdates().get(0); env.getOutputStream().println( Bundle.MSG_Installing(uu.getCodeName(), ue.getSpecificationVersion())); operate.add(ue); } final InstallSupport support = operate.getSupport(); if (support == null) { env.getOutputStream().println(Bundle.MSG_InstallNoMatch(Arrays.asList(pats))); return; } try { env.getOutputStream().println("modules=" + operate.listAll().size()); // NOI18N ProgressHandle downloadHandle = new CLIInternalHandle("downloading-modules", env).createProgressHandle(); // NOI18N downloadHandle.setInitialDelay(0); final Validator res1 = support.doDownload(downloadHandle, null, false); Installer res2 = support.doValidate(res1, null); ProgressHandle installHandle = new CLIInternalHandle("installing-modules", env).createProgressHandle(); // NOI18N installHandle.setInitialDelay(0); Restarter res3 = support.doInstall(res2, installHandle); if (res3 != null) { support.doRestart(res3, null); } } catch (OperationException ex) { // a hack if (OperationException.ERROR_TYPE.INSTALL.equals(ex.getErrorType())) { // probably timeout of loading env.getErrorStream().println(ex.getLocalizedMessage()); throw (CommandException) new CommandException(34, ex.getMessage()).initCause(ex); } else { try { support.doCancel(); throw (CommandException) new CommandException(32, ex.getMessage()).initCause(ex); } catch (OperationException ex1) { throw (CommandException) new CommandException(32, ex1.getMessage()).initCause(ex1); } } } }
Example #7
Source File: InstallTest.java From netbeans with Apache License 2.0 | 4 votes |
public void installPlugin(UpdateElement updateElement) { log(""); log("-----------------------------------------------------------"); log("| INSTALLING FOLLOWING PLUGIN : |"); log("-----------------------------------------------------------"); log("[" + updateElement.getDisplayName() + "]" + updateElement.getCodeName()); int numberOfPluginsToInstall = 0; OperationContainer<InstallSupport> install = OperationContainer.createForInstall(); OperationInfo info = null; try { info = install.add(updateElement); } catch (IllegalArgumentException illegalArgumentException) { fail("Cannot install plugin [" + updateElement.getDisplayName() + "] " + updateElement.getCodeName() + " - probably it has already been installed by some other test. Check .log files of previously executed tests."); illegalArgumentException.printStackTrace(); } log("Broken dependencies:"); log(info.getBrokenDependencies().toString()); numberOfPluginsToInstall++; for (OperationInfo i : install.listAll()) { Set<UpdateElement> reqElements = i.getRequiredElements(); log("List of required plugins is:"); for (UpdateElement reqElm : reqElements) { if (!currentlyUpdatePlugins.contains(reqElm) && !currentlyInstalledPlugins.contains(reqElm) && !currentlyPendingInstalls.contains(reqElm)) { install.add(reqElm); log("[" + reqElm.getDisplayName() + "]" + reqElm.getCodeName()); numberOfPluginsToInstall++; } } } log("Number Of Plugins to install:" + numberOfPluginsToInstall); List<OperationInfo<InstallSupport>> lst = install.listAll(); assertTrue("List of invalid is not empty.", install.listInvalid().isEmpty()); assertTrue("Dependencies broken for plugin '" + updateElement.getDisplayName() + "'." + info.getBrokenDependencies().toString(), info.getBrokenDependencies().size() == 0); InstallSupport is = install.getSupport(); try { Validator v = is.doDownload(null, true); assertNotNull("Validator for " + updateElement + " is not null.", v); Installer installer; try { installer = is.doValidate(v, null); Restarter r = is.doInstall(installer, null); if (r == null) { } else { is.doRestartLater(r); } } catch (OperationException oex) { fail("Unsuccessful operation!"); oex.printStackTrace(); } } catch (Exception e) { fail("Cannot download required plugin or some dependency - probably it doesn't exist"); e.printStackTrace(); } log("-----------------------------------------------------------"); }
Example #8
Source File: UpdateHandler.java From jeddict with Apache License 2.0 | 4 votes |
static Validator doDownload(InstallSupport support) throws OperationException { final String displayName = "Downloading new version of Jeddict plugin..."; ProgressHandle downloadHandle = ProgressHandleFactory.createHandle(displayName, () -> true); return support.doDownload(downloadHandle, true); }
Example #9
Source File: UpdateHandler.java From jeddict with Apache License 2.0 | 4 votes |
static Installer doVerify(InstallSupport support, Validator validator) throws OperationException { final String displayName = "Validating Jeddict plugin..."; ProgressHandle validateHandle = ProgressHandleFactory.createHandle(displayName, () -> true); Installer installer = support.doValidate(validator, validateHandle); return installer; }