Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Versionless Repo Resolver additions and Error handling #29058

Merged
merged 8 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,8 @@ public Collection<String> singleFileResolve() {
if (!isInstallServerFeature) {
resolveResult = resolver.resolve((Collection<String>) data.get(InstallConstants.FEATURES_TO_RESOLVE));
} else {
resolveResult = resolver.resolveAsSet((Collection<String>) data.get(InstallConstants.FEATURES_TO_RESOLVE));
// TODO - After Resolver changes, also start passing platforms
// (Collection<String>) data.get(InstallConstants.PLATFORMS));
resolveResult = resolver.resolveAsSet((Collection<String>) data.get(InstallConstants.FEATURES_TO_RESOLVE),
(Collection<String>) data.get(InstallConstants.PLATFORMS));
}

if (!resolveResult.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2014, 2019 IBM Corporation and others.
* Copyright (c) 2014, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
Expand All @@ -15,8 +15,10 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.osgi.service.resolver.ResolutionException;

Expand All @@ -40,14 +42,17 @@ public class RepositoryResolutionException extends RepositoryException {
private final Collection<ProductRequirementInformation> missingProductInformation;
private final Collection<MissingRequirement> allRequirementsResourcesNotFound;
private final Map<String, Collection<Chain>> featureConflicts;
private Set<String> resolvedPlatforms;
private Set<String> missingPlatforms;
private List<String> missingBasePlatforms;

/**
* @param cause
* @param topLevelFeaturesNotResolved
* @param allRequirementsNotFound
* @param missingProductInformation all the product information requirements that could not be found. Can be empty but must not be <code>null</code>
* @param missingProductInformation all the product information requirements that could not be found. Can be empty but must not be <code>null</code>
* @param allRequirementsResourcesNotFound The {@link MissingRequirement} objects that were not found. Must not be <code>null</code>.
* @param featureConflicts the details of any feature conflicts which occurred during feature resolution, as returned from {@link Result#getConflicts()}
* @param featureConflicts the details of any feature conflicts which occurred during feature resolution, as returned from {@link Result#getConflicts()}
*/
public RepositoryResolutionException(ResolutionException cause, Collection<String> topLevelFeaturesNotResolved, Collection<String> allRequirementsNotFound,
Collection<ProductRequirementInformation> missingProductInformation, Collection<MissingRequirement> allRequirementsResourcesNotFound,
Expand All @@ -60,6 +65,33 @@ public RepositoryResolutionException(ResolutionException cause, Collection<Strin
this.featureConflicts = featureConflicts;
}

/**
* @param object
* @param missingTopLevelRequirements
* @param missingRequirementNames
* @param missingProductInformation all the product information requirements that could not be found. Can be empty but must not be <code>null</code>
* @param allRequirementsResourcesNotFound The {@link MissingRequirement} objects that were not found. Must not be <code>null</code>.
* @param featureConflicts the details of any feature conflicts which occurred during feature resolution, as returned from {@link Result#getConflicts()}
* @param resolvedPlatforms
* @param missingPlatforms Unknown platform names
* @param missingBasePlatforms unresolved versionless features needing platforms defined
*/
public RepositoryResolutionException(ResolutionException cause, Collection<String> topLevelFeaturesNotResolved, Collection<String> allRequirementsNotFound,
Azquelt marked this conversation as resolved.
Show resolved Hide resolved
Collection<ProductRequirementInformation> missingProductInformation, Collection<MissingRequirement> allRequirementsResourcesNotFound,
Map<String, Collection<Chain>> featureConflicts, Set<String> resolvedPlatforms, Set<String> missingPlatforms,
List<String> missingBasePlatforms) {
super(cause);
this.topLevelFeaturesNotResolved = topLevelFeaturesNotResolved;
this.allRequirementsNotFound = allRequirementsNotFound;
this.missingProductInformation = missingProductInformation;
this.allRequirementsResourcesNotFound = allRequirementsResourcesNotFound;
this.featureConflicts = featureConflicts;
this.resolvedPlatforms = resolvedPlatforms;
this.missingPlatforms = missingPlatforms;
this.missingBasePlatforms = missingBasePlatforms;

}

/**
* Returns a collection of top level feature names that were not resolved.
*
Expand Down Expand Up @@ -106,9 +138,9 @@ public ResolutionException getCause() {
* on a {@link ProductRequirementInformation} is not in the form digit.digit.digit.digit then it will be ignored.
*
* @param productId The product ID to find the minimum missing version for or <code>null</code> to match to all products
* @param version The version to find the minimum missing version for by matching the first three parts so if you supply "9.0.0.0" and this item applies to version "8.5.5.3"
* and "9.0.0.1" then "9.0.0.1" will be returned. Supply <code>null</code> to match all versions
* @param edition The edition to find the minimum missing version for or <code>null</code> to match to all products
* @param version The version to find the minimum missing version for by matching the first three parts so if you supply "9.0.0.0" and this item applies to version "8.5.5.3"
* and "9.0.0.1" then "9.0.0.1" will be returned. Supply <code>null</code> to match all versions
* @param edition The edition to find the minimum missing version for or <code>null</code> to match to all products
* @return The minimum missing version or <code>null</code> if there were no relevant matches
*/
public String getMinimumVersionForMissingProduct(String productId, String version, String edition) {
Expand Down Expand Up @@ -152,7 +184,7 @@ private Collection<LibertyVersion> filterVersions(Collection<LibertyVersion> min
* This method will iterate through the missingProductInformation and returned a filtered collection of all the {@link ProductRequirementInformation#versionRange}s.
*
* @param productId The product ID to find the version for or <code>null</code> to match to all products
* @param edition The edition to find the version for or <code>null</code> to match to all editions
* @param edition The edition to find the version for or <code>null</code> to match to all editions
*
* @return the version ranges which apply to the given product ID and edition
*/
Expand Down Expand Up @@ -185,9 +217,9 @@ private Collection<LibertyVersionRange> filterVersionRanges(String productId, St
* indicate a fairly odd repository setup.</p>
*
* @param productId The product ID to find the maximum missing version for or <code>null</code> to match to all products
* @param version The version to find the maximum missing version for by matching the first three parts so if you supply "8.5.5.2" and this item applies to version "8.5.5.3"
* and "9.0.0.1" then "8.5.5.3" will be returned. Supply <code>null</code> to match all versions
* @param edition The edition to find the maximum missing version for or <code>null</code> to match to all products
* @param version The version to find the maximum missing version for by matching the first three parts so if you supply "8.5.5.2" and this item applies to version "8.5.5.3"
* and "9.0.0.1" then "8.5.5.3" will be returned. Supply <code>null</code> to match all versions
* @param edition The edition to find the maximum missing version for or <code>null</code> to match to all products
* @return The maximum missing version or <code>null</code> if there were no relevant matches or the maximum version is unbounded
*/
public String getMaximumVersionForMissingProduct(String productId, String version, String edition) {
Expand Down Expand Up @@ -251,6 +283,16 @@ public Map<String, Collection<Chain>> getFeatureConflicts() {
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder();

if (!getMissingPlatforms().isEmpty()) {
for (String missing : getMissingPlatforms()) {
sb.append("Platform: ").append(missing).append(" couldn't be found, no versionless features will be resolved").append("\n");
}
}
if (getResolvedPlatforms().isEmpty() && getMissingPlatforms().isEmpty()) {
sb.append("Platform couldn't be determined, no versionless features will be resolved").append("\n");
}

for (String missing : getTopLevelFeaturesNotResolved()) {
sb.append("Top level feature not resolved: resource=").append(missing).append("\n");
}
Expand Down Expand Up @@ -329,4 +371,28 @@ private String getResourceName(RepositoryResource resource) {
}
}

/**
* This states the target platforms that were used during the resolution
* @return the resolvedPlatforms
*/
public Set<String> getResolvedPlatforms() {
return resolvedPlatforms;
}

/**
* This describes missspelled or unknown platform names, official names are collected by the feature metadata
* @return the missingPlatforms
*/
public Set<String> getMissingPlatforms() {
return missingPlatforms;
}

/**
* This describes base platforms like "jakartaee" that are not derived, either by passed platform values, or by other included versioned features
* @return the missingBasePlatforms
*/
public List<String> getMissingBasePlatforms() {
return missingBasePlatforms;
}

}
Loading