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

Bug 567032 issue floating license configuration wizard #507

Merged
merged 2 commits into from
Nov 3, 2020
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 @@ -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