diff --git a/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/EncodedResponse.java b/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/EncodedResponse.java index a0a7b179e..a278b8000 100644 --- a/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/EncodedResponse.java +++ b/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/EncodedResponse.java @@ -18,6 +18,7 @@ import org.eclipse.passage.lbc.internal.base.api.FlsGear; import org.eclipse.passage.lbc.internal.base.api.FlsGearAwre; import org.eclipse.passage.lbc.internal.base.api.RawRequest; +import org.eclipse.passage.lic.internal.api.LicensingException; import org.eclipse.passage.lic.internal.api.io.Hashes; import org.eclipse.passage.lic.internal.api.io.KeyKeeper; import org.eclipse.passage.lic.internal.api.registry.StringServiceId; @@ -37,9 +38,14 @@ public EncodedResponse(T payload, ProductUserRequest data) { } public NetResponse get() { - return new FlsGearAwre()// - .withGear(this::transferable) // - .orElse(new Failure.OperationFailed("mine", "Failed exploiting gear")); //$NON-NLS-1$ //$NON-NLS-2$ + try { + return new FlsGearAwre()// + .withGear(this::transferable) // + .orElse(new Failure.OperationFailed("mine", "Failed exploiting gear")); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (LicensingException e) { + // unreachable, development mistake + throw new IllegalStateException("FLS configurational is not complete", e); //$NON-NLS-1$ + } } private Optional transferable(FlsGear gear) { diff --git a/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/FeatureGrants.java b/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/FeatureGrants.java index 64b6036d4..76663c293 100644 --- a/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/FeatureGrants.java +++ b/bundles/org.eclipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/FeatureGrants.java @@ -48,9 +48,13 @@ final class FeatureGrants { * given {@code feature}, if any */ Collection get() { - return new FlsGearAwre()// - .withGear(gear -> Optional.of(get(gear)))// - .orElse(failedOnGathering()); + try { + return new FlsGearAwre()// + .withGear(gear -> Optional.of(get(gear)))// + .orElse(failedOnGathering()); + } catch (LicensingException e) { + return exceptionOnGathering(e); + } } private Collection failedOnGathering() { @@ -58,6 +62,11 @@ private Collection failedOnGathering() { return Collections.emptyList(); } + private Collection exceptionOnGathering(LicensingException e) { + log.error(String.format("Failed on gathering grants for product %s", product), e); //$NON-NLS-1$ + return Collections.emptyList(); + } + private Collection get(FlsGear gear) { try { return new LicensePacks(// diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/GearAware.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/GearAware.java index b76b48fab..99ae56c91 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/GearAware.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/GearAware.java @@ -15,12 +15,12 @@ import java.util.Collection; import java.util.Collections; import java.util.Optional; -import java.util.function.Function; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.eclipse.passage.lic.internal.api.Gear; import org.eclipse.passage.lic.internal.api.GearSupplier; +import org.eclipse.passage.lic.internal.api.LicensingException; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; @@ -30,7 +30,7 @@ public abstract class GearAware> { private final Logger log = LogManager.getLogger(getClass()); - public final Optional withGear(Function> with) { + public final Optional withGear(Unsafe with) throws LicensingException { BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext(); Collection> references = Collections.emptyList(); try { @@ -46,6 +46,8 @@ public final Optional withGear(Function> with) { ServiceReference any = references.iterator().next(); try { return with.apply(context.getService(any).gear()); + } catch (Exception e) { + throw new LicensingException("Error on service invokation", e); //$NON-NLS-1$ } finally { context.ungetService(any); } @@ -53,4 +55,10 @@ public final Optional withGear(Function> with) { protected abstract Class supplier(); + @FunctionalInterface + public interface Unsafe { + + Optional apply(G gear) throws Exception; + + } } diff --git a/bundles/org.eclipse.passage.loc.products.core/src/org/eclipse/passage/loc/internal/products/core/ProductVersionKeys.java b/bundles/org.eclipse.passage.loc.products.core/src/org/eclipse/passage/loc/internal/products/core/ProductVersionKeys.java index 37974c286..bf80e8b69 100644 --- a/bundles/org.eclipse.passage.loc.products.core/src/org/eclipse/passage/loc/internal/products/core/ProductVersionKeys.java +++ b/bundles/org.eclipse.passage.loc.products.core/src/org/eclipse/passage/loc/internal/products/core/ProductVersionKeys.java @@ -114,7 +114,11 @@ private Path open(LicensedProduct licensed, Path path) { @SuppressWarnings("restriction") private Optional codec(LicensedProduct product) { - return new OperatorGearAware().withGear(gear -> gear.codec(product)); + try { + return new OperatorGearAware().withGear(gear -> gear.codec(product)); + } catch (LicensingException e) { + return Optional.empty();// TODO: under construction + } } private Optional validate(ProductVersionDescriptor target) { diff --git a/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF index e4256b532..d5d27e984 100644 --- a/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF @@ -32,7 +32,8 @@ Require-Bundle: org.eclipse.osgi.services;bundle-version="0.0.0", org.eclipse.passage.lic.emf;bundle-version="0.0.0", org.eclipse.passage.loc.api;bundle-version="0.0.0", org.eclipse.passage.loc.workbench;bundle-version="0.0.0";visibility:=reexport, - org.eclipse.passage.lic.licenses.model;bundle-version="0.0.0" + org.eclipse.passage.lic.licenses.model;bundle-version="0.0.0", + org.apache.logging.log4j;bundle-version="2.8.2" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: org.eclipse.passage.loc.internal.workbench.emfforms;x-internal:=true, org.eclipse.passage.loc.internal.workbench.emfforms.i18n;x-internal:=true, diff --git a/bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/ConditionTypeRenderer.java b/bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/ConditionTypeRenderer.java index 1e6cdc902..970c23038 100644 --- a/bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/ConditionTypeRenderer.java +++ b/bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/ConditionTypeRenderer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2020 ArSysOp + * Copyright (c) 2018, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -20,6 +20,8 @@ import javax.inject.Inject; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.eclipse.emf.ecp.view.spi.context.ViewModelContext; import org.eclipse.emf.ecp.view.spi.model.VControl; import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider; @@ -27,6 +29,7 @@ import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding; import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider; import org.eclipse.passage.lic.internal.api.EvaluationType; +import org.eclipse.passage.lic.internal.api.LicensingException; import org.eclipse.passage.lic.internal.api.inspection.RuntimeEnvironment; import org.eclipse.passage.loc.internal.api.OperatorGear; import org.eclipse.passage.loc.internal.equinox.OperatorGearAware; @@ -35,6 +38,7 @@ @SuppressWarnings("restriction") public class ConditionTypeRenderer extends ComboControlRenderer { + private final Logger log = LogManager.getLogger(getClass()); private final List environments; @Inject @@ -42,7 +46,13 @@ public ConditionTypeRenderer(VControl vElement, ViewModelContext viewContext, Re EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, VTViewTemplateProvider vtViewTemplateProvider) { super(vElement, viewContext, reportService, emfFormsDatabinding, emfFormsLabelProvider, vtViewTemplateProvider); - environments = new OperatorGearAware().withGear(this::names).orElseGet(Collections::emptyList); + Optional> found = Optional.empty(); + try { + found = new OperatorGearAware().withGear(this::names); + } catch (LicensingException e) { + log.error(e); + } + environments = found.orElseGet(Collections::emptyList); } @Override