Skip to content

Commit

Permalink
Merge pull request #667 from eclipse-passage/571326
Browse files Browse the repository at this point in the history
Bug 571325 encrypted licenses cannot be issued

remove tests file

Signed-off-by: eparovyshnaya <[email protected]>
  • Loading branch information
eparovyshnaya committed Feb 23, 2021
1 parent cdbccd6 commit 1513386
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 44 deletions.
1 change: 1 addition & 0 deletions bundles/org.eclipse.passage.loc.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Require-Bundle: org.eclipse.e4.core.services;bundle-version="0.0.0",
org.eclipse.passage.lic.products;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.passage.lic.users;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.passage.lic.users.model;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.passage.loc.dashboard.ui.wizards.floating;

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

Expand All @@ -37,6 +38,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public final class IssueLicensePackPage extends WizardPage {

Expand All @@ -45,7 +47,7 @@ public final class IssueLicensePackPage extends WizardPage {
private final Adapter update = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
setPageComplete(validatePage());
updatePageComplete();
}
};
private FloatingLicensePack license;
Expand Down Expand Up @@ -85,38 +87,45 @@ public void createControl(Composite parent) {
}

private void init() {
boolean render = license == null;
createLicensePack();
if (render) {
updatePage();
}
updatePage();
}

private void createLicensePack() {
if (license != null) {
license.eAdapters().remove(update);
} else {
license = context.get(OperatorLicenseService.class)//
.createFloatingLicensePack(data.get(), Optional.ofNullable(license));
license.eAdapters().add(update);
}
license = context.get(OperatorLicenseService.class)//
.createFloatingLicensePack(data.get(), Optional.ofNullable(license));
license.eAdapters().add(update);
}

private void updatePage() {
if (base == null || base.isDisposed()) {
setPageComplete(false);
return;
}
if (license != null) {
try {
ECPSWTViewRenderer.INSTANCE.render(base, license, properties);
base.layout();
} catch (ECPRendererException e) {
}
}
renderEmfForms();
updatePageComplete();
}

private void updatePageComplete() {
setPageComplete(validatePage());
}

private void renderEmfForms() {
if (license == null) {
return;
}
try {
Arrays.asList(base.getChildren()).forEach(Control::dispose);
ECPSWTViewRenderer.INSTANCE.render(base, license, properties);
base.layout(); // guaranteed to exist and been not disposed
} catch (ECPRendererException e) {
// do nothing
}
}

protected boolean validatePage() {
String errors = LicensingEcore.extractValidationError(license);
setErrorMessage(errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected SelectableField(Optional<T> source, Runnable modified, LabelProvider l

@Override
public Optional<String> error() {
return data().isEmpty() ? Optional.of(errorText()) : Optional.empty();
return noData() ? Optional.of(errorText()) : Optional.empty();
}

@Override
Expand Down Expand Up @@ -75,6 +75,17 @@ private void installSelectButton(Composite parent) {
select.setLayoutData(GridDataFactory.fillDefaults().create());
}

private boolean noData() {
Optional<T> data = data();
if (!data.isPresent()) {
return true;
}
if (data.get() instanceof Collection<?>) {
return ((Collection<?>) data.get()).isEmpty();
}
return false;
}

@Override
protected void enableAuxiliaryControls(boolean enable) {
select.setEnabled(enable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private FeatureGrant featureGrant(LicensePlanFeatureDescriptor feature, Floating
FeatureGrant grant = FloatingFactory.eINSTANCE.createFeatureGrant();
String fid = feature.getFeatureIdentifier();
grant.setFeature(fid);
grant.setCapacity(featureGrantCapacity(fid));
grant.setCapacity(request.defaultCapacity());
grant.setIdentifier(String.format("%s#%d", request.identifier(), no)); //$NON-NLS-1$
grant.setPack(pack);
grant.setValid(featureGrantPeriod(fid));
Expand All @@ -191,13 +191,6 @@ private FeatureGrant featureGrant(LicensePlanFeatureDescriptor feature, Floating
return grant;
}

private int featureGrantCapacity(String feature) {
return template//
.flatMap(l -> forFeature(l.getFeatures(), feature)) //
.map(FeatureGrant::getCapacity)//
.orElseGet(request::defaultCapacity);
}

private ValidityPeriod featureGrantPeriod(String feature) {
return template//
.flatMap(l -> forFeature(l.getFeatures(), feature)) //
Expand Down

This file was deleted.

0 comments on commit 1513386

Please sign in to comment.