From 9ecb3dc6c3106d68766f4e55b57d17e28f0c79e9 Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Sun, 10 Nov 2024 19:55:28 +0300 Subject: [PATCH] [#1453] Evolve raw string identifier to semantic entity Rework `String` feature identifier to a dedicated type `FeatureIdentifier` --- .../templates/DefaultProductRequirement.java | 6 ++- .../AntimagicShieldFeatureLicRequirement.java | 6 ++- .../passage/lic/api/FeatureIdentifier.java | 27 +++++++++++ .../org/eclipse/passage/lic/api/Passage.java | 13 +++--- .../eclipse/passage/lic/api/PassageUI.java | 6 ++- .../lic/api/acquire/GrantAcquisition.java | 10 ++++- .../acquire/LicenseAcquisitionService.java | 9 +++- .../passage/lic/api/conditions/Condition.java | 7 ++- .../passage/lic/api/requirements/Feature.java | 11 +++-- .../lic/base/BaseFeatureIdentifier.java | 24 ++++++++++ .../eclipse/passage/lic/base/BasePassage.java | 8 ++-- .../passage/lic/base/FeatureFilter.java | 20 +++++---- .../passage/lic/base/FeatureIdentifier.java | 45 ------------------- .../base/acquire/BaseGrantAcquisition.java | 28 ++++++------ .../LocalLicenseAcquisitionService.java | 6 ++- .../GlobalAgreementSupportFeature.java | 6 ++- .../lic/base/conditions/BaseCondition.java | 28 ++++++------ .../conditions/ConditionsFeatureFilter.java | 13 ++++-- .../base/conditions/FeatureConditionPack.java | 17 ++++--- .../lic/base/requirements/BaseFeature.java | 25 ++++++----- .../RequirementsFeatureFilter.java | 15 ++++--- .../UnsatisfiableRequirement.java | 6 ++- .../restrictions/CertificateIsSufficient.java | 9 +++- .../WorstRestrictionsPerFeature.java | 6 ++- .../lic/internal/base/access/Access.java | 13 +++--- .../lic/internal/base/access/Allow.java | 6 ++- .../lic/internal/base/access/Assess.java | 6 ++- .../lic/internal/base/access/Conditions.java | 6 ++- .../lic/internal/base/access/Cycle.java | 19 ++++---- .../lic/internal/base/access/CycleFilter.java | 6 ++- .../lic/internal/base/access/Lock.java | 8 ++-- .../internal/base/access/Requirements.java | 10 +++-- .../base/access/TentativeFeatureAccess.java | 14 +++--- .../passage/lic/cli/LicenseProtection.java | 7 ++- .../lic/e4/ui/addons/E4LicensingAddon.java | 6 ++- .../passage/lic/equinox/EquinoxPassage.java | 8 ++-- .../passage/lic/equinox/LicensedRunnable.java | 19 ++++---- .../requirements/CapabilityLicFeatureId.java | 16 +++++-- .../requirements/ComponentLicFeatureId.java | 17 ++++--- .../RequirementFromAttributes.java | 10 +++-- .../RequirementFromComponent.java | 10 +++-- .../requirements/RequirementToCapability.java | 14 +++--- .../BundleRequirementsForNamespace.java | 5 ++- .../lic/jface/BaseEquinoxPassageUI.java | 7 +-- .../lic/jface/actions/LicensedAction.java | 6 ++- .../lic/jface/actions/LicensedRunnableUI.java | 12 ++--- .../licenses/convert/EGrantAcquisition.java | 5 ++- .../licenses/convert/PGrantAcquisition.java | 12 ++--- .../transport/BaseXmiConditionTransport.java | 4 +- .../tests/fakes/conditions/FakeCondition.java | 10 +++-- .../tests/fakes/requirements/FakeFeature.java | 14 ++++-- .../tests/conditions/BaseConditionTest.java | 9 ++-- .../conditions/mining/HeadOnlyTransport.java | 6 ++- .../tests/requirements/RequirementsTest.java | 9 ++-- .../CertificateIsSufficientTest.java | 25 ++++++----- .../tests/restrictions/TestCertificates.java | 25 ++++++----- .../base/tests/restrictions/TestState.java | 8 ++-- .../CapabilityLicFeatureAgreementsTest.java | 5 ++- .../CapabilityLicFeatureIdTest.java | 10 +++-- .../CapabilityLicFeatureInfoTest.java | 11 ++--- .../CapabilityLicFeatureNameTest.java | 5 ++- .../CapabilityLicFeatureProviderTest.java | 5 ++- .../CapabilityLicFeatureRestrictionTest.java | 5 ++- .../CapabilityLicFeatureVersionTest.java | 5 ++- .../lic/equinox/requirements/DataBundle.java | 14 +++--- .../ResolvedRequirementsServiceTest.java | 7 +-- .../tests/XmiConditionTransportTest.java | 6 ++- .../demo/tests/access/AccessAcquireTest.java | 23 ++++++---- .../tests/access/AccessAssessmentTest.java | 6 ++- .../demo/tests/access/AccessCanUseTest.java | 16 ++++--- 70 files changed, 497 insertions(+), 324 deletions(-) create mode 100644 bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/FeatureIdentifier.java create mode 100644 bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BaseFeatureIdentifier.java delete mode 100644 bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureIdentifier.java diff --git a/bundles/org.eclipse.passage.ldc.pde.core.templates/src/org/eclipse/passage/ldc/internal/pde/core/templates/DefaultProductRequirement.java b/bundles/org.eclipse.passage.ldc.pde.core.templates/src/org/eclipse/passage/ldc/internal/pde/core/templates/DefaultProductRequirement.java index 7eff2887f..275022a0f 100644 --- a/bundles/org.eclipse.passage.ldc.pde.core.templates/src/org/eclipse/passage/ldc/internal/pde/core/templates/DefaultProductRequirement.java +++ b/bundles/org.eclipse.passage.ldc.pde.core.templates/src/org/eclipse/passage/ldc/internal/pde/core/templates/DefaultProductRequirement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.ldc.internal.pde.core.templates; @@ -16,6 +17,7 @@ import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.requirements.BaseFeature; import org.eclipse.passage.lic.base.requirements.BaseRequirement; @@ -38,7 +40,7 @@ public DefaultProductRequirement(Supplier product, Supplier name public Requirement get() { return new BaseRequirement(// new BaseFeature(// - product.get(), // + new BaseFeatureIdentifier(product.get()), // version.get(), // name.get(), // provider.get()), // diff --git a/bundles/org.eclipse.passage.ldc.pde.ui.templates/src/org/eclipse/passage/ldc/internal/pde/ui/templates/fullfeather/AntimagicShieldFeatureLicRequirement.java b/bundles/org.eclipse.passage.ldc.pde.ui.templates/src/org/eclipse/passage/ldc/internal/pde/ui/templates/fullfeather/AntimagicShieldFeatureLicRequirement.java index 40aab1c5d..4d5887930 100644 --- a/bundles/org.eclipse.passage.ldc.pde.ui.templates/src/org/eclipse/passage/ldc/internal/pde/ui/templates/fullfeather/AntimagicShieldFeatureLicRequirement.java +++ b/bundles/org.eclipse.passage.ldc.pde.ui.templates/src/org/eclipse/passage/ldc/internal/pde/ui/templates/fullfeather/AntimagicShieldFeatureLicRequirement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.ldc.internal.pde.ui.templates.fullfeather; @@ -16,6 +17,7 @@ import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.requirements.BaseFeature; import org.eclipse.passage.lic.base.requirements.BaseRequirement; @@ -25,7 +27,7 @@ public final class AntimagicShieldFeatureLicRequirement implements Supplier * - * @param feature string identifier of the feature under licensing. + * @param feature identifier of the feature under licensing. * * @see org.eclipse.passage.lic.api * @see Passage#releaseLicense(ExaminationCertificate) + * @since 4.0 */ - ServiceInvocationResult acquireLicense(String feature); + ServiceInvocationResult acquireLicense(FeatureIdentifier feature); /** *

@@ -101,7 +103,7 @@ public interface Passage { * control flow. *

* - * @param feature string identifier of the feature under licensing. + * @param feature identifier of the feature under licensing. * @return {@code true} if the given {@code feature} can be used and * {@code false} otherwise * @@ -109,8 +111,9 @@ public interface Passage { * @see Restriction * @see RestrictionLevel * @see org.eclipse.passage.lic.api + * @since 4.0 */ - boolean canUse(String feature); + boolean canUse(FeatureIdentifier feature); /** * Examines all the requirements against all the permissions and summarizes the diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/PassageUI.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/PassageUI.java index bb0a6de9e..9548a04ec 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/PassageUI.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/PassageUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api; @@ -53,8 +54,9 @@ public interface PassageUI { * for the {@code feature} utilization. Returns {@code false} if * existing coverage is not enough and the end user failed to improve * it. + * @since 4.0 */ - ServiceInvocationResult acquireLicense(String feature); + ServiceInvocationResult acquireLicense(FeatureIdentifier feature); /** * Assess the whole product licensing coverage. diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/GrantAcquisition.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/GrantAcquisition.java index f0d41e690..d69b8488d 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/GrantAcquisition.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/GrantAcquisition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,11 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.acquire; import java.util.Date; +import org.eclipse.passage.lic.api.FeatureIdentifier; + /** * * @since 2.1 @@ -24,7 +27,10 @@ public interface GrantAcquisition { String grant(); - String feature(); + /** + * @since 4.0 + */ + FeatureIdentifier feature(); String user(); diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/LicenseAcquisitionService.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/LicenseAcquisitionService.java index 81ee14b3e..e5be5905e 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/LicenseAcquisitionService.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/acquire/LicenseAcquisitionService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.acquire; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget; @@ -23,7 +25,10 @@ */ public interface LicenseAcquisitionService extends Service { - ServiceInvocationResult acquire(LicensedProduct product, String feature); + /** + * @since 4.0 + */ + ServiceInvocationResult acquire(LicensedProduct product, FeatureIdentifier feature); ServiceInvocationResult release(LicensedProduct product, GrantAcquisition acquisition); diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/conditions/Condition.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/conditions/Condition.java index 465c7c20e..b555638bf 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/conditions/Condition.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/conditions/Condition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,10 +9,12 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.conditions; import org.eclipse.passage.lic.api.EvaluationInstructions; +import org.eclipse.passage.lic.api.FeatureIdentifier; /** *

@@ -38,8 +40,9 @@ public interface Condition { /** * @return unique identifier of a feature under licensing. + * @since 4.0 */ - String feature(); + FeatureIdentifier feature(); /** * Define the actual {@code version} representing string that has been mined in diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/requirements/Feature.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/requirements/Feature.java index 9648909b7..919de0273 100644 --- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/requirements/Feature.java +++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/api/requirements/Feature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,12 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.requirements; +import org.eclipse.passage.lic.api.FeatureIdentifier; + /** *

* Describes a feature under licensing in context of access cycle. @@ -37,9 +40,11 @@ public interface Feature { String version(); /** - * Id of the feature under licensing + * Identifier of the feature under licensing + * + * @since 4.0 */ - String identifier(); + FeatureIdentifier identifier(); /** * Freely named provider of the feature diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BaseFeatureIdentifier.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BaseFeatureIdentifier.java new file mode 100644 index 000000000..9e2f24dae --- /dev/null +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BaseFeatureIdentifier.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2024 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.base; + +import org.eclipse.passage.lic.api.FeatureIdentifier; + +/** + * Base implementation for {@link FeatureIdentifier} + * + * @since 4.0 + */ +public record BaseFeatureIdentifier(String identifier) implements FeatureIdentifier { + +} diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BasePassage.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BasePassage.java index ba49dec79..804f91097 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BasePassage.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/BasePassage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.Passage; import org.eclipse.passage.lic.api.ServiceInvocationResult; @@ -31,7 +33,7 @@ public BasePassage(FrameworkAware delegate) { } @Override - public boolean canUse(String feature) { + public boolean canUse(FeatureIdentifier feature) { return delegate.withFramework(framework -> new Access(framework).canUse(feature)).orElse(Boolean.FALSE); } @@ -41,7 +43,7 @@ public ServiceInvocationResult assess() { } @Override - public ServiceInvocationResult acquireLicense(String feature) { + public ServiceInvocationResult acquireLicense(FeatureIdentifier feature) { return delegate.withFrameworkService(framework -> new Access(framework).acquire(feature)); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureFilter.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureFilter.java index 24e1d310c..a27087bd4 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureFilter.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,23 +9,24 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; +import java.util.Objects; import java.util.Optional; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; /** * - * @author afedorov3un - * * @param * * @since 2.1 @@ -33,12 +34,15 @@ public final class FeatureFilter implements Function>, ServiceInvocationResult>> { - private final String feature; - private final BiFunction> map; + private final FeatureIdentifier feature; + private final BiFunction> map; - public FeatureFilter(String feature, BiFunction> map) { - this.feature = feature; - this.map = map; + /** + * @since 4.0 + */ + public FeatureFilter(FeatureIdentifier feature, BiFunction> map) { + this.feature = Objects.requireNonNull(feature); + this.map = Objects.requireNonNull(map); } @Override diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureIdentifier.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureIdentifier.java deleted file mode 100644 index 6e5d4aadf..000000000 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/FeatureIdentifier.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020, 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 - * https://www.eclipse.org/legal/epl-2.0/. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * ArSysOp - initial API and implementation - *******************************************************************************/ -package org.eclipse.passage.lic.base; - -import java.util.Map; -import java.util.function.Function; - -/** - * Supplies an {@code identifier} of a feature under licensing, which is - * expected to be stored in a variety of sources under a special key. - * - * @see NamedData - * - * @since 2.1 - */ -public final class FeatureIdentifier extends StringNamedData { - - public FeatureIdentifier(String value) { - super(value); - } - - public FeatureIdentifier(Map values) { - super(values); - } - - public FeatureIdentifier(Function retriever) { - super(retriever); - } - - @Override - public String key() { - return "licensing.feature.identifier"; //$NON-NLS-1$ - } - -} diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/BaseGrantAcquisition.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/BaseGrantAcquisition.java index fc156e586..2d2993be9 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/BaseGrantAcquisition.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/BaseGrantAcquisition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2022 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.acquire; @@ -16,6 +17,7 @@ import java.util.Date; import java.util.Objects; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.acquire.GrantAcquisition; /** @@ -27,21 +29,19 @@ public final class BaseGrantAcquisition implements GrantAcquisition, Serializabl private static final long serialVersionUID = 2755031536488685673L; private final String id; private final String grant; - private final String feature; + private final FeatureIdentifier feature; private final String user; private final Date created; - public BaseGrantAcquisition(String id, String grant, String feature, String user, Date created) { - Objects.requireNonNull(id, "BaseGrantAcquisition::id"); //$NON-NLS-1$ - Objects.requireNonNull(grant, "BaseGrantAcquisition::grant"); //$NON-NLS-1$ - Objects.requireNonNull(feature, "BaseGrantAcquisition::feature"); //$NON-NLS-1$ - Objects.requireNonNull(user, "BaseGrantAcquisition::user"); //$NON-NLS-1$ - Objects.requireNonNull(created, "BaseGrantAcquisition::created"); //$NON-NLS-1$ - this.id = id; - this.grant = grant; - this.feature = feature; - this.user = user; - this.created = created; + /** + * @since 4.0 + */ + public BaseGrantAcquisition(String id, String grant, FeatureIdentifier feature, String user, Date created) { + this.id = Objects.requireNonNull(id); + this.grant = Objects.requireNonNull(grant); + this.feature = Objects.requireNonNull(feature); + this.user = Objects.requireNonNull(user); + this.created = Objects.requireNonNull(created); } @Override @@ -55,7 +55,7 @@ public String grant() { } @Override - public String feature() { + public FeatureIdentifier feature() { return feature; } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/LocalLicenseAcquisitionService.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/LocalLicenseAcquisitionService.java index f96f23907..dec83e3d7 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/LocalLicenseAcquisitionService.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/acquire/LocalLicenseAcquisitionService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,11 +9,13 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.acquire; import java.util.Date; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.acquire.GrantAcquisition; @@ -28,7 +30,7 @@ public abstract class LocalLicenseAcquisitionService implements LicenseAcquisitionService { @Override - public final ServiceInvocationResult acquire(LicensedProduct product, String feature) { + public final ServiceInvocationResult acquire(LicensedProduct product, FeatureIdentifier feature) { return new BaseServiceInvocationResult<>(// new BaseGrantAcquisition(// "local", //$NON-NLS-1$ diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/agreements/GlobalAgreementSupportFeature.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/agreements/GlobalAgreementSupportFeature.java index 4087f077d..9725f8505 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/agreements/GlobalAgreementSupportFeature.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/agreements/GlobalAgreementSupportFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021, 2022 ArSysOp + * Copyright (c) 2021, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.agreements; @@ -16,6 +17,7 @@ import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.requirements.Feature; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.requirements.BaseFeature; public final class GlobalAgreementSupportFeature implements Supplier { @@ -29,7 +31,7 @@ public GlobalAgreementSupportFeature(LicensedProduct product) { @Override public Feature get() { return new BaseFeature(// - product.identifier(), // + new BaseFeatureIdentifier(product.identifier()), // product.version(), // "Global Agreements Support by Passage", //$NON-NLS-1$ "Eclipse Passage Runtime" //$NON-NLS-1$ diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/BaseCondition.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/BaseCondition.java index b02ac19d5..426d20acf 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/BaseCondition.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/BaseCondition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.conditions; import java.util.Objects; import org.eclipse.passage.lic.api.EvaluationInstructions; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.conditions.Condition; import org.eclipse.passage.lic.api.conditions.ValidityPeriod; import org.eclipse.passage.lic.api.conditions.VersionMatch; @@ -26,23 +28,21 @@ public final class BaseCondition implements Condition { private final String identifier; - private final String feature; + private final FeatureIdentifier feature; private final VersionMatch version; private final ValidityPeriod period; private final EvaluationInstructions instructions; - public BaseCondition(String identifier, String feature, VersionMatch version, ValidityPeriod period, + /** + * @since 4.0 + */ + public BaseCondition(String identifier, FeatureIdentifier feature, VersionMatch version, ValidityPeriod period, EvaluationInstructions instructions) { - Objects.requireNonNull(identifier, "BaseCondition::Identifier"); //$NON-NLS-1$ - Objects.requireNonNull(feature, "BaseCondition::Feature"); //$NON-NLS-1$ - Objects.requireNonNull(version, "BaseCondition::VersionMatch"); //$NON-NLS-1$ - Objects.requireNonNull(period, "BaseCondition::ValidityPeriod"); //$NON-NLS-1$ - Objects.requireNonNull(instructions, "BaseCondition::EvaluationInstructions"); //$NON-NLS-1$ - this.identifier = identifier; - this.feature = feature; - this.version = version; - this.period = period; - this.instructions = instructions; + this.identifier = Objects.requireNonNull(identifier); + this.feature = Objects.requireNonNull(feature); + this.version = Objects.requireNonNull(version); + this.period = Objects.requireNonNull(period); + this.instructions = Objects.requireNonNull(instructions); } @Override @@ -51,7 +51,7 @@ public String identifier() { } @Override - public String feature() { + public FeatureIdentifier feature() { return feature; } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/ConditionsFeatureFilter.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/ConditionsFeatureFilter.java index 56b741efd..59de0b585 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/ConditionsFeatureFilter.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/ConditionsFeatureFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.conditions; import java.util.Optional; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.conditions.ConditionPack; import org.eclipse.passage.lic.base.FeatureFilter; @@ -23,9 +25,12 @@ */ public final class ConditionsFeatureFilter implements Supplier> { - private final String feature; + private final FeatureIdentifier feature; - public ConditionsFeatureFilter(String feature) { + /** + * @since 4.0 + */ + public ConditionsFeatureFilter(FeatureIdentifier feature) { this.feature = feature; } @@ -34,7 +39,7 @@ public FeatureFilter get() { return new FeatureFilter(feature, this::filtered); } - private Optional filtered(ConditionPack pack, String incoming) { + private Optional filtered(ConditionPack pack, FeatureIdentifier incoming) { ConditionPack filtered = new FeatureConditionPack(pack, incoming); return filtered.conditions().isEmpty() ? Optional.empty() : Optional.of(filtered); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/FeatureConditionPack.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/FeatureConditionPack.java index d0bb2b829..0bf2af530 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/FeatureConditionPack.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/FeatureConditionPack.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.conditions; @@ -17,6 +18,7 @@ import java.util.Objects; import java.util.stream.Collectors; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.agreements.GlobalAgreement; import org.eclipse.passage.lic.api.conditions.Condition; import org.eclipse.passage.lic.api.conditions.ConditionOrigin; @@ -31,13 +33,14 @@ public final class FeatureConditionPack implements ConditionPack { private final ConditionPack parent; - private final String feature; + private final FeatureIdentifier feature; - public FeatureConditionPack(ConditionPack parent, String feature) { - Objects.requireNonNull(parent, "FeatureConditionPack::parent"); //$NON-NLS-1$ - Objects.requireNonNull(feature, "FeatureConditionPack::feature"); //$NON-NLS-1$ - this.parent = parent; - this.feature = feature; + /** + * @since 4.0 + */ + public FeatureConditionPack(ConditionPack parent, FeatureIdentifier feature) { + this.parent = Objects.requireNonNull(parent); + this.feature = Objects.requireNonNull(feature); } @Override diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/BaseFeature.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/BaseFeature.java index 6586bf3f1..6987a02b5 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/BaseFeature.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/BaseFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,11 +9,13 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.requirements; import java.util.Objects; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.requirements.Feature; /** @@ -23,20 +25,19 @@ */ public final class BaseFeature implements Feature { - private final String id; + private final FeatureIdentifier id; private final String version; private final String name; private final String provider; - public BaseFeature(String id, String version, String name, String provider) { - Objects.requireNonNull(id, "Identifier is mandatory for a feature"); //$NON-NLS-1$ - Objects.requireNonNull(version, "Version is mandatory for a feature"); //$NON-NLS-1$ - Objects.requireNonNull(name, "Name is mandatory for a feature"); //$NON-NLS-1$ - Objects.requireNonNull(provider, "Provider is mandatory for a feature"); //$NON-NLS-1$ - this.id = id; - this.version = version; - this.name = name; - this.provider = provider; + /** + * @since 4.0 + */ + public BaseFeature(FeatureIdentifier id, String version, String name, String provider) { + this.id = Objects.requireNonNull(id); + this.version = Objects.requireNonNull(version); + this.name = Objects.requireNonNull(name); + this.provider = Objects.requireNonNull(provider); } @Override @@ -50,7 +51,7 @@ public String version() { } @Override - public String identifier() { + public FeatureIdentifier identifier() { return id; } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/RequirementsFeatureFilter.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/RequirementsFeatureFilter.java index f76a28987..5066708a2 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/RequirementsFeatureFilter.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/RequirementsFeatureFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.requirements; import java.util.Optional; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.base.FeatureFilter; @@ -23,18 +25,21 @@ */ public final class RequirementsFeatureFilter implements Supplier> { - private final String feature; + private final FeatureIdentifier feature; - public RequirementsFeatureFilter(String feature) { + /** + * @since 4.0 + */ + public RequirementsFeatureFilter(FeatureIdentifier feature) { this.feature = feature; } @Override public FeatureFilter get() { - return new FeatureFilter(feature, this::filtered); + return new FeatureFilter<>(feature, this::filtered); } - private Optional filtered(Requirement origin, String incoming) { + private Optional filtered(Requirement origin, FeatureIdentifier incoming) { return incoming.equals(origin.feature().identifier()) ? Optional.of(origin) : Optional.empty(); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/UnsatisfiableRequirement.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/UnsatisfiableRequirement.java index dee66a759..e66ce2802 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/UnsatisfiableRequirement.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/requirements/UnsatisfiableRequirement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.requirements; @@ -18,6 +19,7 @@ import org.eclipse.passage.lic.api.requirements.Feature; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; /** *

@@ -54,7 +56,7 @@ public UnsatisfiableRequirement(String description, Object source) { @Override public Requirement get() { Feature feature = new BaseFeature( // - Long.toHexString(System.currentTimeMillis()), // + new BaseFeatureIdentifier(Long.toHexString(System.currentTimeMillis())), // "0.0.0", //$NON-NLS-1$ // FIXME: rework on LicensingVersions elimination description, // "Passage License Management"); //$NON-NLS-1$ // FIXME: i18n diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/CertificateIsSufficient.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/CertificateIsSufficient.java index 953097944..1ad4dec34 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/CertificateIsSufficient.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/CertificateIsSufficient.java @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.restrictions; @@ -16,6 +17,7 @@ import java.util.Optional; import java.util.function.Predicate; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.agreements.AgreementToAccept; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate; @@ -27,9 +29,12 @@ */ public final class CertificateIsSufficient implements Predicate> { - private final String feature; + private final FeatureIdentifier feature; - public CertificateIsSufficient(String feature) { + /** + * @since 4.0 + */ + public CertificateIsSufficient(FeatureIdentifier feature) { this.feature = Objects.requireNonNull(feature); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/WorstRestrictionsPerFeature.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/WorstRestrictionsPerFeature.java index 480a9a1df..e769abf07 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/WorstRestrictionsPerFeature.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/WorstRestrictionsPerFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.base.restrictions; @@ -20,6 +21,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.restrictions.Restriction; import org.eclipse.passage.lic.api.restrictions.RestrictionComparator; @@ -37,7 +39,7 @@ public WorstRestrictionsPerFeature(Collection restrictions) { @Override public Collection get() { - Map> featured = restrictions.stream()// + Map> featured = restrictions.stream()// .collect(Collectors.groupingBy(r -> r.unsatisfiedRequirement().feature().identifier())); return featured.values().stream()// .map(this::worst) // diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Access.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Access.java index a4bf0f924..629c2f43f 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Access.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Access.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.Framework; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; @@ -27,7 +29,6 @@ /** * Top-level access cycle * - * @since 2.1 */ public final class Access { @@ -37,7 +38,7 @@ public Access(Framework framework) { this.framework = framework; } - public boolean canUse(String feature) { + public boolean canUse(FeatureIdentifier feature) { return new Allow(framework, feature).apply(); } @@ -45,7 +46,7 @@ public ServiceInvocationResult assess() { return new Assess(framework).apply(); } - public ServiceInvocationResult acquire(String feature) { + public ServiceInvocationResult acquire(FeatureIdentifier feature) { ServiceInvocationResult certificate = new Assess(framework, feature).apply(); if (new CertificateIsRestrictive().test(certificate.data())) { return failOnAccess(certificate); @@ -72,11 +73,11 @@ private ServiceInvocationResult failOnAccess( return new BaseServiceInvocationResult<>(assessment.diagnostic()); } - private ServiceInvocationResult unknownFeature(String feature, Diagnostic diagnostic) { + private ServiceInvocationResult unknownFeature(FeatureIdentifier feature, Diagnostic diagnostic) { return new BaseServiceInvocationResult<>(// new SumOfDiagnostics().apply(// diagnostic, // - new BaseDiagnostic(new Trouble(new NoRequirements(), feature))// + new BaseDiagnostic(new Trouble(new NoRequirements(), feature.identifier()))// )); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Allow.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Allow.java index b954dcd7a..e4f5679bb 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Allow.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Allow.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.Framework; import org.eclipse.passage.lic.api.diagnostic.Diagnostic; import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate; @@ -20,7 +22,7 @@ final class Allow extends Cycle { - Allow(Framework framework, String feature) { + Allow(Framework framework, FeatureIdentifier feature) { super(framework, feature); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Assess.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Assess.java index aeea5209c..7686301c4 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Assess.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Assess.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,11 +9,13 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; import java.util.Collections; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.Framework; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.diagnostic.Diagnostic; @@ -23,7 +25,7 @@ final class Assess extends Cycle> { - Assess(Framework framework, String feature) { + Assess(Framework framework, FeatureIdentifier feature) { super(framework, feature); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Conditions.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Conditions.java index cc25cf156..1b1e96ba4 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Conditions.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Conditions.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; @@ -18,6 +19,7 @@ import java.util.function.Function; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget; @@ -43,7 +45,7 @@ final class Conditions implements Supplier>> filter; public Conditions(Registry registry, LicensedProduct product, - String feature) { + FeatureIdentifier feature) { this(registry, product, new ConditionsFeatureFilter(feature).get()); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Cycle.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Cycle.java index ee648e42c..1b864b1e6 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Cycle.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Cycle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; @@ -19,6 +20,7 @@ import java.util.Optional; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.Framework; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.conditions.ConditionPack; @@ -35,30 +37,29 @@ abstract class Cycle { private final Framework framework; private final CycleFilter filter; private final List diagnostics; - private final Optional feature; + private final Optional feature; Cycle(Framework framework) { this(framework, new CycleFilter(), Optional.empty()); } - Cycle(Framework framework, String feature) { + Cycle(Framework framework, FeatureIdentifier feature) { this(framework, new CycleFilter(feature), Optional.of(feature)); } - private Cycle(Framework framework, CycleFilter filter, Optional feature) { - Objects.requireNonNull(framework, "Cycle::framework"); //$NON-NLS-1$ + private Cycle(Framework framework, CycleFilter filter, Optional feature) { Objects.requireNonNull(filter, "Cycle::filter"); //$NON-NLS-1$ - this.framework = framework; - this.filter = filter; + this.framework = Objects.requireNonNull(framework); + this.filter = Objects.requireNonNull(filter); this.diagnostics = new ArrayList<>(); - this.feature = feature; + this.feature = Objects.requireNonNull(feature); } T apply() { return examine(this::requirements, this::permissions); } - protected Optional feature() { + protected Optional feature() { return feature; } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/CycleFilter.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/CycleFilter.java index ae8a09b91..44a059a08 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/CycleFilter.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/CycleFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; import java.util.Collection; import java.util.function.Function; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.conditions.ConditionPack; import org.eclipse.passage.lic.api.requirements.Requirement; @@ -34,7 +36,7 @@ final class CycleFilter { this(Function.identity(), Function.identity()); } - CycleFilter(String feature) { + CycleFilter(FeatureIdentifier feature) { this(new RequirementsFeatureFilter(feature).get(), new ConditionsFeatureFilter(feature).get()); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Lock.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Lock.java index a94111fb8..2d8f77bad 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Lock.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Lock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2022 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; import java.util.Collections; import java.util.stream.Collectors; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.Framework; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; @@ -180,7 +182,7 @@ private Trouble explained(Restriction restriction) { * Certificate is guaranteed to be not empty: either restrictions or * satisfactions are present */ - private String feature(ExaminationCertificate certificate) { + private FeatureIdentifier feature(ExaminationCertificate certificate) { return feature(// certificate.restrictions().isEmpty() // ? certificate.satisfied().iterator().next()// @@ -188,7 +190,7 @@ private String feature(ExaminationCertificate certificate) { ); } - private String feature(Requirement requirement) { + private FeatureIdentifier feature(Requirement requirement) { return requirement.feature().identifier(); } diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Requirements.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Requirements.java index bc8cdd92f..fb59b9938 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Requirements.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Requirements.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; @@ -20,6 +21,7 @@ import java.util.function.Function; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.diagnostic.Trouble; import org.eclipse.passage.lic.api.registry.Registry; @@ -43,9 +45,9 @@ public final class Requirements implements Supplier>, // ServiceInvocationResult>> filter; - private final Optional feature; + private final Optional feature; - public Requirements(Registry registry, String feature) { + public Requirements(Registry registry, FeatureIdentifier feature) { this(registry, new RequirementsFeatureFilter(feature).get(), Optional.of(feature)); } @@ -55,7 +57,7 @@ public Requirements(Registry registry) { public Requirements(Registry registry, Function>, ServiceInvocationResult>> filter, - Optional feature) { + Optional feature) { Objects.requireNonNull(registry, "Requirements::registry"); //$NON-NLS-1$ Objects.requireNonNull(filter, "Requirements::filter"); //$NON-NLS-1$ this.registry = registry; diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/TentativeFeatureAccess.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/TentativeFeatureAccess.java index 287b67071..11ebf61a3 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/TentativeFeatureAccess.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/TentativeFeatureAccess.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,27 +9,31 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.access; import java.util.Date; +import java.util.Objects; import java.util.function.Predicate; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.acquire.GrantAcquisition; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.acquire.BaseGrantAcquisition; final class TentativeFeatureAccess implements Supplier, Predicate { - private final String feature; + private final FeatureIdentifier feature; private final String tentative = "tentative"; //$NON-NLS-1$ - TentativeFeatureAccess(String feature) { - this.feature = feature; + TentativeFeatureAccess(FeatureIdentifier feature) { + this.feature = Objects.requireNonNull(feature); } TentativeFeatureAccess() { - this("any"); //$NON-NLS-1$ + this(new BaseFeatureIdentifier("any")); //$NON-NLS-1$ } @Override diff --git a/bundles/org.eclipse.passage.lic.cli/src/org/eclipse/passage/lic/cli/LicenseProtection.java b/bundles/org.eclipse.passage.lic.cli/src/org/eclipse/passage/lic/cli/LicenseProtection.java index 2be375c5a..47e9ce8b2 100644 --- a/bundles/org.eclipse.passage.lic.cli/src/org/eclipse/passage/lic/cli/LicenseProtection.java +++ b/bundles/org.eclipse.passage.lic.cli/src/org/eclipse/passage/lic/cli/LicenseProtection.java @@ -8,7 +8,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.cli; @@ -18,6 +19,7 @@ import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained; import org.eclipse.passage.lic.equinox.EquinoxPassage; import org.slf4j.Logger; @@ -81,7 +83,8 @@ private Optional product() { } private Optional acquireLicense(LicensedProduct product) { - ServiceInvocationResult response = new EquinoxPassage().acquireLicense(product.identifier()); + ServiceInvocationResult response = new EquinoxPassage() + .acquireLicense(new BaseFeatureIdentifier(product.identifier())); if (!successful(response)) { log.error(String.format(// "Failed to acquire license \nfor product %s:\n%s\n", //$NON-NLS-1$ diff --git a/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java b/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java index 1316e8b56..30e533745 100644 --- a/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java +++ b/bundles/org.eclipse.passage.lic.e4.ui/src/org/eclipse/passage/lic/e4/ui/addons/E4LicensingAddon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.e4.ui.addons; @@ -21,6 +22,7 @@ import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained; import org.eclipse.passage.lic.base.restrictions.ExaminationExplained; import org.eclipse.passage.lic.equinox.EquinoxPassage; @@ -55,7 +57,7 @@ public void applicationStarted(// @SuppressWarnings("unused") @UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) // Event event) { ServiceInvocationResult response = // - new EquinoxPassageUI(this::shell).acquireLicense(product().identifier()); + new EquinoxPassageUI(this::shell).acquireLicense(new BaseFeatureIdentifier(product().identifier())); if (grantAcquired(response)) { grant = response.data(); } else { diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/EquinoxPassage.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/EquinoxPassage.java index 49c3596db..70e96c8a8 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/EquinoxPassage.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/EquinoxPassage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.Passage; import org.eclipse.passage.lic.api.ServiceInvocationResult; @@ -36,7 +38,7 @@ public EquinoxPassage(FrameworkAware delegate) { } @Override - public boolean canUse(String feature) { + public boolean canUse(FeatureIdentifier feature) { return delegate.canUse(feature); } @@ -46,7 +48,7 @@ public ServiceInvocationResult assess() { } @Override - public ServiceInvocationResult acquireLicense(String feature) { + public ServiceInvocationResult acquireLicense(FeatureIdentifier feature) { return delegate.acquireLicense(feature); } diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/LicensedRunnable.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/LicensedRunnable.java index 6f2ba15bd..a2713ec79 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/LicensedRunnable.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/LicensedRunnable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 ArSysOp + * Copyright (c) 2021, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox; import java.util.Optional; import java.util.function.Consumer; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; @@ -23,18 +25,18 @@ */ public abstract class LicensedRunnable implements Runnable { - private final String feature; + private final FeatureIdentifier feature; private final Runnable action; private final Consumer> fallback; - protected LicensedRunnable(String feature, Runnable action, + protected LicensedRunnable(FeatureIdentifier feature, Runnable action, Consumer> fallback) { this.feature = feature; this.action = action; this.fallback = fallback; } - public LicensedRunnable(String feature, Runnable action) { + public LicensedRunnable(FeatureIdentifier feature, Runnable action) { this(feature, action, response -> { }); } @@ -63,20 +65,21 @@ private boolean grantAcquired(Optional } @SuppressWarnings("hiding") - protected abstract ServiceInvocationResult acquireLicense(String feature); + protected abstract ServiceInvocationResult acquireLicense(FeatureIdentifier feature); public static final class Default extends LicensedRunnable { - public Default(String feature, Runnable action) { + public Default(FeatureIdentifier feature, Runnable action) { super(feature, action); } - public Default(String feature, Runnable action, Consumer> fallback) { + public Default(FeatureIdentifier feature, Runnable action, + Consumer> fallback) { super(feature, action, fallback); } @Override - protected ServiceInvocationResult acquireLicense(String feature) { + protected ServiceInvocationResult acquireLicense(FeatureIdentifier feature) { return new EquinoxPassage().acquireLicense(feature); } diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureId.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureId.java index 4c978349c..20bff1bdb 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureId.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureId.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,17 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; import java.util.Map; +import java.util.Optional; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.requirements.Requirement; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; +import org.eclipse.passage.lic.base.BaseNamedData; import org.eclipse.passage.lic.base.NamedData; /** @@ -24,14 +29,17 @@ * @see NamedData * @since 2.1 */ -public final class CapabilityLicFeatureId extends CapabilityLicFeatureInfo { +public final class CapabilityLicFeatureId extends BaseNamedData { public CapabilityLicFeatureId(Requirement requirement) { - super(requirement.feature().identifier()); + super(k -> requirement.feature().identifier()); } public CapabilityLicFeatureId(Map container) { - super(container); + super(key -> Optional.ofNullable(container.get(key))// + .map(String::valueOf) // + .map(BaseFeatureIdentifier::new) // + .orElse(null)); } @Override diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/ComponentLicFeatureId.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/ComponentLicFeatureId.java index f141ed6f4..a51e13983 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/ComponentLicFeatureId.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/ComponentLicFeatureId.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,13 +9,17 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; import java.util.Map; +import java.util.Optional; +import org.eclipse.passage.lic.api.FeatureIdentifier; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; +import org.eclipse.passage.lic.base.BaseNamedData; import org.eclipse.passage.lic.base.NamedData; -import org.eclipse.passage.lic.base.StringNamedData; /** * Encapsulate reading of a {@code feature identifier} from an @@ -24,14 +28,17 @@ * @see NamedData * @since 2.1 */ -public final class ComponentLicFeatureId extends StringNamedData { +public final class ComponentLicFeatureId extends BaseNamedData { public ComponentLicFeatureId(String identifier) { - super(identifier); + super(k -> new BaseFeatureIdentifier(identifier)); } public ComponentLicFeatureId(Map container) { - super(container); + super(key -> Optional.ofNullable(container.get(key))// + .map(String::valueOf) // + .map(BaseFeatureIdentifier::new) // + .orElse(null)); } @Override diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromAttributes.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromAttributes.java index 46a571602..42c4fabf4 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromAttributes.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromAttributes.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -20,6 +21,7 @@ import java.util.function.Supplier; import org.eclipse.osgi.util.NLS; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.agreements.ResolvedAgreement; import org.eclipse.passage.lic.api.diagnostic.Trouble; @@ -54,7 +56,7 @@ public RequirementFromAttributes(Bundle bundle, Map attributes) @Override public ServiceInvocationResult> get() { - Optional feature = new CapabilityLicFeatureId(attributes).get(); + Optional feature = new CapabilityLicFeatureId(attributes).get(); if (!feature.isPresent()) { return fail(NLS.bind(EquinoxMessages.RequirementsFromCapability_no_feature_id, // new LicCapabilityNamespace().get(), new BundleName(bundle).get())); @@ -62,12 +64,12 @@ public ServiceInvocationResult> get() { return succeed(requirementFromAttributes(feature.get())); } - private Requirement requirementFromAttributes(String feature) { + private Requirement requirementFromAttributes(FeatureIdentifier feature) { String version = new CapabilityLicFeatureVersion(attributes).get()// .map(value -> new SafeVersion(value).value())// .orElse(new DefaultVersion().value()); String name = new CapabilityLicFeatureName(attributes).get()// - .orElse(feature); + .orElse(feature.identifier()); String provider = new CapabilityLicFeatureProvider(attributes).get()// .orElseGet(new BundleVendor(bundle)); RestrictionLevel level = new CapabilityLicFeatureLevel(attributes).get()// diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromComponent.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromComponent.java index 0caf29122..dc3cb7ffb 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromComponent.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementFromComponent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -17,6 +18,7 @@ import java.util.Optional; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.agreements.ResolvedAgreement; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; @@ -52,7 +54,7 @@ public Optional get() { if (!properties.isPresent()) { // it's just a foreign component without licensing requirement declared return Optional.empty(); } - Optional feature = new ComponentLicFeatureId(properties.get()).get(); + Optional feature = new ComponentLicFeatureId(properties.get()).get(); if (!feature.isPresent()) { // it's a component without licensing requirement declared too return Optional.empty(); @@ -60,12 +62,12 @@ public Optional get() { return Optional.of(requirementFromProperties(feature.get(), properties.get())); } - private Requirement requirementFromProperties(String feature, Map properties) { + private Requirement requirementFromProperties(FeatureIdentifier feature, Map properties) { String version = new ComponentLicFeatureVersion(properties).get()// .map(raw -> new SafeVersion(raw).value())// .orElse(new DefaultVersion().value()); String name = new ComponentLicFeatureName(properties).get()// - .orElse(feature); + .orElse(feature.identifier()); Bundle bundle = context.getBundle(component.bundle.id); String provider = new ComponentLicFeatureProvider(properties).get()// .orElseGet(new BundleVendor(bundle)); diff --git a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementToCapability.java b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementToCapability.java index 031482727..67529c1d6 100644 --- a/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementToCapability.java +++ b/bundles/org.eclipse.passage.lic.equinox/src/org/eclipse/passage/lic/equinox/requirements/RequirementToCapability.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -19,8 +20,8 @@ import java.util.Optional; import org.eclipse.passage.lic.api.requirements.Requirement; +import org.eclipse.passage.lic.base.BaseNamedData; import org.eclipse.passage.lic.base.NamedData; -import org.eclipse.passage.lic.base.StringNamedData; /** *

@@ -55,11 +56,12 @@ public String key() { return new LicCapabilityNamespace().get(); } + @SuppressWarnings("unchecked") @Override public String printed(Requirement value) { StringBuilder out = new StringBuilder(); attributes().stream() // - .map(NamedData.Writable::new)// + .map(NamedData.Writable::new)// .forEach(w -> w.write(out)); return out.toString(); } @@ -74,8 +76,8 @@ public String entrySeparator() { return ","; //$NON-NLS-1$ } - private List attributes() { - List mandatory = Arrays.asList(// + private List> attributes() { + List> mandatory = Arrays.asList(// new CapabilityLicFeatureId(requirement), // new CapabilityLicFeatureName(requirement), // new CapabilityLicFeatureVersion(requirement), // @@ -84,7 +86,7 @@ private List attributes() { if (requirement.agreements().isEmpty()) { return mandatory; } - List full = new ArrayList<>(mandatory); + List> full = new ArrayList<>(mandatory); full.add(new CapabilityLicFeatureAgreements(requirement)); return full; } diff --git a/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java index 5ecdf71de..5d8c2c9bc 100644 --- a/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java +++ b/bundles/org.eclipse.passage.lic.execute/src/org/eclipse/passage/lic/execute/BundleRequirementsForNamespace.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 ArSysOp + * Copyright (c) 2022, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.execute; @@ -42,7 +43,7 @@ public Registry get() { } private boolean declaredInNamespace(Requirement requirement) { - return requirement.feature().identifier().startsWith(namespace); + return requirement.feature().identifier().identifier().startsWith(namespace); } } diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/BaseEquinoxPassageUI.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/BaseEquinoxPassageUI.java index bd7727bdc..0d8349162 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/BaseEquinoxPassageUI.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/BaseEquinoxPassageUI.java @@ -9,7 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation - * ArSysOp - further support + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.jface; @@ -19,6 +19,7 @@ import java.util.function.Supplier; import org.eclipse.jface.window.Window; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.PassageUI; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; @@ -44,7 +45,7 @@ protected BaseEquinoxPassageUI(Supplier shell) { } @Override - public final ServiceInvocationResult acquireLicense(String feature) { + public final ServiceInvocationResult acquireLicense(FeatureIdentifier feature) { return investigate(// () -> acquire(feature), // GrantLockAttempt::certificate, // @@ -74,7 +75,7 @@ private ServiceInvocationResult investigate(// return result; } - private ServiceInvocationResult acquire(String feature) { + private ServiceInvocationResult acquire(FeatureIdentifier feature) { return new EquinoxPassage().acquireLicense(feature); } diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedAction.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedAction.java index 44267f009..5ba17824f 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedAction.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedAction.java @@ -8,11 +8,13 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.jface.actions; import org.eclipse.jface.action.Action; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -35,7 +37,7 @@ public final void run() { @SuppressWarnings("restriction") private void runEverywhere(Display display) { - new LicensedRunnableUI(display::getActiveShell, getId(), this::doAction).run(); + new LicensedRunnableUI(display::getActiveShell, new BaseFeatureIdentifier(getId()), this::doAction).run(); } } diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedRunnableUI.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedRunnableUI.java index cc96d595e..7d09c42fb 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedRunnableUI.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/jface/actions/LicensedRunnableUI.java @@ -8,13 +8,15 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.jface.actions; import java.util.function.Consumer; import java.util.function.Supplier; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; import org.eclipse.passage.lic.equinox.LicensedRunnable; @@ -30,23 +32,23 @@ public final class LicensedRunnableUI extends LicensedRunnable { private final Supplier shell; - public LicensedRunnableUI(Supplier shell, String feature, Runnable action, + public LicensedRunnableUI(Supplier shell, FeatureIdentifier feature, Runnable action, Consumer> fallback) { super(feature, action, fallback); this.shell = shell; } - public LicensedRunnableUI(Supplier shell, String feature, Runnable action) { + public LicensedRunnableUI(Supplier shell, FeatureIdentifier feature, Runnable action) { this(shell, feature, action, response -> { }); } - public LicensedRunnableUI(String feature, Runnable action) { + public LicensedRunnableUI(FeatureIdentifier feature, Runnable action) { this(Display.getDefault()::getActiveShell, feature, action); } @Override - protected ServiceInvocationResult acquireLicense(String feature) { + protected ServiceInvocationResult acquireLicense(FeatureIdentifier feature) { return new EquinoxPassageUI(shell).acquireLicense(feature); } diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/EGrantAcquisition.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/EGrantAcquisition.java index 94d4dcf61..557a79ce7 100644 --- a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/EGrantAcquisition.java +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/EGrantAcquisition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.licenses.convert; @@ -30,7 +31,7 @@ public GrantAcqisition get() { GrantAcqisition grant = LicensesFactory.eINSTANCE.createGrantAcqisition(); grant.setIdentifier(source.identifier()); grant.setGrant(source.grant()); - grant.setFeature(source.feature()); + grant.setFeature(source.feature().identifier()); grant.setUser(source.user()); grant.setCreated(source.created()); return grant; diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/PGrantAcquisition.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/PGrantAcquisition.java index 85dd8dd53..6bd5fe865 100644 --- a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/PGrantAcquisition.java +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/convert/PGrantAcquisition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,23 +9,23 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.licenses.convert; import java.util.Objects; import java.util.function.Supplier; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.acquire.BaseGrantAcquisition; import org.eclipse.passage.lic.licenses.model.api.GrantAcqisition; -public final class PGrantAcquisition - implements Supplier { +public final class PGrantAcquisition implements Supplier { private final GrantAcqisition source; public PGrantAcquisition(GrantAcqisition source) { - Objects.requireNonNull(source, "PGrantAcquisition::source"); //$NON-NLS-1$ - this.source = source; + this.source = Objects.requireNonNull(source); } @Override @@ -33,7 +33,7 @@ public org.eclipse.passage.lic.api.acquire.GrantAcquisition get() { return new BaseGrantAcquisition(// source.getIdentifier(), // source.getGrant(), // - source.getFeature(), // + new BaseFeatureIdentifier(source.getFeature()), // source.getUser(), // source.getCreated()); } diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/transport/BaseXmiConditionTransport.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/transport/BaseXmiConditionTransport.java index 7028bbf5c..52464f167 100644 --- a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/transport/BaseXmiConditionTransport.java +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/transport/BaseXmiConditionTransport.java @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.licenses.model.transport; @@ -32,6 +33,7 @@ import org.eclipse.passage.lic.api.conditions.IssuerSignature; import org.eclipse.passage.lic.api.conditions.mining.ConditionTransport; import org.eclipse.passage.lic.api.conditions.mining.ContentType; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.conditions.BaseCondition; import org.eclipse.passage.lic.base.conditions.BaseEvaluationInstructions; import org.eclipse.passage.lic.base.conditions.BaseValidityPeriodClosed; @@ -106,7 +108,7 @@ private Map loadOptions() { private Condition condition(PersonalFeatureGrant grant) { return new BaseCondition(grant.getIdentifier(), // - grant.getFeature().getIdentifier(), // + new BaseFeatureIdentifier(grant.getFeature().getIdentifier()), // new PVersionMatch(grant.getFeature().getVersionMatch()).get(), // new BaseValidityPeriodClosed(// fromDate(((ValidityPeriodClosed) grant.getValid()).getFrom()), // diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java index 589b32d2d..f72d208d4 100644 --- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java +++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,12 +9,14 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.tests.fakes.conditions; import java.util.Optional; import org.eclipse.passage.lic.api.EvaluationInstructions; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.conditions.Condition; import org.eclipse.passage.lic.api.conditions.ValidityPeriod; import org.eclipse.passage.lic.api.conditions.VersionMatch; @@ -22,7 +24,7 @@ public final class FakeCondition implements Condition { private Optional identifier = Optional.empty(); - private Optional feature = Optional.empty(); + private Optional feature = Optional.empty(); private Optional version = Optional.empty(); private Optional period = Optional.empty(); private Optional evaluation = Optional.empty(); @@ -33,7 +35,7 @@ public String identifier() { } @Override - public String feature() { + public FeatureIdentifier feature() { return getOrFail(feature); } @@ -69,7 +71,7 @@ public FakeCondition withValidityPeriod(ValidityPeriod p) { return this; } - public FakeCondition withFeature(String f) { + public FakeCondition withFeature(FeatureIdentifier f) { this.feature = Optional.ofNullable(f); return this; } diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java index 8432fc988..8e099e2d2 100644 --- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java +++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,9 +9,11 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.api.tests.fakes.requirements; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.requirements.Feature; public final class FakeFeature implements Feature { @@ -37,8 +39,14 @@ public String version() { } @Override - public String identifier() { - return String.format("fake_%s ", identity); //$NON-NLS-1$ + public FeatureIdentifier identifier() { + return new FeatureIdentifier() { + + @Override + public String identifier() { + return String.format("fake_%s ", identity); //$NON-NLS-1$ + } + }; } @Override diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/BaseConditionTest.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/BaseConditionTest.java index 925eafbff..34041dc62 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/BaseConditionTest.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/BaseConditionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.conditions; @@ -19,9 +20,11 @@ import org.eclipse.passage.lic.api.EvaluationInstructions; import org.eclipse.passage.lic.api.EvaluationType; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.conditions.Condition; import org.eclipse.passage.lic.api.conditions.ValidityPeriod; import org.eclipse.passage.lic.api.conditions.VersionMatch; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.conditions.BaseCondition; import org.eclipse.passage.lic.base.conditions.BaseEvaluationInstructions; import org.eclipse.passage.lic.base.conditions.BaseValidityPeriodClosed; @@ -96,8 +99,8 @@ private String identifier() { return "aaa"; //$NON-NLS-1$ } - private String feature() { - return "test-feature"; //$NON-NLS-1$ + private FeatureIdentifier feature() { + return new BaseFeatureIdentifier("test-feature"); //$NON-NLS-1$ } private VersionMatch versionMatch() { diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/mining/HeadOnlyTransport.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/mining/HeadOnlyTransport.java index bb8d3699f..39dc14982 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/mining/HeadOnlyTransport.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/conditions/mining/HeadOnlyTransport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.conditions.mining; @@ -27,6 +28,7 @@ import org.eclipse.passage.lic.api.conditions.VersionMatch; import org.eclipse.passage.lic.api.conditions.mining.ConditionTransport; import org.eclipse.passage.lic.api.conditions.mining.ContentType; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.conditions.BaseCondition; import org.eclipse.passage.lic.base.conditions.BaseEvaluationInstructions; import org.eclipse.passage.lic.base.conditions.BaseValidityPeriodClosed; @@ -55,7 +57,7 @@ public Data read(InputStream input) throws IOException { spy.transportLine(); conditions.add(new BaseCondition(// String.valueOf(line.trim().hashCode()), // - line.trim(), // + new BaseFeatureIdentifier(line.trim()), // commonVersion(), commonPeriod(), commonInstructions())); } } diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/requirements/RequirementsTest.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/requirements/RequirementsTest.java index 576fc81b2..6f2cdf505 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/requirements/RequirementsTest.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/requirements/RequirementsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.requirements; @@ -23,6 +24,7 @@ import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.requirements.ResolvedRequirements; import org.eclipse.passage.lic.api.tests.fakes.requirements.FakeResolvedRequirements; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.diagnostic.code.NoRequirements; import org.eclipse.passage.lic.base.diagnostic.code.NoServicesOfType; import org.eclipse.passage.lic.base.registry.ReadOnlyRegistry; @@ -36,7 +38,7 @@ public final class RequirementsTest { public void noResolversMeansNoAccess() { ServiceInvocationResult> result = new Requirements(// new SabotagedFramework().accessCycleConfiguration().requirementResolvers().get(), // - "feature0" //$NON-NLS-1$ + new BaseFeatureIdentifier("feature0") //$NON-NLS-1$ ).get(); assertFalse(result.diagnostic().severe().isEmpty()); assertFalse(result.data().isPresent()); @@ -48,7 +50,8 @@ public void noResolversMeansNoAccess() { @Test public void noRequirementsIsSuspicious() { ServiceInvocationResult> result = new Requirements(// - new ReadOnlyRegistry(new FakeResolvedRequirements()), "feature0" //$NON-NLS-1$ + new ReadOnlyRegistry(new FakeResolvedRequirements()), + new BaseFeatureIdentifier("feature0") //$NON-NLS-1$ ).get(); assertTrue(result.diagnostic().severe().isEmpty()); assertFalse(result.diagnostic().bearable().isEmpty()); diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/CertificateIsSufficientTest.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/CertificateIsSufficientTest.java index bf1ad505d..d1669f396 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/CertificateIsSufficientTest.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/CertificateIsSufficientTest.java @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.restrictions; @@ -17,7 +18,9 @@ import java.util.Optional; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.restrictions.CertificateIsSufficient; import org.junit.Test; @@ -25,49 +28,49 @@ public final class CertificateIsSufficientTest { @Test public void absentCertificateIsNotSufficient() { - assertFalse(new CertificateIsSufficient("any").test(Optional.empty())); //$NON-NLS-1$ + assertFalse(new CertificateIsSufficient(new BaseFeatureIdentifier("any")).test(Optional.empty())); //$NON-NLS-1$ } @Test public void assessedFeatureIsRestricted() { - String feature = feature(); + FeatureIdentifier feature = feature(); assertFalse(new CertificateIsSufficient(feature).test(Optional.of(severe(feature)))); } @Test public void assessedFeatureIsSoftlyRestricted() { - String feature = feature(); + FeatureIdentifier feature = feature(); assertFalse(new CertificateIsSufficient(feature).test(Optional.of(warn(feature)))); } @Test public void notAssessedFeatureIsRestricted() { - String feature = feature(); + FeatureIdentifier feature = feature(); assertTrue(new CertificateIsSufficient(feature).test(Optional.of(severe()))); } @Test public void assessedFeatureDemandsAgreementNotAccepted() { - String feature = feature(); + FeatureIdentifier feature = feature(); Optional certificate = Optional.of(agreementNotAccepted(feature)); assertFalse(new CertificateIsSufficient(feature).test(certificate)); } @Test public void notAssessedFeatureDemandsAgreementNotAccepted() { - String feature = feature(); + FeatureIdentifier feature = feature(); assertTrue(new CertificateIsSufficient(feature).test(Optional.of(agreementNotAccepted()))); } - private String feature() { - return "feature-under-assessment-" + Long.toHexString(System.currentTimeMillis()); //$NON-NLS-1$ + private FeatureIdentifier feature() { + return new BaseFeatureIdentifier("feature-under-assessment-" + Long.toHexString(System.currentTimeMillis())); //$NON-NLS-1$ } - private ExaminationCertificate severe(String feature) { + private ExaminationCertificate severe(FeatureIdentifier feature) { return new TestCertificates().withSevereRestrictions(feature); } - private ExaminationCertificate warn(String feature) { + private ExaminationCertificate warn(FeatureIdentifier feature) { return new TestCertificates().withWarningRestrictions(feature); } @@ -75,7 +78,7 @@ private ExaminationCertificate severe() { return new TestCertificates().withSevereRestrictions(); } - private ExaminationCertificate agreementNotAccepted(String feature) { + private ExaminationCertificate agreementNotAccepted(FeatureIdentifier feature) { return new TestCertificates().withAgreementRestrictions(feature); } diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestCertificates.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestCertificates.java index 17db7f37c..0dce6a8c4 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestCertificates.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestCertificates.java @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.restrictions; @@ -17,6 +18,7 @@ import java.util.List; import org.eclipse.passage.lic.api.EvaluationType; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.LicensedProduct; import org.eclipse.passage.lic.api.agreements.AgreementToAccept; import org.eclipse.passage.lic.api.diagnostic.TroubleCode; @@ -24,6 +26,7 @@ import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; import org.eclipse.passage.lic.api.tests.fakes.agreements.FakeAgreementState; import org.eclipse.passage.lic.api.tests.fakes.agreements.FakeResolvedAgreement; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.BaseLicensedProduct; import org.eclipse.passage.lic.base.agreements.BaseAgreementToAccept; import org.eclipse.passage.lic.base.agreements.UnacceptedAgreementRestriction; @@ -49,7 +52,7 @@ ExaminationCertificate verbose() { Collections.singletonMap(// new BaseRequirement(// new BaseFeature(// - "properly-licensed-feature", //$NON-NLS-1$ + new BaseFeatureIdentifier("properly-licensed-feature"), //$NON-NLS-1$ "1.2.3", //$NON-NLS-1$ "Feature to Succeed", //$NON-NLS-1$ "This test"), //$NON-NLS-1$ @@ -59,7 +62,7 @@ ExaminationCertificate verbose() { product(), // new BaseCondition(// "condition-identifier", //$NON-NLS-1$ - "properly-licensed-feature", //$NON-NLS-1$ + new BaseFeatureIdentifier("properly-licensed-feature"), //$NON-NLS-1$ new BaseVersionMatch("1.2.3", new MatchingRuleCompatible()), //$NON-NLS-1$ new BaseValidityPeriodClosed(// ZonedDateTime.now().minusDays(11), // @@ -77,7 +80,7 @@ ExaminationCertificate verbose() { product(), // new BaseRequirement(// new BaseFeature(// - "failed-feature", //$NON-NLS-1$ + new BaseFeatureIdentifier("failed-feature"), //$NON-NLS-1$ "17.2.1", //$NON-NLS-1$ "Feature to fail", //$NON-NLS-1$ "This test"), //$NON-NLS-1$ @@ -99,10 +102,10 @@ ExaminationCertificate onlyBearableRestrictions() { } ExaminationCertificate withSevereRestrictions() { - return withSevereRestrictions("very-much-protected-feature"); //$NON-NLS-1$ + return withSevereRestrictions(new BaseFeatureIdentifier("very-much-protected-feature")); //$NON-NLS-1$ } - ExaminationCertificate withSevereRestrictions(String feature) { + ExaminationCertificate withSevereRestrictions(FeatureIdentifier feature) { return new BaseExaminationCertificate(// Collections.emptyMap(), // no permissions Collections.singleton(// @@ -113,7 +116,7 @@ ExaminationCertificate withSevereRestrictions(String feature) { )); } - ExaminationCertificate withWarningRestrictions(String feature) { + ExaminationCertificate withWarningRestrictions(FeatureIdentifier feature) { return new BaseExaminationCertificate(// Collections.emptyMap(), // no permissions Collections.singleton(// @@ -125,10 +128,10 @@ ExaminationCertificate withWarningRestrictions(String feature) { } ExaminationCertificate withAgreementRestrictions() { - return withAgreementRestrictions("not-very-much-protected-feature"); //$NON-NLS-1$ + return withAgreementRestrictions(new BaseFeatureIdentifier("not-very-much-protected-feature")); //$NON-NLS-1$ } - ExaminationCertificate withAgreementRestrictions(String feature) { + ExaminationCertificate withAgreementRestrictions(FeatureIdentifier feature) { AgreementToAccept agreement = new BaseAgreementToAccept(// warningProtectedFeature(feature), // new FakeResolvedAgreement(), // @@ -157,10 +160,10 @@ private LicensedProduct product() { } private BaseRequirement warningProtectedFeature() { - return warningProtectedFeature("not-very-much-protected-feature"); //$NON-NLS-1$ + return warningProtectedFeature(new BaseFeatureIdentifier("not-very-much-protected-feature")); //$NON-NLS-1$ } - private BaseRequirement warningProtectedFeature(String feature) { + private BaseRequirement warningProtectedFeature(FeatureIdentifier feature) { return new BaseRequirement(// new BaseFeature(// feature, // @@ -171,7 +174,7 @@ private BaseRequirement warningProtectedFeature(String feature) { "Requirement is not mandatory to satisfy");//$NON-NLS-1$ } - private BaseRequirement errorProtectedFeature(String feature) { + private BaseRequirement errorProtectedFeature(FeatureIdentifier feature) { return new BaseRequirement(// new BaseFeature(// feature, // diff --git a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestState.java b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestState.java index aa30cd37b..bd1593f1d 100644 --- a/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestState.java +++ b/tests/org.eclipse.passage.lic.base.tests/src/org/eclipse/passage/lic/internal/base/tests/restrictions/TestState.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.base.tests.restrictions; @@ -21,6 +22,7 @@ import org.eclipse.passage.lic.api.requirements.Feature; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.BaseLicensedProduct; import org.eclipse.passage.lic.base.conditions.BaseCondition; import org.eclipse.passage.lic.base.conditions.BaseEvaluationInstructions; @@ -49,11 +51,11 @@ final class TestState { TestState() { product = new BaseLicensedProduct("test-product", "4.3.18-hotfix"); //$NON-NLS-1$//$NON-NLS-2$ - featureFirst = new BaseFeature("the-first-feature", //$NON-NLS-1$ + featureFirst = new BaseFeature(new BaseFeatureIdentifier("the-first-feature"), //$NON-NLS-1$ "1.12.0", //$NON-NLS-1$ "Feature the first", //$NON-NLS-1$ getClass().getName()); - featureSecond = new BaseFeature("the-second-feature", //$NON-NLS-1$ + featureSecond = new BaseFeature(new BaseFeatureIdentifier("the-second-feature"), //$NON-NLS-1$ "6.4.37", //$NON-NLS-1$ "Feature the second", //$NON-NLS-1$ getClass().getName()); diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureAgreementsTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureAgreementsTest.java index d19772dd6..8ff4dfa22 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureAgreementsTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureAgreementsTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 ArSysOp + * Copyright (c) 2021, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -19,7 +20,7 @@ import org.eclipse.passage.lic.base.StringNamedData; -public final class CapabilityLicFeatureAgreementsTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureAgreementsTest extends CapabilityLicFeatureInfoTest { @Override protected StringNamedData infoSupplier(Map attributes) { diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureIdTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureIdTest.java index 2fd8023e4..e35a430ab 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureIdTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureIdTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -17,12 +18,13 @@ import java.util.Map; import java.util.Set; -import org.eclipse.passage.lic.base.StringNamedData; +import org.eclipse.passage.lic.api.FeatureIdentifier; +import org.eclipse.passage.lic.base.BaseNamedData; -public final class CapabilityLicFeatureIdTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureIdTest extends CapabilityLicFeatureInfoTest { @Override - protected StringNamedData infoSupplier(Map attributes) { + protected BaseNamedData infoSupplier(Map attributes) { return new CapabilityLicFeatureId(attributes); } diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureInfoTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureInfoTest.java index 3a8d2e52d..fe2c785b0 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureInfoTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureInfoTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -21,11 +22,11 @@ import java.util.Set; import java.util.stream.Collectors; -import org.eclipse.passage.lic.base.StringNamedData; +import org.eclipse.passage.lic.base.BaseNamedData; import org.junit.Test; import org.osgi.framework.wiring.BundleCapability; -abstract class CapabilityLicFeatureInfoTest { +abstract class CapabilityLicFeatureInfoTest { @Test public void read() { @@ -35,7 +36,7 @@ public void read() { data.capabilities().stream()// .map(BundleCapability::getAttributes) // .map(this::infoSupplier) // - .map(StringNamedData::get) // + .map(BaseNamedData::get) // .filter(Optional::isPresent)// .map(Optional::get) // .collect(Collectors.toSet())// @@ -52,7 +53,7 @@ public void nullInputValue() { assertFalse(infoSupplier(Collections.emptyMap()).get().isPresent()); } - protected abstract StringNamedData infoSupplier(Map attributes); + protected abstract BaseNamedData infoSupplier(Map attributes); protected abstract Set expectations(); diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureNameTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureNameTest.java index 498aa4f88..557bc0e8d 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureNameTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureNameTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -19,7 +20,7 @@ import org.eclipse.passage.lic.base.StringNamedData; -public final class CapabilityLicFeatureNameTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureNameTest extends CapabilityLicFeatureInfoTest { @Override protected StringNamedData infoSupplier(Map attributes) { diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureProviderTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureProviderTest.java index 541afdddf..fa1759d49 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureProviderTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureProviderTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -18,7 +19,7 @@ import org.eclipse.passage.lic.base.StringNamedData; -public final class CapabilityLicFeatureProviderTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureProviderTest extends CapabilityLicFeatureInfoTest { @Override protected StringNamedData infoSupplier(Map attributes) { diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureRestrictionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureRestrictionTest.java index 2c9a5d796..9f528f573 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureRestrictionTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureRestrictionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -19,7 +20,7 @@ import org.eclipse.passage.lic.base.StringNamedData; -public final class CapabilityLicFeatureRestrictionTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureRestrictionTest extends CapabilityLicFeatureInfoTest { @Override protected StringNamedData infoSupplier(Map attributes) { diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureVersionTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureVersionTest.java index 2aa732fdc..13a5a12f9 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureVersionTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/CapabilityLicFeatureVersionTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -19,7 +20,7 @@ import org.eclipse.passage.lic.base.StringNamedData; -public final class CapabilityLicFeatureVersionTest extends CapabilityLicFeatureInfoTest { +public final class CapabilityLicFeatureVersionTest extends CapabilityLicFeatureInfoTest { @Override protected StringNamedData infoSupplier(Map attributes) { diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/DataBundle.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/DataBundle.java index f48806850..c1db3a893 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/DataBundle.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/DataBundle.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -20,6 +21,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.passage.lic.api.requirements.Requirement; import org.eclipse.passage.lic.api.restrictions.RestrictionLevel; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.requirements.BaseFeature; import org.eclipse.passage.lic.base.requirements.BaseRequirement; import org.eclipse.passage.lic.internal.base.Cached; @@ -52,7 +54,7 @@ Set validRequirementsFromComponents() { BaseRequirement e() { return new BaseRequirement(// new BaseFeature(// - "E", //$NON-NLS-1$ + new BaseFeatureIdentifier("E"), //$NON-NLS-1$ "2.71.82", //$NON-NLS-1$ "Euler number", //$NON-NLS-1$ "Euler"), //$NON-NLS-1$ @@ -66,7 +68,7 @@ BaseRequirement e() { BaseRequirement pi() { return new BaseRequirement(// new BaseFeature(// - "PI", //$NON-NLS-1$ + new BaseFeatureIdentifier("PI"), //$NON-NLS-1$ "3.14.15", //$NON-NLS-1$ "PI of version PI", //$NON-NLS-1$ "Eclipse Passage"), //$NON-NLS-1$ @@ -77,7 +79,7 @@ BaseRequirement pi() { BaseRequirement incomplete() { return new BaseRequirement(// new BaseFeature(// - "Incomplete", //$NON-NLS-1$ + new BaseFeatureIdentifier("Incomplete"), //$NON-NLS-1$ "0.0.0", //$NON-NLS-1$ "Incomplete", //$NON-NLS-1$ "Eclipse Passage"), //$NON-NLS-1$ @@ -88,7 +90,7 @@ BaseRequirement incomplete() { BaseRequirement evilWitch() { return new BaseRequirement(// new BaseFeature(// - "EvilWitch", //$NON-NLS-1$ + new BaseFeatureIdentifier("EvilWitch"), //$NON-NLS-1$ "13.4.1", //$NON-NLS-1$ "Evil Witch", //$NON-NLS-1$ "Universe"), //$NON-NLS-1$ @@ -100,7 +102,7 @@ BaseRequirement evilWitch() { BaseRequirement goodWitch() { return new BaseRequirement(// new BaseFeature(// - "GoodWitch", //$NON-NLS-1$ + new BaseFeatureIdentifier("GoodWitch"), //$NON-NLS-1$ "0.0.0", //$NON-NLS-1$ "GoodWitch", //$NON-NLS-1$ "Eclipse Passage"), //$NON-NLS-1$ diff --git a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/ResolvedRequirementsServiceTest.java b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/ResolvedRequirementsServiceTest.java index 416ba800f..31c813e33 100644 --- a/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/ResolvedRequirementsServiceTest.java +++ b/tests/org.eclipse.passage.lic.equinox.tests/src/org/eclipse/passage/lic/equinox/requirements/ResolvedRequirementsServiceTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.equinox.requirements; @@ -46,8 +47,8 @@ public void requirementsForFeature() throws InvalidSyntaxException { Requirement single = single(); ServiceInvocationResult> filtered = new RequirementsFeatureFilter( single.feature().identifier())// - .get()// - .apply(service().all()); + .get()// + .apply(service().all()); assertEquals(// Collections.singleton(single), // new HashSet(filtered.data().get())); diff --git a/tests/org.eclipse.passage.lic.licenses.model.tests/src/org/eclipse/passage/lic/internal/licenses/model/toberemoved/tests/XmiConditionTransportTest.java b/tests/org.eclipse.passage.lic.licenses.model.tests/src/org/eclipse/passage/lic/internal/licenses/model/toberemoved/tests/XmiConditionTransportTest.java index e8247fae6..699d61409 100644 --- a/tests/org.eclipse.passage.lic.licenses.model.tests/src/org/eclipse/passage/lic/internal/licenses/model/toberemoved/tests/XmiConditionTransportTest.java +++ b/tests/org.eclipse.passage.lic.licenses.model.tests/src/org/eclipse/passage/lic/internal/licenses/model/toberemoved/tests/XmiConditionTransportTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2024 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -9,6 +9,7 @@ * * Contributors: * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.lic.internal.licenses.model.toberemoved.tests; @@ -20,6 +21,7 @@ import org.eclipse.passage.lic.api.conditions.Condition; import org.eclipse.passage.lic.api.conditions.mining.ConditionTransport; import org.eclipse.passage.lic.api.tests.conditions.mining.ConditionTransportContractTest; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.conditions.BaseCondition; import org.eclipse.passage.lic.base.conditions.BaseEvaluationInstructions; import org.eclipse.passage.lic.base.conditions.BaseValidityPeriodClosed; @@ -40,7 +42,7 @@ protected ConditionTransport transport() { protected Collection conditions() { return Collections.singleton(new BaseCondition(// "aaa", //$NON-NLS-1$ - "doodle", //$NON-NLS-1$ + new BaseFeatureIdentifier("doodle"), //$NON-NLS-1$ new BaseVersionMatch(// "1.2.3", //$NON-NLS-1$ new MatchingRuleDefault()), // diff --git a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAcquireTest.java b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAcquireTest.java index c528e9979..0b90ddfb2 100644 --- a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAcquireTest.java +++ b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAcquireTest.java @@ -8,7 +8,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.seal.demo.tests.access; @@ -18,11 +19,13 @@ import java.util.List; import java.util.function.Consumer; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.access.GrantLockAttempt; import org.eclipse.passage.lic.api.diagnostic.Diagnostic; import org.eclipse.passage.lic.api.diagnostic.Trouble; import org.eclipse.passage.lic.api.diagnostic.TroubleCode; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained; import org.eclipse.passage.lic.base.diagnostic.NoErrors; import org.eclipse.passage.lic.base.diagnostic.NoSevereErrors; @@ -46,7 +49,7 @@ public final class AccessAcquireTest { public void acquireTentativeGrant() { successfullyAcquireAndRelease(// new TestFramework.Everlasting(), // - "frog-to-prince", //$NON-NLS-1$ + new BaseFeatureIdentifier("frog-to-prince"), //$NON-NLS-1$ diagnostic -> { assertTrue(diagnostic.bearable().size() > 0); assertContainsCode(new TentativeAccess(), diagnostic.bearable()); @@ -60,7 +63,7 @@ public void acquireTentativeGrant() { public void acquireLicenseGrant() { successfullyAcquireAndRelease(// new TestFramework.Everlasting(), // - "prince-to-frog", //$NON-NLS-1$ + new BaseFeatureIdentifier("prince-to-frog"), //$NON-NLS-1$ diagnostic -> System.out.println(new DiagnosticExplained(diagnostic).get())); } @@ -71,7 +74,7 @@ public void acquireLicenseGrant() { */ public void denyUnknownFeatureAcquisition() { ServiceInvocationResult acquire = new Access(new TestFramework.Everlasting()) - .acquire("unknown"); //$NON-NLS-1$ + .acquire(new BaseFeatureIdentifier("unknown")); //$NON-NLS-1$ assertFalse(new NoSevereErrors().test(acquire.diagnostic())); assertFalse(acquire.data().isPresent()); assertTrue(acquire.diagnostic().severe().size() > 0); @@ -85,7 +88,7 @@ public void denyUnknownFeatureAcquisition() { */ public void denyFromExpiredLicense() { ServiceInvocationResult acquire = new Access(new TestFramework.Expired()) - .acquire("anti-human-magic.product"); //$NON-NLS-1$ + .acquire(new BaseFeatureIdentifier("anti-human-magic.product")); //$NON-NLS-1$ assertTrue(new NoSevereErrors().test(acquire.diagnostic())); assertTrue(acquire.data().isPresent()); assertContainsCode(new LicenseExpired(), acquire.diagnostic().bearable()); @@ -98,7 +101,7 @@ public void denyFromExpiredLicense() { */ public void denyFromNotStartedLicense() { ServiceInvocationResult acquire = new Access(new TestFramework.NotStarted()) - .acquire("anti-human-magic.product"); //$NON-NLS-1$ + .acquire(new BaseFeatureIdentifier("anti-human-magic.product")); //$NON-NLS-1$ assertTrue(new NoSevereErrors().test(acquire.diagnostic())); assertTrue(acquire.data().isPresent()); assertContainsCode(new LicenseNotStarted(), acquire.diagnostic().bearable()); @@ -117,7 +120,7 @@ private void assertContainsCode(TroubleCode expected, List actual) { */ public void denyUnlicensedFeatureAcquisition() { ServiceInvocationResult acquire = new Access(new TestFramework.Everlasting()) - .acquire("frog-firework"); //$NON-NLS-1$ + .acquire(new BaseFeatureIdentifier("frog-firework")); //$NON-NLS-1$ assertTrue(// new DiagnosticExplained(acquire.diagnostic()).get(), // new NoSevereErrors().test(acquire.diagnostic())); @@ -125,7 +128,8 @@ public void denyUnlicensedFeatureAcquisition() { assertFalse(acquire.data().get().successful()); } - private void successfullyAcquireAndRelease(TestFramework framework, String feature, Consumer report) { + private void successfullyAcquireAndRelease(TestFramework framework, FeatureIdentifier feature, + Consumer report) { Access access = new Access(framework); GrantLockAttempt lock = successfullyAcquire(feature, access, report); successfullyRelease(lock, access); @@ -138,7 +142,8 @@ private void successfullyRelease(GrantLockAttempt lock, Access access) { assertTrue(release.data().get()); } - private GrantLockAttempt successfullyAcquire(String feature, Access access, Consumer onDiagnostic) { + private GrantLockAttempt successfullyAcquire(FeatureIdentifier feature, Access access, + Consumer onDiagnostic) { ServiceInvocationResult acquire = access.acquire(feature); assertTrue(// new DiagnosticExplained(acquire.diagnostic()).get(), // diff --git a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAssessmentTest.java b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAssessmentTest.java index 640201ecd..4900c66ab 100644 --- a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAssessmentTest.java +++ b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessAssessmentTest.java @@ -8,7 +8,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.seal.demo.tests.access; @@ -20,6 +21,7 @@ import java.util.Set; import java.util.stream.Collectors; +import org.eclipse.passage.lic.api.FeatureIdentifier; import org.eclipse.passage.lic.api.ServiceInvocationResult; import org.eclipse.passage.lic.api.requirements.Feature; import org.eclipse.passage.lic.api.requirements.Requirement; @@ -67,7 +69,7 @@ private void assess(TestFramework framework, Set expected) { new HashSet<>(coveredFeatures(result.data().get()))); } - private Set coveredFeatures(ExaminationCertificate certificate) { + private Set coveredFeatures(ExaminationCertificate certificate) { return certificate.satisfied().stream() // .map(Requirement::feature)// .map(Feature::identifier)// diff --git a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessCanUseTest.java b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessCanUseTest.java index c5b5e6394..e5da88005 100644 --- a/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessCanUseTest.java +++ b/tests/org.eclipse.passage.seal.demo.tests/src/org/eclipse/passage/seal/demo/tests/access/AccessCanUseTest.java @@ -8,13 +8,15 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * ArSysOp - initial API and implementation, further support + * ArSysOp - initial API and implementation + * ArSysOp - further support and improvements *******************************************************************************/ package org.eclipse.passage.seal.demo.tests.access; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.eclipse.passage.lic.base.BaseFeatureIdentifier; import org.eclipse.passage.lic.internal.base.access.Access; import org.junit.Test; @@ -26,32 +28,32 @@ public final class AccessCanUseTest { @Test public void allowUnknownFeature() { - assertTrue(new Access(new TestFramework.Expired()).canUse("unkonwn-feature")); //$NON-NLS-1$ + assertTrue(new Access(new TestFramework.Expired()).canUse(new BaseFeatureIdentifier("unkonwn-feature"))); //$NON-NLS-1$ } @Test public void allowKnownFeatureUnderLicense() { - assertTrue(new Access(new TestFramework.Everlasting()).canUse("prince-to-frog")); //$NON-NLS-1$ + assertTrue(new Access(new TestFramework.Everlasting()).canUse(new BaseFeatureIdentifier("prince-to-frog"))); //$NON-NLS-1$ } @Test public void forbidKnownFeatureUnderExpiredLicense() { - assertFalse(new Access(new TestFramework.Expired()).canUse("prince-to-frog")); //$NON-NLS-1$ + assertFalse(new Access(new TestFramework.Expired()).canUse(new BaseFeatureIdentifier("prince-to-frog"))); //$NON-NLS-1$ } @Test public void forbidKnownFeatureUnderNotStartedLicense() { - assertFalse(new Access(new TestFramework.NotStarted()).canUse("prince-to-frog")); //$NON-NLS-1$ + assertFalse(new Access(new TestFramework.NotStarted()).canUse(new BaseFeatureIdentifier("prince-to-frog"))); //$NON-NLS-1$ } @Test public void forbidKnownFeatureErrorRestrictedWithoutLicense() { - assertFalse(new Access(new TestFramework.Expired()).canUse("frog-firework")); //$NON-NLS-1$ + assertFalse(new Access(new TestFramework.Expired()).canUse(new BaseFeatureIdentifier("frog-firework"))); //$NON-NLS-1$ } @Test public void allowKnownFeatureInfoRestrictedWithoutLicense() { - assertTrue(new Access(new TestFramework.Expired()).canUse("frog-to-prince")); //$NON-NLS-1$ + assertTrue(new Access(new TestFramework.Expired()).canUse(new BaseFeatureIdentifier("frog-to-prince"))); //$NON-NLS-1$ } }