public Extension resolve(ExtensionId extensionId) throws ResolveException { LocalExtension localExtension = this.extensions.get(extensionId); if (localExtension == null) { throw new ResolveException("Can't find extension [" + extensionId + "]"); } return localExtension; }
public Collection<LocalExtension> getBackwardDependencies(String id, String namespace) throws ResolveException { if (getInstalledExtension(id, namespace) == null) { throw new ResolveException("Extension [" + id + "] does is not installed"); } Map<String, Set<LocalExtension>> namespaceBackwardDependenciesMap = this.backwardDependenciesMap.get(id); Set<LocalExtension> backwardDependencies = namespaceBackwardDependenciesMap != null ? namespaceBackwardDependenciesMap.get(id) : null; return backwardDependencies != null ? Collections.unmodifiableCollection(backwardDependencies) : Collections .<LocalExtension> emptyList(); }
public Extension resolve(ExtensionId extensionId) throws ResolveException { Model model; try { model = loadPom(this.session, extensionId); } catch (Exception e) { throw new ResolveException("Failed to resolve extension [" + extensionId + "] descriptor", e); } try { return new AetherExtension(extensionId, model, this, this.plexusComponentManager); } catch (ComponentLookupException e) { throw new ResolveException("Failed to resolve extension [" + extensionId + "]", e); } }
@Override public Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace) throws ResolveException { if (getInstalledExtension(feature, namespace) == null) { throw new ResolveException( String.format("Extension [%s] is not installed on namespace [%s]", feature, namespace)); } Map<String, InstalledFeature> installedExtensionsByFeature = this.extensionNamespaceByFeature.get(feature); if (installedExtensionsByFeature != null) { InstalledFeature installedExtension = installedExtensionsByFeature.get(namespace); if (installedExtension != null) { Set<DefaultInstalledExtension> backwardDependencies = installedExtension.root.backwardDependencies; // copy the list to allow use cases like uninstalling all backward dependencies without getting a // concurrent issue on the list return backwardDependencies.isEmpty() ? Collections.<InstalledExtension>emptyList() : new ArrayList<InstalledExtension>(backwardDependencies); } } return Collections.emptyList(); }
private org.eclipse.aether.version.Version resolveVersionConstraint(Artifact artifact, RepositorySystemSession session) throws ResolveException { try { List<org.eclipse.aether.version.Version> versions = resolveVersions(artifact, session); if (versions.isEmpty()) { throw new ExtensionNotFoundException("No versions available for artifact [" + artifact + "]"); } return versions.get(versions.size() - 1); } catch (Exception e) { throw new ResolveException("Failed to resolve version range", e); } }
@Override public Extension resolve(ExtensionId extensionId) throws ResolveException { ResolveException lastException = null; for (ExtensionRepository repository : this.repositories) { try { return repository.resolve(extensionId); } catch (ExtensionNotFoundException e1) { this.logger.debug("Could not find extension [{}] in repository [{}]", extensionId, repository.getDescriptor(), e1); } catch (ResolveException e2) { this.logger.error("Unexpected error when trying to find extension [{}] in repository [{}]", extensionId, repository.getDescriptor(), e2); lastException = e2; } } if (lastException != null) { throw new ResolveException(MessageFormat.format("Failed to resolve extension [{0}]", extensionId), lastException); } else { throw new ExtensionNotFoundException(MessageFormat.format("Could not find extension [{0}]", extensionId)); } }
private List<ExtensionDependency> toAetherDependencies(Collection<ExtensionDependency> mavenDependencies, RepositorySystemSession session) throws ResolveException { List<ExtensionDependency> dependencies = new ArrayList<>(mavenDependencies.size()); try { ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry(); for (ExtensionDependency mavenDependency : mavenDependencies) { dependencies.add(new AetherExtensionDependency(mavenDependency, convertToAether(((MavenExtensionDependency) mavenDependency).getMavenDependency(), stereotypes), this.getDescriptor())); } } catch (Exception e) { throw new ResolveException("Failed to resolve dependencies", e); } return dependencies; }
public Extension resolve(ExtensionId extensionId) throws ResolveException { Extension artifact = null; for (ExtensionRepository repository : this.repositories.values()) { try { artifact = repository.resolve(extensionId); return artifact; } catch (ResolveException e) { getLogger().debug( "Could not find extension [" + extensionId + "] in repository [" + repository.getId() + "]"); } } throw new ResolveException("Could not find extension [" + extensionId + "]"); } }
private List<org.eclipse.aether.version.Version> resolveVersionRange(String id, VersionRange versionRange, RepositorySystemSession session) throws ResolveException { Artifact artifact = AetherUtils.createArtifact(id, versionRange.getValue()); try { List<org.eclipse.aether.version.Version> versions = resolveVersions(artifact, session); if (versions.isEmpty()) { throw new ExtensionNotFoundException( "No versions available for id [" + id + "] and version range [" + versionRange + "]"); } return versions; } catch (Exception e) { throw new ResolveException("Failed to resolve version range", e); } }
@Override public Extension resolve(ExtensionId extensionId) throws ResolveException { try { if (getDescriptor().getType().equals("maven") && this.mavenDescriptorReader != null) { return resolveMaven(extensionId); } else { // FIXME: impossible to resolve extension type as well as most of the information with pure Aether API throw new ResolveException("Unsupported"); } } catch (InvalidExtensionIdException e) { // In case the id is invalid behave as if the extension simply did not exist (which is true anyway) throw new ExtensionNotFoundException("Invalid extension id", e); } }
@Override public Extension resolve(ExtensionDependency extensionDependency) throws ResolveException { try { if (getDescriptor().getType().equals("maven") && this.mavenDescriptorReader != null) { return resolveMaven(extensionDependency); } else { // FIXME: impossible to resolve extension type as well as most of the information with pure Aether API throw new ResolveException("Unsupported"); } } catch (InvalidExtensionIdException e) { // In case the id is invalid behave as if the extension simply did not exist (which is true anyway) throw new ExtensionNotFoundException("Invalid extension id", e); } }
@Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { Artifact artifact; try { artifact = AetherUtils.createArtifact(id, "(,)"); } catch (InvalidExtensionIdException e) { // In case the id is invalid behave as if the extension simply did not exist (which is true anyway) throw new ExtensionNotFoundException("Invalid extension id", e); } List<org.eclipse.aether.version.Version> versions; try (XWikiRepositorySystemSession session = createRepositorySystemSession()) { versions = resolveVersions(artifact, session); } catch (Exception e) { throw new ResolveException("Failed to resolve versions for id [" + id + "]", e); } if (versions.isEmpty()) { throw new ExtensionNotFoundException("No versions available for id [" + id + "]"); } if (nb == 0 || offset >= versions.size()) { return new CollectionIterableResult<Version>(versions.size(), offset, Collections.<Version>emptyList()); } int fromId = offset < 0 ? 0 : offset; int toId = offset + nb > versions.size() || nb < 0 ? versions.size() : offset + nb; List<Version> result = new ArrayList<Version>(toId - fromId); for (int i = fromId; i < toId; ++i) { result.add(new DefaultVersion(versions.get(i).toString())); } return new CollectionIterableResult<Version>(versions.size(), offset, result); }
protected XWikiRepositorySystemSession createRepositorySystemSession() throws ResolveException { XWikiRepositorySystemSession session; try { session = this.repositoryFactory.createRepositorySystemSession(); } catch (IOException e) { throw new ResolveException("Failed to create the repository system session", e); } session.addConfigurationProperties(getDescriptor().getProperties()); return session; }
public Extension resolve(ExtensionId extensionId) throws ResolveException { Extension extension = getCoreExtension(extensionId.getId()); if (extension == null || (extensionId.getVersion() != null && !extension.getId().getVersion().equals(extensionId.getVersion()))) { throw new ResolveException("Could not find extension [" + extensionId + "]"); } return extension; }
return AETHERVERSIONSCHEME.parseVersion(versionConstraint.getVersion().getValue()); } catch (InvalidVersionSpecificationException e) { throw new ResolveException("Invalid version [" + versionConstraint.getVersion() + "]", e); return AETHERVERSIONSCHEME.parseVersion(strictVersion.getValue()); } catch (InvalidVersionSpecificationException e) { throw new ResolveException("Invalid version [" + versionConstraint.getVersion() + "]", e);
throw new ResolveException( MessageFormat.format("Failed to resolve extension dependency [{0}]", extensionDependency), lastException);
throw new ExtensionNotFoundException("Could not find artifact [" + artifact + "] descriptor", e1); } else { throw new ResolveException("Failed to resolve artifact [" + artifact + "] descriptor", e1); throw new ResolveException("Failed to resolve artifact [" + artifact + "] descriptor", e2); model = createModel(pomArtifact.getFile(), session); } catch (ModelBuildingException e) { throw new ResolveException("Failed to create Maven model", e); throw new ResolveException("Failed to resolve artifact [" + artifact + "] descriptor");