private Map<String, Set<InstalledExtension>> getBackwardDependencies( Collection<InstalledExtension> installedExtensions, String namespace) throws ResolveException { Map<String, Set<InstalledExtension>> backwardDependencies = new LinkedHashMap<>(); for (InstalledExtension installedExtension : installedExtensions) { if (namespace == null) { for (Map.Entry<String, Collection<InstalledExtension>> entry : this.installedExtensionRepository .getBackwardDependencies(installedExtension.getId()).entrySet()) { Set<InstalledExtension> namespaceBackwardDependencies = backwardDependencies.get(entry.getKey()); if (namespaceBackwardDependencies == null) { namespaceBackwardDependencies = new LinkedHashSet<>(); backwardDependencies.put(entry.getKey(), namespaceBackwardDependencies); } namespaceBackwardDependencies.addAll(entry.getValue()); } } else { for (InstalledExtension backwardDependency : this.installedExtensionRepository .getBackwardDependencies(installedExtension.getId().getId(), namespace)) { Set<InstalledExtension> namespaceBackwardDependencies = backwardDependencies.get(namespace); if (namespaceBackwardDependencies == null) { namespaceBackwardDependencies = new LinkedHashSet<>(); backwardDependencies.put(namespace, namespaceBackwardDependencies); } namespaceBackwardDependencies.add(backwardDependency); } } } return backwardDependencies; }
private void unloadJARFromNamespace(InstalledExtension installedExtension, String namespace, Map<String, Set<InstalledExtension>> unloadedExtensions, Set<InstalledExtension> unloadedExtensionsInNamespace) throws UninstallException { try { Collection<InstalledExtension> bDependencies = this.installedExtensionRepository .getBackwardDependencies(installedExtension.getId().getId(), namespace); for (InstalledExtension bDependency : bDependencies) { unloadJAR(bDependency, namespace, unloadedExtensions); } } catch (ResolveException e) { this.logger.error("Failed to get backward dependencies for installed extension [{}] on namespace [{}]", installedExtension, namespace, e); } this.jarHandler.uninstall(installedExtension, namespace, null); unloadedExtensionsInNamespace.add(installedExtension); } }
try { Map<String, Collection<InstalledExtension>> bDependencies = this.installedExtensionRepository.getBackwardDependencies(installedExtension.getId());
/** * @param installedExtension the extension to uninstall * @param parentBranch the children of the parent {@link ExtensionPlanNode} * @param withBackWard uninstall also the backward dependencies * @throws UninstallException error when trying to uninstall backward dependencies * @throws ResolveException error when trying to resolve backward dependencies */ protected void uninstallBackwardDependencies(InstalledExtension installedExtension, List<ExtensionPlanNode> parentBranch, boolean withBackWard) throws UninstallException, ResolveException { Map<String, Collection<InstalledExtension>> backwardDependencies = this.installedExtensionRepository.getBackwardDependencies(installedExtension.getId()); this.progressManager.pushLevelProgress(backwardDependencies.size(), this); try { for (Map.Entry<String, Collection<InstalledExtension>> entry : backwardDependencies.entrySet()) { this.progressManager.startStep(this); uninstallExtensions(entry.getValue(), entry.getKey(), parentBranch, withBackWard); this.progressManager.endStep(this); } } finally { this.progressManager.popLevelProgress(this); } } }
/** * Get all backward dependencies by namespace for the provided installed extension. * * @param extensionId the extension identifier * @return the extension backward dependencies in all namespaces, or {@code null} if any error occurs while * computing the result, in which case {@link #getLastError()} contains the failure reason */ public Map<String, Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId) { Map<String, Collection<InstalledExtension>> extensions; setError(null); try { return safe(this.installedExtensionRepository.getBackwardDependencies(extensionId)); } catch (Exception e) { setError(e); extensions = null; } return extensions; }
@Override public Map<String, Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId) { setError(null); try { return safe(getWrapped().getBackwardDependencies(extensionId)); } catch (Exception e) { setError(e); } return null; }
@Override public Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace) { setError(null); try { return safe(getWrapped().getBackwardDependencies(feature, namespace)); } catch (Exception e) { setError(e); } return null; }
/** * Get provided installed extension backward dependencies in the provided namespace. * <p> * Only look at the backward dependencies in the provided namespace. To get all the dependencies of a root extension * (namespace=null) across namespaces use {@link #getBackwardDependencies(ExtensionId)} instead. * * @param feature the extension unique identifier * @param namespace the namespace where to search for backward dependencies * @return the backward dependencies, an empty collection of none could be found, or {@code null} if any error * occurs while computing the result, in which case {@link #getLastError()} contains the failure reason */ public Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace) { Collection<InstalledExtension> extensions; setError(null); try { return safe(this.installedExtensionRepository.getBackwardDependencies(feature, namespace)); } catch (Exception e) { setError(e); extensions = null; } return extensions; } }
if (extension.getNamespaces() == null) { hasBackwardDependencies = !this.installedExtensionRepository.getBackwardDependencies(extension.getId()).isEmpty(); } else { hasBackwardDependencies = !this.installedExtensionRepository .getBackwardDependencies(extension.getId().getId(), namespace).isEmpty();
/** * @param installedExtension the extension to uninstall * @param namespace the namespace from where to uninstall the extension * @param parentBranch the children of the parent {@link ExtensionPlanNode} * @param withBackWard uninstall also the backward dependencies * @throws UninstallException error when trying to uninstall backward dependencies * @throws ResolveException error when trying to resolve backward dependencies */ protected void uninstallBackwardDependencies(InstalledExtension installedExtension, String namespace, List<ExtensionPlanNode> parentBranch, boolean withBackWard) throws UninstallException { try { if (namespace != null) { Collection<InstalledExtension> installedExtensions = this.installedExtensionRepository .getBackwardDependencies(installedExtension.getId().getId(), namespace); if (!installedExtensions.isEmpty()) { uninstallExtensions(installedExtensions, namespace, parentBranch, withBackWard); } } else { uninstallBackwardDependencies(installedExtension, parentBranch, withBackWard); } } catch (ResolveException e) { throw new UninstallException( "Failed to resolve backward dependencies of extension [" + installedExtension + "]", e); } }
if (installedExtension.isInstalled(null)) { Map<String, Collection<InstalledExtension>> backwardDependencies = this.installedExtensionRepository.getBackwardDependencies(installedExtension.getId()); .getBackwardDependencies(installedExtension.getId().getId(), namespace);