Skip to content

Commit

Permalink
Fixup syntax and javadoc based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cbridgha committed Jul 16, 2024
1 parent 9a7cd49 commit d5a3db5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* 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
Expand Down Expand Up @@ -44,7 +44,6 @@ public class RepositoryResolutionException extends RepositoryException {
private final Map<String, Collection<Chain>> featureConflicts;
private Set<String> resolvedPlatforms;
private Set<String> missingPlatforms;
private boolean hasVersionlessIssue;
private List<String> missingBasePlatforms;

/**
Expand Down Expand Up @@ -373,20 +372,23 @@ 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.ibm.ws.kernel.feature.provisioning.ProvisioningFeatureDefinition;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Chain;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Repository;
import com.ibm.ws.kernel.feature.resolver.FeatureResolver.Result;
import com.ibm.ws.kernel.productinfo.ProductInfo;
import com.ibm.ws.product.utility.extension.IFixUtils;
Expand Down Expand Up @@ -146,11 +145,10 @@ public class RepositoryResolver {
* List of all the missing platforms after resolution
*/
Set<String> missingPlatforms;

/**
* Indicates if an issue was found resolving versionless features and platforms
* returns if versionless features are part of the resolution - used to skip extra processing
*/
boolean hasVersionlessIssue;
boolean includesVersionless;

/**
* <p>
Expand Down Expand Up @@ -367,6 +365,8 @@ public Collection<List<RepositoryResource>> resolve(String toResolve) throws Rep
* For example, if {@code ejbLite-3.2} is already installed and {@code resolve(Arrays.asList("cdi-2.0"))} is called, it will not return the autofeature which would be required
* for {@code cdi-2.0} and {@code ejbLite-3.2} to work together.
*
* @deprecated - calling this method should be replaced by passing the platform list, required to support versionless features.
*
* @param toResolve A collection of the identifiers of the resources to resolve. It should be in the form:</br>
* <code>{name}/{version}</code></br>
* <p>Where the <code>{name}</code> can be either the symbolic name, short name or lower case short name of the resource and <code>/{version}</code> is
Expand All @@ -389,6 +389,7 @@ public Collection<List<RepositoryResource>> resolve(String toResolve) throws Rep
*
* @throws RepositoryResolutionException If the resource cannot be resolved
*/
@Deprecated
public Collection<List<RepositoryResource>> resolveAsSet(Collection<String> toResolve) throws RepositoryResolutionException {
return resolve(toResolve, null, ResolutionMode.DETECT_CONFLICTS);
}
Expand Down Expand Up @@ -502,7 +503,7 @@ void initResolve() {
featureConflicts = new HashMap<>();
resolvedPlatforms = new HashSet<>();
missingPlatforms = new HashSet<>();
hasVersionlessIssue = false;
includesVersionless = false;
}

/**
Expand Down Expand Up @@ -567,8 +568,11 @@ void resolveFeaturesAsSet() {
Result result = resolver.resolve(resolverRepository, kernelFeatures, featureNamesToResolve, Collections.<String> emptySet(), false, requestedPlatformNames);

featureConflicts.putAll(result.getConflicts());
if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository))
recordVersionless(result, resolverRepository);
if (hasRequestedVersionlessFeatures(featureNamesToResolve, resolverRepository)) {
includesVersionless = true;
resolvedPlatforms = result.getResolvedPlatforms();
missingPlatforms = result.getMissingPlatforms();
}

for (String name : result.getResolvedFeatures()) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
Expand All @@ -580,22 +584,6 @@ void resolveFeaturesAsSet() {
}
}

/**
* Record Versionless Messages and Issues
*
* @param result
* @param resolverRepo
* @param requestedFeatures
*/
private void recordVersionless(Result result, Repository resolverRepo) {

resolvedPlatforms = result.getResolvedPlatforms();
missingPlatforms = result.getMissingPlatforms();
if (resolvedPlatforms.isEmpty() || !missingPlatforms.isEmpty())
hasVersionlessIssue = true;

}

/**
* Resolves {@link #featureNamesToResolve} using a simple traversal of the dependency tree
*
Expand Down Expand Up @@ -1005,21 +993,27 @@ private EsaResource getResource(ProvisioningFeatureDefinition feature) {
* @throws RepositoryResolutionException if any errors occurred during resolution
*/
private void reportErrors() throws RepositoryResolutionException {
if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty() && !hasVersionlessIssue()) {
if (resourcesWrongProduct.isEmpty() && missingTopLevelRequirements.isEmpty() && missingRequirements.isEmpty() && featureConflicts.isEmpty()
&& (!includesVersionless || ((!resolvedPlatforms.isEmpty()) && (missingPlatforms.isEmpty())))) {
// Everything went fine!
return;
}

List<String> missingBasePlatforms = new ArrayList<String>();

// Versionless feature issues will appear in missingTopLevelRequirements, and this will gather the associated platform unable to target.
for (String name : missingTopLevelRequirements) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
if (feature != null && feature.isVersionless()) {
ProvisioningFeatureDefinition firstChild = resolverRepository.findAllPossibleVersions(feature).get(0);
String plat = firstChild.getPlatformName();
if (plat != null) {//This will add just the platform name without version
missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
// Versionless features can't be resolved if a corresponding platform is not derived, making the choice ambiguous, and the feature won't be included in the resolved list. - will gather the associated platform unable to target.
if (includesVersionless) {
for (String name : missingTopLevelRequirements) {
ProvisioningFeatureDefinition feature = resolverRepository.getFeature(name);
if (feature != null && feature.isVersionless()) {
List<ProvisioningFeatureDefinition> featureChildren = resolverRepository.findAllPossibleVersions(feature);
if (!featureChildren.isEmpty()) {
ProvisioningFeatureDefinition firstChild = featureChildren.get(0);
String plat = firstChild.getPlatformName();
if (plat != null) {//This will add just the platform name without version
missingBasePlatforms.add(resolverRepository.getFeatureBaseName(plat));
}
}
}
}
}
Expand Down Expand Up @@ -1054,14 +1048,6 @@ private void reportErrors() throws RepositoryResolutionException {
resolvedPlatforms, missingPlatforms, missingBasePlatforms);
}

/**
* @return
*/
protected boolean hasVersionlessIssue() {

return hasVersionlessIssue;
}

static class NameAndVersion {

public NameAndVersion(String name, String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,12 @@ public boolean isVersionless() {
return false;
}

if (getSymbolicName().indexOf(".versionless.") == -1) {
return false;
} else if (getSymbolicName().indexOf(".internal.versionless.") != -1) {
if (getSymbolicName().contains(".versionless.")
&& !getSymbolicName().contains(".internal.")) {
return true;
} else {
return false;
}

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public List<ProvisioningFeatureDefinition> findAllPossibleVersions(ProvisioningF
publicFeature = getVersionedFeature(dependency.getSymbolicName());
if (publicFeature != null)
result.add(publicFeature);

String baseName = getFeatureBaseName(dependency.getSymbolicName());
List<String> tolerates = dependency.getTolerates();
if (tolerates != null) {
Expand All @@ -275,13 +275,13 @@ public List<ProvisioningFeatureDefinition> findAllPossibleVersions(ProvisioningF

/**
*
* Answer the public versioned feature based on the internal versionless linking feature
* Answer the public versioned feature based on the internal versionless linking feature, or null if can't be found
*
* @param versionlessLinkingFeatureName
* @return ProvisioningFeatureDefinition
*/
private ProvisioningFeatureDefinition getVersionedFeature(String versionlessLinkingFeatureName) {
ProvisioningFeatureDefinition result = null;

ProvisioningFeatureDefinition feature = getFeature(versionlessLinkingFeatureName);
if (feature != null) {
//This is the versionless linking feature pointing to a public versioned feature
Expand Down

0 comments on commit d5a3db5

Please sign in to comment.