Skip to content

Commit

Permalink
Merge pull request #507 from eclipse-passage/567032-4
Browse files Browse the repository at this point in the history
Bug 567032 issue floating license configuration wizard
  • Loading branch information
eparovyshnaya authored Nov 3, 2020
2 parents 3e2067e + 794c41c commit a122922
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.passage.lic.internal.base.conditions;

import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.conditions.MatchingRule;
Expand All @@ -25,6 +26,11 @@ public MatchingRuleForIdentifier(String identifier) {
this.identifier = identifier;
}

public MatchingRuleForIdentifier(Optional<String> identifier) {
Objects.requireNonNull(identifier, "MatchingRuleForIdentifier::identifier"); //$NON-NLS-1$
this.identifier = identifier.isPresent() ? identifier.get() : new MatchingRuleDefault().identifier();
}

@Override
public MatchingRule get() {
switch (identifier.toLowerCase()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.passage.lic.floating.model.api.VersionMatch;
import org.eclipse.passage.lic.floating.model.meta.FloatingFactory;
import org.eclipse.passage.lic.internal.api.conditions.EvaluationType;
import org.eclipse.passage.lic.internal.base.conditions.MatchingRuleForIdentifier;
import org.eclipse.passage.lic.internal.base.inspection.hardware.Disk;
import org.eclipse.passage.lic.licenses.LicensePlanDescriptor;
import org.eclipse.passage.lic.licenses.LicensePlanFeatureDescriptor;
Expand Down Expand Up @@ -138,7 +139,7 @@ private Collection<UserGrant> userGrants() {
private UserGrant userGrant(UserDescriptor user) {
UserGrant grant = FloatingFactory.eINSTANCE.createUserGrant();
grant.setAuthentication(userAuthentication(user));
grant.setUser(user.getIdentifier());
grant.setUser(user.getEmail());
return grant;
}

Expand Down Expand Up @@ -218,7 +219,7 @@ private Optional<FeatureGrant> forFeature(List<FeatureGrant> all, String feature
private VersionMatch version(LicensePlanFeatureDescriptor feature) {
VersionMatch version = FloatingFactory.eINSTANCE.createVersionMatch();
version.setVersion(feature.getMatchVersion());
version.setRule(feature.getMatchRule());
version.setRule(new MatchingRuleForIdentifier(Optional.ofNullable(feature.getMatchRule())).get().identifier());
return version;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public EvaluationInstructions userAuthentication(String user) {

private UserDescriptor user(String identifier) {
return users.get().stream()//
.filter(user -> identifier.equals(user.getIdentifier()))//
.filter(user -> identifier.equals(user.getEmail()))//
.findAny()//
.get(); // yah, fail if not found, it's a development problem
}
Expand Down

0 comments on commit a122922

Please sign in to comment.