PackageManager pm = Framework.getService(PackageManager.class); List<DownloadablePackage> pkgToRemove = pm.getUninstallDependencies(pkg, getTargetPlatform(filterOnPlatform)); boolean restartRequired = InstallAfterRestart.isNeededForPackage(pkg); if (!restartRequired) { return getView("uninstallOnRestart").arg("pkg", pkg).arg("source", source); } else { log.debug("Uninstalling: " + pkgToRemove); for (DownloadablePackage rpkg : pkgToRemove) { LocalPackage localPackage = pus.getPackage(rpkg.getId()); performUninstall(localPackage); uninstallTask = performUninstall(pkg); return getView("uninstallDone").arg("uninstallTask", uninstallTask).arg("pkg", pkg).arg("source", source); return getView("uninstallError").arg("e", e).arg("source", source);
@GET @Produces("text/html") @Path(value = "start/{pkgId}") public Object startUninstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("filterOnPlatform") Boolean filterOnPlatform) { try { PackageUpdateService pus = Framework.getService(PackageUpdateService.class); LocalPackage pkg = pus.getPackage(pkgId); Task uninstallTask = pkg.getUninstallTask(); ValidationStatus status = uninstallTask.validate(); if (status.hasErrors()) { return getView("canNotUninstall").arg("status", status).arg("pkg", pkg).arg("source", source); } PackageManager pm = Framework.getService(PackageManager.class); List<DownloadablePackage> pkgToRemove = pm.getUninstallDependencies(pkg, getTargetPlatform(filterOnPlatform)); if (pkgToRemove.size() > 0) { return getView("displayDependencies").arg("pkg", pkg).arg("pkgToRemove", pkgToRemove).arg("source", source); } return getView("startUninstall").arg("status", status) .arg("uninstallTask", uninstallTask) .arg("pkg", pkg) .arg("source", source); } catch (PackageException e) { log.error("Error during first step of installation", e); return getView("uninstallError").arg("e", e); } }
@GET @Produces("text/html") @Path(value = "start/{pkgId}") public Object startUninstall(@PathParam("pkgId") String pkgId, @QueryParam("source") String source, @QueryParam("filterOnPlatform") Boolean filterOnPlatform) { try { PackageUpdateService pus = Framework.getLocalService(PackageUpdateService.class); LocalPackage pkg = pus.getPackage(pkgId); Task uninstallTask = pkg.getUninstallTask(); ValidationStatus status = uninstallTask.validate(); if (status.hasErrors()) { return getView("canNotUninstall").arg("status", status).arg("pkg", pkg).arg("source", source); } PackageManager pm = Framework.getLocalService(PackageManager.class); List<DownloadablePackage> pkgToRemove = pm.getUninstallDependencies(pkg, getTargetPlatform(filterOnPlatform)); if (pkgToRemove.size() > 0) { return getView("displayDependencies").arg("pkg", pkg).arg("pkgToRemove", pkgToRemove).arg("source", source); } return getView("startUninstall").arg("status", status).arg("uninstallTask", uninstallTask).arg("pkg", pkg).arg( "source", source); } catch (PackageException e) { log.error("Error during first step of installation", e); return getView("uninstallError").arg("e", e); } }
PackageManager pm = Framework.getLocalService(PackageManager.class); List<DownloadablePackage> pkgToRemove = pm.getUninstallDependencies(pkg, getTargetPlatform(filterOnPlatform)); boolean restartRequired = InstallAfterRestart.isNeededForPackage(pkg); if (!restartRequired) { return getView("uninstallOnRestart").arg("pkg", pkg).arg("source", source); } else { log.debug("Uninstalling: " + pkgToRemove); for (DownloadablePackage rpkg : pkgToRemove) { LocalPackage localPackage = pus.getPackage(rpkg.getId()); performUninstall(localPackage); uninstallTask = performUninstall(pkg); return getView("uninstallDone").arg("uninstallTask", uninstallTask).arg("pkg", pkg).arg("source", source); return getView("uninstallError").arg("e", e).arg("source", source);