licenseReadingService();
-
- /**
- *
- * If the given {@code license} relates to the library, it should install to the
- * license residence, configured for this library's
- * {@code access cycle configuration}
- *
- *
- *
- * If the {@code license} file does not belong to the library, report negative
- * result with bearable diagnostic of {@linkplain ForeignLicense} trouble code.
- *
- *
- * If the {@code license} file can be read, but was not imported for some
- * reason, report negative result with severe trouble in diagnostic.
- *
- *
- * In case the {@code license} has been actually installed, report positive
- * result, optionally with whatever informative diagnostic.
- *
- *
- * @return diagnosed result of installation: whether installation of the
- * {@code license} has been actually performed or not
- */
- ServiceInvocationResult installLicense(Path license);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2022 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.access;
+
+import java.nio.file.Path;
+
+import org.eclipse.passage.lic.api.LicensedProduct;
+import org.eclipse.passage.lic.api.PassageLicenseCoverage;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.agreements.AgreementAcceptanceService;
+import org.eclipse.passage.lic.api.agreements.AgreementToAccept;
+import org.eclipse.passage.lic.api.conditions.mining.LicenseReadingService;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.diagnostic.code.ForeignLicense;
+
+/**
+ *
+ * Represent a library's licensing aspect for an owning product.
+ *
+ *
+ * Implementation must be stateless: service is to be instantiated as many times
+ * as it is appealed to, no caching to perform for scanned extensions.
+ *
+ *
+ * A library appeals to it's own standalone {@linkplain Framewrok} instance when
+ * checks license coverage for its features. Nothing to be contributed to the
+ * product {@code access cycle} for this scenario.
+ *
+ *
+ * However, a library should participate in
+ *
+ *
+ *
+ *
+ * - 1. the owning product license coverage assessment
+ *
+ * - 2. bulk license import (prevent end user from dealing with all the
+ * product-libraries relations)
+ *
+ *
+ *
+ *
+ * smoothly, so it should
+ *
+ *
+ *
+ *
+ * - 1.1. supply it's own assessment results when asked: {@code access()}
+ *
+ * - 1.2. facilitate acceptance of a license agreement, in case it demands
+ * some for acceptance:
+ * {@code agreementsService(AgreementToAccept agreement)}
+ *
+ * - 2.1. supply a {@linkplain LicenseReadingService} that will read licensing
+ * {@linkplain Condition}s from a license file, in case it can be treated a this
+ * library's license
+ *
+ * - 2.2. provide a way to install a license (it defined to be this library's
+ * license) to path configured for the library as license residence:
+ * {@code installLicense(Path license)}.
+ *
+ *
+ *
+ */
+public interface Library extends PassageLicenseCoverage {
+
+ /**
+ * Library represents its own product.
+ */
+ LicensedProduct product();
+
+ /**
+ * Request a library to perform full license coverage assessment.
+ */
+ @Override
+ ServiceInvocationResult assess();
+
+ /**
+ *
+ * For a given {@code agreement} a library should perform an analysis if this
+ * agreement is demanded by it, and in this case supply an instance and
+ * {@linkplain AgreementAcceptanceService} for acceptance.
+ *
+ *
+ * If the {@code agreement} does not belong to the library, report empty result
+ * with bearable diagnostic of {@linkplain ForeignLicense} trouble code.
+ *
+ */
+ ServiceInvocationResult agreementsService(AgreementToAccept agreement);
+
+ /**
+ * Supply license reading service configured for the library to be used for
+ * imported license analysis.
+ */
+ ServiceInvocationResult licenseReadingService();
+
+ /**
+ *
+ * If the given {@code license} relates to the library, it should install to the
+ * license residence, configured for this library's
+ * {@code access cycle configuration}
+ *
+ *
+ *
+ * If the {@code license} file does not belong to the library, report negative
+ * result with bearable diagnostic of {@linkplain ForeignLicense} trouble code.
+ *
+ *
+ * If the {@code license} file can be read, but was not imported for some
+ * reason, report negative result with severe trouble in diagnostic.
+ *
+ *
+ * In case the {@code license} has been actually installed, report positive
+ * result, optionally with whatever informative diagnostic.
+ *
+ *
+ * @return diagnosed result of installation: whether installation of the
+ * {@code license} has been actually performed or not
+ */
+ ServiceInvocationResult installLicense(Path license);
+
+}
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 b8457f078..a4bf0f924 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,87 +1,87 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import org.eclipse.passage.lic.api.Framework;
-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.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
-import org.eclipse.passage.lic.base.diagnostic.SumOfDiagnostics;
-import org.eclipse.passage.lic.base.diagnostic.code.NoRequirements;
-import org.eclipse.passage.lic.base.restrictions.CertificateIsRestrictive;
-
-/**
- * Top-level access cycle
- *
- * @since 2.1
- */
-public final class Access {
-
- private final Framework framework;
-
- public Access(Framework framework) {
- this.framework = framework;
- }
-
- public boolean canUse(String feature) {
- return new Allow(framework, feature).apply();
- }
-
- public ServiceInvocationResult assess() {
- return new Assess(framework).apply();
- }
-
- public ServiceInvocationResult acquire(String feature) {
- ServiceInvocationResult certificate = new Assess(framework, feature).apply();
- if (new CertificateIsRestrictive().test(certificate.data())) {
- return failOnAccess(certificate);
- }
- if (empty(certificate.data().get())) {
- return unknownFeature(feature, certificate.diagnostic());
- }
- ServiceInvocationResult lock = new Lock(framework).lock(certificate.data().get());
- return new BaseServiceInvocationResult<>(//
- new SumOfDiagnostics().apply(certificate.diagnostic(), lock.diagnostic()), //
- lock.data());
- }
-
- public ServiceInvocationResult release(GrantLockAttempt lock) {
- return new Lock(framework).unlock(lock);
- }
-
- private ServiceInvocationResult failOnAccess(
- ServiceInvocationResult assessment) {
- if (assessment.data().isPresent()) {
- return new BaseServiceInvocationResult<>(assessment.diagnostic(),
- new BaseGrantLockAttempt.Failed(assessment.data().get()));
- }
- return new BaseServiceInvocationResult<>(assessment.diagnostic());
- }
-
- private ServiceInvocationResult unknownFeature(String feature, Diagnostic diagnostic) {
- return new BaseServiceInvocationResult<>(//
- new SumOfDiagnostics().apply(//
- diagnostic, //
- new BaseDiagnostic(new Trouble(new NoRequirements(), feature))//
- ));
- }
-
- private boolean empty(ExaminationCertificate certificate) {
- return certificate.restrictions().isEmpty() && certificate.satisfied().isEmpty();
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import org.eclipse.passage.lic.api.Framework;
+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.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
+import org.eclipse.passage.lic.base.diagnostic.SumOfDiagnostics;
+import org.eclipse.passage.lic.base.diagnostic.code.NoRequirements;
+import org.eclipse.passage.lic.base.restrictions.CertificateIsRestrictive;
+
+/**
+ * Top-level access cycle
+ *
+ * @since 2.1
+ */
+public final class Access {
+
+ private final Framework framework;
+
+ public Access(Framework framework) {
+ this.framework = framework;
+ }
+
+ public boolean canUse(String feature) {
+ return new Allow(framework, feature).apply();
+ }
+
+ public ServiceInvocationResult assess() {
+ return new Assess(framework).apply();
+ }
+
+ public ServiceInvocationResult acquire(String feature) {
+ ServiceInvocationResult certificate = new Assess(framework, feature).apply();
+ if (new CertificateIsRestrictive().test(certificate.data())) {
+ return failOnAccess(certificate);
+ }
+ if (empty(certificate.data().get())) {
+ return unknownFeature(feature, certificate.diagnostic());
+ }
+ ServiceInvocationResult lock = new Lock(framework).lock(certificate.data().get());
+ return new BaseServiceInvocationResult<>(//
+ new SumOfDiagnostics().apply(certificate.diagnostic(), lock.diagnostic()), //
+ lock.data());
+ }
+
+ public ServiceInvocationResult release(GrantLockAttempt lock) {
+ return new Lock(framework).unlock(lock);
+ }
+
+ private ServiceInvocationResult failOnAccess(
+ ServiceInvocationResult assessment) {
+ if (assessment.data().isPresent()) {
+ return new BaseServiceInvocationResult<>(assessment.diagnostic(),
+ new BaseGrantLockAttempt.Failed(assessment.data().get()));
+ }
+ return new BaseServiceInvocationResult<>(assessment.diagnostic());
+ }
+
+ private ServiceInvocationResult unknownFeature(String feature, Diagnostic diagnostic) {
+ return new BaseServiceInvocationResult<>(//
+ new SumOfDiagnostics().apply(//
+ diagnostic, //
+ new BaseDiagnostic(new Trouble(new NoRequirements(), feature))//
+ ));
+ }
+
+ private boolean empty(ExaminationCertificate certificate) {
+ return certificate.restrictions().isEmpty() && certificate.satisfied().isEmpty();
+ }
+
+}
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 175ebb47e..b954dcd7a 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,43 +1,43 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import org.eclipse.passage.lic.api.Framework;
-import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.base.diagnostic.NoSevereErrors;
-import org.eclipse.passage.lic.base.restrictions.NoSevereRestrictions;
-
-final class Allow extends Cycle {
-
- Allow(Framework framework, String feature) {
- super(framework, feature);
- }
-
- @Override
- protected Boolean stopOnError(Diagnostic diagnostic) {
- return false;
- }
-
- @Override
- protected Boolean stopOnCertificate(ExaminationCertificate certificate, Diagnostic diagnostic) {
- return new NoSevereErrors().test(diagnostic) && //
- new NoSevereRestrictions().test(certificate);
- }
-
- @Override
- protected Boolean freeWayOut() {
- return true;
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import org.eclipse.passage.lic.api.Framework;
+import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.diagnostic.NoSevereErrors;
+import org.eclipse.passage.lic.base.restrictions.NoSevereRestrictions;
+
+final class Allow extends Cycle {
+
+ Allow(Framework framework, String feature) {
+ super(framework, feature);
+ }
+
+ @Override
+ protected Boolean stopOnError(Diagnostic diagnostic) {
+ return false;
+ }
+
+ @Override
+ protected Boolean stopOnCertificate(ExaminationCertificate certificate, Diagnostic diagnostic) {
+ return new NoSevereErrors().test(diagnostic) && //
+ new NoSevereRestrictions().test(certificate);
+ }
+
+ @Override
+ protected Boolean freeWayOut() {
+ return true;
+ }
+
+}
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 e8d3502b6..aeea5209c 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,63 +1,63 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.Collections;
-
-import org.eclipse.passage.lic.api.Framework;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.restrictions.BaseExaminationCertificate;
-
-final class Assess extends Cycle> {
-
- Assess(Framework framework, String feature) {
- super(framework, feature);
- }
-
- Assess(Framework framework) {
- super(framework);
- }
-
- @Override
- protected ServiceInvocationResult stopOnError(Diagnostic diagnostic) {
- return new BaseServiceInvocationResult(diagnostic);
- }
-
- @Override
- protected ServiceInvocationResult stopOnCertificate(ExaminationCertificate certificate,
- Diagnostic diagnostic) {
- if (feature().isPresent()) {
- return acquire(certificate, diagnostic);
- }
- return new BaseServiceInvocationResult(diagnostic, certificate);
- }
-
- @Override
- protected ServiceInvocationResult freeWayOut() {
- return new BaseServiceInvocationResult(//
- new BaseExaminationCertificate(//
- Collections.emptyMap(), //
- Collections.emptySet()));
- }
-
- private ServiceInvocationResult acquire(ExaminationCertificate certificate,
- Diagnostic diagnostic) {
-
- // TODO: YTBD
- return new BaseServiceInvocationResult(diagnostic, certificate);
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.Collections;
+
+import org.eclipse.passage.lic.api.Framework;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.restrictions.BaseExaminationCertificate;
+
+final class Assess extends Cycle> {
+
+ Assess(Framework framework, String feature) {
+ super(framework, feature);
+ }
+
+ Assess(Framework framework) {
+ super(framework);
+ }
+
+ @Override
+ protected ServiceInvocationResult stopOnError(Diagnostic diagnostic) {
+ return new BaseServiceInvocationResult(diagnostic);
+ }
+
+ @Override
+ protected ServiceInvocationResult stopOnCertificate(ExaminationCertificate certificate,
+ Diagnostic diagnostic) {
+ if (feature().isPresent()) {
+ return acquire(certificate, diagnostic);
+ }
+ return new BaseServiceInvocationResult(diagnostic, certificate);
+ }
+
+ @Override
+ protected ServiceInvocationResult freeWayOut() {
+ return new BaseServiceInvocationResult(//
+ new BaseExaminationCertificate(//
+ Collections.emptyMap(), //
+ Collections.emptySet()));
+ }
+
+ private ServiceInvocationResult acquire(ExaminationCertificate certificate,
+ Diagnostic diagnostic) {
+
+ // TODO: YTBD
+ return new BaseServiceInvocationResult(diagnostic, certificate);
+ }
+
+}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/BaseGrantLockAttempt.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/BaseGrantLockAttempt.java
index 076ae8862..8baa33ff7 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/BaseGrantLockAttempt.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/BaseGrantLockAttempt.java
@@ -1,75 +1,75 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.Objects;
-
-import org.eclipse.passage.lic.api.access.GrantLockAttempt;
-import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-
-abstract class BaseGrantLockAttempt implements GrantLockAttempt {
-
- private final ExaminationCertificate certificate;
-
- protected BaseGrantLockAttempt(ExaminationCertificate certificate) {
- Objects.requireNonNull(certificate, "BaseGrantLock::certificate"); //$NON-NLS-1$
- this.certificate = certificate;
- }
-
- @Override
- public ExaminationCertificate certificate() {
- return certificate;
- }
-
- final static class Successful extends BaseGrantLockAttempt {
-
- private final GrantAcquisition grant;
-
- Successful(ExaminationCertificate certificate, GrantAcquisition grant) {
- super(certificate);
- Objects.requireNonNull(grant, "BaseGrantLock::grant"); //$NON-NLS-1$
- this.grant = grant;
- }
-
- @Override
- public boolean successful() {
- return true;
- }
-
- @Override
- public GrantAcquisition grant() {
- return grant;
- }
-
- }
-
- final static class Failed extends BaseGrantLockAttempt {
-
- protected Failed(ExaminationCertificate certificate) {
- super(certificate);
- }
-
- @Override
- public boolean successful() {
- return false;
- }
-
- @Override
- public GrantAcquisition grant() {
- throw new IllegalStateException("Failed lock is not supposed to supply grant"); //$NON-NLS-1$
- }
-
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.Objects;
+
+import org.eclipse.passage.lic.api.access.GrantLockAttempt;
+import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+
+abstract class BaseGrantLockAttempt implements GrantLockAttempt {
+
+ private final ExaminationCertificate certificate;
+
+ protected BaseGrantLockAttempt(ExaminationCertificate certificate) {
+ Objects.requireNonNull(certificate, "BaseGrantLock::certificate"); //$NON-NLS-1$
+ this.certificate = certificate;
+ }
+
+ @Override
+ public ExaminationCertificate certificate() {
+ return certificate;
+ }
+
+ final static class Successful extends BaseGrantLockAttempt {
+
+ private final GrantAcquisition grant;
+
+ Successful(ExaminationCertificate certificate, GrantAcquisition grant) {
+ super(certificate);
+ Objects.requireNonNull(grant, "BaseGrantLock::grant"); //$NON-NLS-1$
+ this.grant = grant;
+ }
+
+ @Override
+ public boolean successful() {
+ return true;
+ }
+
+ @Override
+ public GrantAcquisition grant() {
+ return grant;
+ }
+
+ }
+
+ final static class Failed extends BaseGrantLockAttempt {
+
+ protected Failed(ExaminationCertificate certificate) {
+ super(certificate);
+ }
+
+ @Override
+ public boolean successful() {
+ return false;
+ }
+
+ @Override
+ public GrantAcquisition grant() {
+ throw new IllegalStateException("Failed lock is not supposed to supply grant"); //$NON-NLS-1$
+ }
+
+ }
+
+}
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 98714ad15..cc25cf156 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,80 +1,80 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-import org.eclipse.passage.lic.api.LicensedProduct;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget;
-import org.eclipse.passage.lic.api.conditions.ConditionPack;
-import org.eclipse.passage.lic.api.conditions.mining.MinedConditions;
-import org.eclipse.passage.lic.api.diagnostic.Trouble;
-import org.eclipse.passage.lic.api.registry.Registry;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.SumOfCollections;
-import org.eclipse.passage.lic.base.conditions.ConditionsFeatureFilter;
-import org.eclipse.passage.lic.base.diagnostic.code.NoServicesOfType;
-import org.eclipse.passage.lic.internal.base.i18n.AccessCycleMessages;
-
-/**
- * @since 2.1
- */
-final class Conditions implements Supplier>> {
-
- private final Registry registry;
- private final LicensedProduct product;
- private final Function/
- ServiceInvocationResult>, //
- ServiceInvocationResult>> filter;
-
- public Conditions(Registry registry, LicensedProduct product,
- String feature) {
- this(registry, product, new ConditionsFeatureFilter(feature).get());
- }
-
- public Conditions(Registry registry, LicensedProduct product) {
- this(registry, product, Function.identity());
- }
-
- public Conditions(Registry registry, LicensedProduct product,
- Function>, ServiceInvocationResult>> filter) {
- Objects.requireNonNull(registry, "Conditions::registry"); //$NON-NLS-1$
- Objects.requireNonNull(product, "Conditions::product"); //$NON-NLS-1$
- Objects.requireNonNull(filter, "Conditions::filter"); //$NON-NLS-1$
- this.registry = registry;
- this.product = product;
- this.filter = filter;
- }
-
- @Override
- public ServiceInvocationResult> get() {
- if (registry.services().isEmpty()) {
- return new BaseServiceInvocationResult>(//
- new Trouble(//
- new NoServicesOfType(AccessCycleMessages.getString("Conditions.servive_type")), // //$NON-NLS-1$
- AccessCycleMessages.getString("Conditions.no_miners"))); //$NON-NLS-1$
- }
- return registry.services().stream() //
- .map(miner -> miner.all(product)) //
- .reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCollections()))//
- .map(filter) //
- .orElse(new BaseServiceInvocationResult<>(Collections.emptyList()));
-
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.eclipse.passage.lic.api.LicensedProduct;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget;
+import org.eclipse.passage.lic.api.conditions.ConditionPack;
+import org.eclipse.passage.lic.api.conditions.mining.MinedConditions;
+import org.eclipse.passage.lic.api.diagnostic.Trouble;
+import org.eclipse.passage.lic.api.registry.Registry;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.SumOfCollections;
+import org.eclipse.passage.lic.base.conditions.ConditionsFeatureFilter;
+import org.eclipse.passage.lic.base.diagnostic.code.NoServicesOfType;
+import org.eclipse.passage.lic.internal.base.i18n.AccessCycleMessages;
+
+/**
+ * @since 2.1
+ */
+final class Conditions implements Supplier>> {
+
+ private final Registry registry;
+ private final LicensedProduct product;
+ private final Function/
+ ServiceInvocationResult>, //
+ ServiceInvocationResult>> filter;
+
+ public Conditions(Registry registry, LicensedProduct product,
+ String feature) {
+ this(registry, product, new ConditionsFeatureFilter(feature).get());
+ }
+
+ public Conditions(Registry registry, LicensedProduct product) {
+ this(registry, product, Function.identity());
+ }
+
+ public Conditions(Registry registry, LicensedProduct product,
+ Function>, ServiceInvocationResult>> filter) {
+ Objects.requireNonNull(registry, "Conditions::registry"); //$NON-NLS-1$
+ Objects.requireNonNull(product, "Conditions::product"); //$NON-NLS-1$
+ Objects.requireNonNull(filter, "Conditions::filter"); //$NON-NLS-1$
+ this.registry = registry;
+ this.product = product;
+ this.filter = filter;
+ }
+
+ @Override
+ public ServiceInvocationResult> get() {
+ if (registry.services().isEmpty()) {
+ return new BaseServiceInvocationResult>(//
+ new Trouble(//
+ new NoServicesOfType(AccessCycleMessages.getString("Conditions.servive_type")), // //$NON-NLS-1$
+ AccessCycleMessages.getString("Conditions.no_miners"))); //$NON-NLS-1$
+ }
+ return registry.services().stream() //
+ .map(miner -> miner.all(product)) //
+ .reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCollections()))//
+ .map(filter) //
+ .orElse(new BaseServiceInvocationResult<>(Collections.emptyList()));
+
+ }
+
+}
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 c63b42e33..ee648e42c 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,164 +1,164 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Supplier;
-
-import org.eclipse.passage.lic.api.Framework;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.conditions.ConditionPack;
-import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
-import org.eclipse.passage.lic.api.requirements.Requirement;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
-import org.eclipse.passage.lic.base.diagnostic.SumOfDiagnostics;
-import org.eclipse.passage.lic.internal.base.access.Permissions.AppliedLicenses;
-
-abstract class Cycle {
-
- private final Framework framework;
- private final CycleFilter filter;
- private final List diagnostics;
- private final Optional feature;
-
- Cycle(Framework framework) {
- this(framework, new CycleFilter(), Optional.empty());
- }
-
- Cycle(Framework framework, String 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$
- Objects.requireNonNull(filter, "Cycle::filter"); //$NON-NLS-1$
- this.framework = framework;
- this.filter = filter;
- this.diagnostics = new ArrayList<>();
- this.feature = feature;
- }
-
- T apply() {
- return examine(this::requirements, this::permissions);
- }
-
- protected Optional feature() {
- return feature;
- }
-
- private T examine(Supplier>> requirements, //
- Supplier> permissions) {
- ServiceInvocationResult> reqs = requirements.get();
- if (failed(reqs)) {
- return stop();
- }
- if (empty(reqs)) {
- // no requirements means no restrictions anyway, which is always green light,
- // we just want to avoid heavy operations below
- return freeWayOut();
- }
- ServiceInvocationResult perms = permissions.get();
- if (failed(perms)) {
- return stop();
- }
- ServiceInvocationResult examination = //
- restrictions(reqs.data().get(), perms.data().get());
- if (failed(examination)) {
- return stop();
- }
- return stop(examination.data().get());
- }
-
- private T stop() {
- return stopOnError(diagnostic());
- }
-
- private T stop(ExaminationCertificate certificate) {
- return stopOnCertificate(certificate, diagnostic());
- }
-
- /**
- * Severe error cannot be fixed by new data (say, imported license). It must
- * cause unavoidable denial, but for user's sake we'd like to expose the state
- * of affairs to support one with the failure reason information.
- */
- protected abstract T stopOnError(Diagnostic diagnostic);
-
- /**
- * We successfully made it to and through the examination, and even have got a
- * certificate!
- */
- protected abstract T stopOnCertificate(ExaminationCertificate certificate, Diagnostic diagnostic);
-
- protected abstract T freeWayOut();
-
- private Diagnostic diagnostic() {
- return diagnostics.stream().reduce(new BaseDiagnostic(), new SumOfDiagnostics());
- }
-
- private boolean failed(ServiceInvocationResult> result) {
- return !result.diagnostic().severe().isEmpty();
- }
-
- private boolean empty(ServiceInvocationResult> collection) {
- return collection.data().map(Collection::isEmpty).orElse(true);
- }
-
- private ServiceInvocationResult scan(ServiceInvocationResult result) {
- diagnostics.add(result.diagnostic());
- return result;
- }
-
- private ServiceInvocationResult> requirements() {
- return scan(new Requirements(//
- framework.accessCycleConfiguration().requirementResolvers().get(), //
- filter.requiremental(), //
- feature//
- ).get());
- }
-
- private ServiceInvocationResult> conditions() {
- return scan(new Conditions(//
- framework.accessCycleConfiguration().conditionMiners().get(), //
- framework.product(), //
- filter.conditional()).get());
- }
-
- private ServiceInvocationResult permissions() {
- ServiceInvocationResult> conditions = conditions();
- if (failed(conditions) || empty(conditions)) {
- return new BaseServiceInvocationResult(conditions.diagnostic(), new AppliedLicenses());
- }
- return scan(new Permissions(//
- framework.accessCycleConfiguration().permissionEmitters().get(), //
- conditions.data().get(), //
- framework.product()).get());
- }
-
- private ServiceInvocationResult restrictions(Collection requirements,
- AppliedLicenses permissions) {
- return scan(new Restrictions(//
- framework.product(), //
- framework.accessCycleConfiguration().examinators().get(), //
- framework.accessCycleConfiguration().acceptance(), //
- requirements, //
- permissions).get());
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+import org.eclipse.passage.lic.api.Framework;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.conditions.ConditionPack;
+import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
+import org.eclipse.passage.lic.api.requirements.Requirement;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
+import org.eclipse.passage.lic.base.diagnostic.SumOfDiagnostics;
+import org.eclipse.passage.lic.internal.base.access.Permissions.AppliedLicenses;
+
+abstract class Cycle {
+
+ private final Framework framework;
+ private final CycleFilter filter;
+ private final List diagnostics;
+ private final Optional feature;
+
+ Cycle(Framework framework) {
+ this(framework, new CycleFilter(), Optional.empty());
+ }
+
+ Cycle(Framework framework, String 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$
+ Objects.requireNonNull(filter, "Cycle::filter"); //$NON-NLS-1$
+ this.framework = framework;
+ this.filter = filter;
+ this.diagnostics = new ArrayList<>();
+ this.feature = feature;
+ }
+
+ T apply() {
+ return examine(this::requirements, this::permissions);
+ }
+
+ protected Optional feature() {
+ return feature;
+ }
+
+ private T examine(Supplier>> requirements, //
+ Supplier> permissions) {
+ ServiceInvocationResult> reqs = requirements.get();
+ if (failed(reqs)) {
+ return stop();
+ }
+ if (empty(reqs)) {
+ // no requirements means no restrictions anyway, which is always green light,
+ // we just want to avoid heavy operations below
+ return freeWayOut();
+ }
+ ServiceInvocationResult perms = permissions.get();
+ if (failed(perms)) {
+ return stop();
+ }
+ ServiceInvocationResult examination = //
+ restrictions(reqs.data().get(), perms.data().get());
+ if (failed(examination)) {
+ return stop();
+ }
+ return stop(examination.data().get());
+ }
+
+ private T stop() {
+ return stopOnError(diagnostic());
+ }
+
+ private T stop(ExaminationCertificate certificate) {
+ return stopOnCertificate(certificate, diagnostic());
+ }
+
+ /**
+ * Severe error cannot be fixed by new data (say, imported license). It must
+ * cause unavoidable denial, but for user's sake we'd like to expose the state
+ * of affairs to support one with the failure reason information.
+ */
+ protected abstract T stopOnError(Diagnostic diagnostic);
+
+ /**
+ * We successfully made it to and through the examination, and even have got a
+ * certificate!
+ */
+ protected abstract T stopOnCertificate(ExaminationCertificate certificate, Diagnostic diagnostic);
+
+ protected abstract T freeWayOut();
+
+ private Diagnostic diagnostic() {
+ return diagnostics.stream().reduce(new BaseDiagnostic(), new SumOfDiagnostics());
+ }
+
+ private boolean failed(ServiceInvocationResult> result) {
+ return !result.diagnostic().severe().isEmpty();
+ }
+
+ private boolean empty(ServiceInvocationResult> collection) {
+ return collection.data().map(Collection::isEmpty).orElse(true);
+ }
+
+ private ServiceInvocationResult scan(ServiceInvocationResult result) {
+ diagnostics.add(result.diagnostic());
+ return result;
+ }
+
+ private ServiceInvocationResult> requirements() {
+ return scan(new Requirements(//
+ framework.accessCycleConfiguration().requirementResolvers().get(), //
+ filter.requiremental(), //
+ feature//
+ ).get());
+ }
+
+ private ServiceInvocationResult> conditions() {
+ return scan(new Conditions(//
+ framework.accessCycleConfiguration().conditionMiners().get(), //
+ framework.product(), //
+ filter.conditional()).get());
+ }
+
+ private ServiceInvocationResult permissions() {
+ ServiceInvocationResult> conditions = conditions();
+ if (failed(conditions) || empty(conditions)) {
+ return new BaseServiceInvocationResult(conditions.diagnostic(), new AppliedLicenses());
+ }
+ return scan(new Permissions(//
+ framework.accessCycleConfiguration().permissionEmitters().get(), //
+ conditions.data().get(), //
+ framework.product()).get());
+ }
+
+ private ServiceInvocationResult restrictions(Collection requirements,
+ AppliedLicenses permissions) {
+ return scan(new Restrictions(//
+ framework.product(), //
+ framework.accessCycleConfiguration().examinators().get(), //
+ framework.accessCycleConfiguration().acceptance(), //
+ requirements, //
+ permissions).get());
+ }
+
+}
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 ef38ba990..ae8a09b91 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,56 +1,56 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.Collection;
-import java.util.function.Function;
-
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.conditions.ConditionPack;
-import org.eclipse.passage.lic.api.requirements.Requirement;
-import org.eclipse.passage.lic.base.conditions.ConditionsFeatureFilter;
-import org.eclipse.passage.lic.base.requirements.RequirementsFeatureFilter;
-
-final class CycleFilter {
-
- private final Function/
- ServiceInvocationResult>, //
- ServiceInvocationResult>> requiremental;
- private final Function/
- ServiceInvocationResult>, //
- ServiceInvocationResult>> conditional;
-
- CycleFilter() {
- this(Function.identity(), Function.identity());
- }
-
- CycleFilter(String feature) {
- this(new RequirementsFeatureFilter(feature).get(), new ConditionsFeatureFilter(feature).get());
- }
-
- private CycleFilter(
- Function>, ServiceInvocationResult>> requiremental,
- Function>, ServiceInvocationResult>> conditional) {
- this.requiremental = requiremental;
- this.conditional = conditional;
- }
-
- Function>, ServiceInvocationResult>> requiremental() {
- return requiremental;
- }
-
- Function>, ServiceInvocationResult>> conditional() {
- return conditional;
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.Collection;
+import java.util.function.Function;
+
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.conditions.ConditionPack;
+import org.eclipse.passage.lic.api.requirements.Requirement;
+import org.eclipse.passage.lic.base.conditions.ConditionsFeatureFilter;
+import org.eclipse.passage.lic.base.requirements.RequirementsFeatureFilter;
+
+final class CycleFilter {
+
+ private final Function/
+ ServiceInvocationResult>, //
+ ServiceInvocationResult>> requiremental;
+ private final Function/
+ ServiceInvocationResult>, //
+ ServiceInvocationResult>> conditional;
+
+ CycleFilter() {
+ this(Function.identity(), Function.identity());
+ }
+
+ CycleFilter(String feature) {
+ this(new RequirementsFeatureFilter(feature).get(), new ConditionsFeatureFilter(feature).get());
+ }
+
+ private CycleFilter(
+ Function>, ServiceInvocationResult>> requiremental,
+ Function>, ServiceInvocationResult>> conditional) {
+ this.requiremental = requiremental;
+ this.conditional = conditional;
+ }
+
+ Function>, ServiceInvocationResult>> requiremental() {
+ return requiremental;
+ }
+
+ Function>, ServiceInvocationResult>> conditional() {
+ return conditional;
+ }
+
+}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Libraries.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Libraries.java
index e7faf36a8..cc023b261 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Libraries.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Libraries.java
@@ -1,101 +1,101 @@
-/*******************************************************************************
- * Copyright (c) 2022 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.internal.base.access;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.function.BinaryOperator;
-import java.util.function.Supplier;
-
-import org.eclipse.passage.lic.api.LicensedProduct;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.agreements.AgreementAcceptanceService;
-import org.eclipse.passage.lic.api.agreements.AgreementToAccept;
-import org.eclipse.passage.lic.api.conditions.mining.LicenseReadingService;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult.Sum;
-import org.eclipse.passage.lic.base.access.Library;
-import org.eclipse.passage.lic.base.diagnostic.SumOfLists;
-
-/**
- * Set of libraries registered for the the product
- *
- * @see Library
- */
-public final class Libraries {
-
- private final List libraries;
- private final Supplier owner;
-
- public Libraries(Supplier> libraries, Supplier owner) {
- this(libraries.get(), owner);
- }
-
- public Libraries(List libraries, Supplier owner) {
- this.libraries = libraries;
- this.owner = owner;
- }
-
- public boolean empty() {
- return libraries.isEmpty();
- }
-
- public LicensedProduct product() {
- return owner.get();
- }
-
- public Optional> assess() {
- return libraries.stream()//
- .map(Library::assess).reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCertificates()));
- }
-
- public Optional>> agreementsServices(
- AgreementToAccept agreement) {
- return libraries.stream()//
- .map(library -> library.agreementsService(agreement))//
- .map(this::enlisted)//
- .reduce(sum());
- }
-
- public Optional>> licenseReadingServices() {
- return libraries.stream()//
- .map(Library::licenseReadingService)//
- .map(this::enlisted)//
- .reduce(sum());
- }
-
- public Optional> installLicense(Path license) throws IOException {
- return libraries.stream()//
- .map(library -> library.installLicense(license))//
- .reduce(new Sum(or()));
- }
-
- private ServiceInvocationResult> enlisted(ServiceInvocationResult origin) {
- List data = origin.data().isPresent() ? Arrays.asList(origin.data().get()) : Collections.emptyList();
- return new BaseServiceInvocationResult>(origin.diagnostic(), data);
- }
-
- private Sum> sum() {
- return new Sum>(new SumOfLists());
- }
-
- private BinaryOperator or() {
- return (first, second) -> first || second;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2022 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.internal.base.access;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.BinaryOperator;
+import java.util.function.Supplier;
+
+import org.eclipse.passage.lic.api.LicensedProduct;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.agreements.AgreementAcceptanceService;
+import org.eclipse.passage.lic.api.agreements.AgreementToAccept;
+import org.eclipse.passage.lic.api.conditions.mining.LicenseReadingService;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult.Sum;
+import org.eclipse.passage.lic.base.access.Library;
+import org.eclipse.passage.lic.base.diagnostic.SumOfLists;
+
+/**
+ * Set of libraries registered for the the product
+ *
+ * @see Library
+ */
+public final class Libraries {
+
+ private final List libraries;
+ private final Supplier owner;
+
+ public Libraries(Supplier> libraries, Supplier owner) {
+ this(libraries.get(), owner);
+ }
+
+ public Libraries(List libraries, Supplier owner) {
+ this.libraries = libraries;
+ this.owner = owner;
+ }
+
+ public boolean empty() {
+ return libraries.isEmpty();
+ }
+
+ public LicensedProduct product() {
+ return owner.get();
+ }
+
+ public Optional> assess() {
+ return libraries.stream()//
+ .map(Library::assess).reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCertificates()));
+ }
+
+ public Optional>> agreementsServices(
+ AgreementToAccept agreement) {
+ return libraries.stream()//
+ .map(library -> library.agreementsService(agreement))//
+ .map(this::enlisted)//
+ .reduce(sum());
+ }
+
+ public Optional>> licenseReadingServices() {
+ return libraries.stream()//
+ .map(Library::licenseReadingService)//
+ .map(this::enlisted)//
+ .reduce(sum());
+ }
+
+ public Optional> installLicense(Path license) throws IOException {
+ return libraries.stream()//
+ .map(library -> library.installLicense(license))//
+ .reduce(new Sum(or()));
+ }
+
+ private ServiceInvocationResult> enlisted(ServiceInvocationResult origin) {
+ List data = origin.data().isPresent() ? Arrays.asList(origin.data().get()) : Collections.emptyList();
+ return new BaseServiceInvocationResult>(origin.diagnostic(), data);
+ }
+
+ private Sum> sum() {
+ return new Sum>(new SumOfLists());
+ }
+
+ private BinaryOperator or() {
+ return (first, second) -> first || second;
+ }
+
+}
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 bdd405fae..a94111fb8 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,199 +1,199 @@
-/*******************************************************************************
- * Copyright (c) 2020, 2022 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.internal.base.access;
-
-import java.util.Collections;
-import java.util.stream.Collectors;
-
-import org.eclipse.passage.lic.api.Framework;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.access.GrantLockAttempt;
-import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
-import org.eclipse.passage.lic.api.acquire.GrantsTraceService;
-import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionService;
-import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionServicesRegistry;
-import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget;
-import org.eclipse.passage.lic.api.conditions.evaluation.Permission;
-import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
-import org.eclipse.passage.lic.api.diagnostic.Trouble;
-import org.eclipse.passage.lic.api.requirements.Requirement;
-import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
-import org.eclipse.passage.lic.api.restrictions.Restriction;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
-import org.eclipse.passage.lic.base.diagnostic.code.NoServicesOfType;
-import org.eclipse.passage.lic.base.diagnostic.code.ServiceFailedOnMorsel;
-import org.eclipse.passage.lic.base.diagnostic.code.TentativeAccess;
-import org.eclipse.passage.lic.base.restrictions.CertificateIsRestrictive;
-import org.eclipse.passage.lic.base.restrictions.RequirementDemandsExecutionStop;
-import org.eclipse.passage.lic.internal.base.access.storage.GrantReleased;
-import org.eclipse.passage.lic.internal.base.i18n.AccessCycleMessages;
-
-final class Lock {
-
- private final LicenseAcquisitionServicesRegistry acquirers;
- private final GrantsTraceService traces;
-
- Lock(LicenseAcquisitionServicesRegistry acquirers, GrantsTraceService traces) {
- this.acquirers = acquirers;
- this.traces = traces;
- }
-
- Lock(Framework framework) {
- this(framework.accessCycleConfiguration().acquirers(), framework.accessCycleConfiguration().grantsTrace());
- }
-
- /**
- * Appeals to a LicenseAcquisitionService in order to lock an actual grant for a
- * requested feature
- *
- * @param valid, positive, not-restrictive certificate
- * @see ExaminationCertificate
- * @see CertificateIsRestrictive
- * @see LicenseAcquisitionService
- */
- ServiceInvocationResult lock(ExaminationCertificate certificate) {
- if (notPermissive(certificate)) {
- return tentativeGrant(certificate);
- }
- Permission permission = permission(certificate);
- ConditionMiningTarget target = permission.conditionOrigin().miner();
- if (!acquirers.get().hasService(target)) {
- return noService(new BaseGrantLockAttempt.Failed(certificate), target);
- }
- ServiceInvocationResult grant = acquirers.get().service(target)//
- .acquire(permission.product(), permission.condition().feature());
- if (!grant.data().isPresent()) {
- return canIssueTentativeGrant(certificate) //
- ? tentativeGrant(certificate) //
- : noGrant(certificate, grant);
- }
- traces.trace(grant.data().get());
- return grant(certificate, grant.data().get(), grant.diagnostic());
- }
-
- ServiceInvocationResult unlock(GrantLockAttempt lock) {
- if (!lock.successful()) {
- return wrongLockWarning(); // It's illegal state actually. Should we throw something?
- }
- if (new TentativeFeatureAccess().test(lock.grant())) {
- return new BaseServiceInvocationResult<>(Boolean.TRUE);
- }
- Permission permission = permission(lock.certificate());
- ConditionMiningTarget target = permission.conditionOrigin().miner();
- if (!acquirers.get().hasService(target)) {
- return noService(Boolean.FALSE, target);
- }
- ServiceInvocationResult response = acquirers.get().service(target)//
- .release(permission.product(), lock.grant());
- if (new GrantReleased().test(response)) {
- traces.forget(lock.grant());
- }
- return response;
- }
-
- private BaseServiceInvocationResult noGrant(ExaminationCertificate certificate,
- ServiceInvocationResult grant) {
- return new BaseServiceInvocationResult<>(//
- grant.diagnostic(), //
- new BaseGrantLockAttempt.Failed(certificate));
- }
-
- private ServiceInvocationResult grant(ExaminationCertificate certificate, GrantAcquisition grant,
- Diagnostic diagnostic) {
- return new BaseServiceInvocationResult<>(//
- diagnostic, //
- new BaseGrantLockAttempt.Successful(certificate, grant));
- }
-
- private ServiceInvocationResult wrongLockWarning() {
- return new BaseServiceInvocationResult<>(fail("Lock.wrong_release")); //$NON-NLS-1$
- }
-
- private BaseDiagnostic fail(String details) {
- return new BaseDiagnostic(//
- Collections.emptyList(), //
- Collections.singletonList(//
- new Trouble(//
- new ServiceFailedOnMorsel(), //
- AccessCycleMessages.getString(details))));
- }
-
- private ServiceInvocationResult noService(T data, ConditionMiningTarget target) {
- return new BaseServiceInvocationResult(//
- new BaseDiagnostic(new Trouble(//
- new NoServicesOfType(AccessCycleMessages.getString("Lock.service_type")), //$NON-NLS-1$
- String.format(//
- AccessCycleMessages.getString("Lock.no_service_for_target"), //$NON-NLS-1$
- target.toString())//
- )), //
- data);
- }
-
- /**
- * {@code Warning} and {@code Info} {@code requirement}s can stay unsatisfied
- * and still a feature must be accessible for usage
- */
- private boolean notPermissive(ExaminationCertificate certificate) {
- return certificate.satisfied().isEmpty();
- }
-
- /**
- * Certificate must be permissive: must contain at least one properly satisfied
- * requirement // #569004
- */
- private Permission permission(ExaminationCertificate certificate) {
- Requirement any = certificate.satisfied().iterator().next(); // guaranteed to exist
- return certificate.satisfaction(any); // guaranteed to exist and be not null
- }
-
- private ServiceInvocationResult tentativeGrant(ExaminationCertificate certificate) {
- return grant(certificate, new TentativeFeatureAccess(feature(certificate)).get(), tentativeReport(certificate));
- }
-
- private Diagnostic tentativeReport(ExaminationCertificate certificate) {
- return new BaseDiagnostic(//
- Collections.emptyList(), //
- certificate.restrictions().stream()//
- .map(this::explained)//
- .collect(Collectors.toList()));
- }
-
- private Trouble explained(Restriction restriction) {
- return new Trouble(new TentativeAccess(), //
- String.format(//
- AccessCycleMessages.getString("Lock.temp_access"), //$NON-NLS-1$
- feature(restriction.unsatisfiedRequirement())));
- }
-
- /**
- * Certificate is guaranteed to be not empty: either restrictions or
- * satisfactions are present
- */
- private String feature(ExaminationCertificate certificate) {
- return feature(//
- certificate.restrictions().isEmpty() //
- ? certificate.satisfied().iterator().next()//
- : certificate.restrictions().iterator().next().unsatisfiedRequirement()//
- );
- }
-
- private String feature(Requirement requirement) {
- return requirement.feature().identifier();
- }
-
- private boolean canIssueTentativeGrant(ExaminationCertificate certificate) {
- return certificate.satisfied().stream().noneMatch(new RequirementDemandsExecutionStop());
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2020, 2022 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.internal.base.access;
+
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+import org.eclipse.passage.lic.api.Framework;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.access.GrantLockAttempt;
+import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
+import org.eclipse.passage.lic.api.acquire.GrantsTraceService;
+import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionService;
+import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionServicesRegistry;
+import org.eclipse.passage.lic.api.conditions.ConditionMiningTarget;
+import org.eclipse.passage.lic.api.conditions.evaluation.Permission;
+import org.eclipse.passage.lic.api.diagnostic.Diagnostic;
+import org.eclipse.passage.lic.api.diagnostic.Trouble;
+import org.eclipse.passage.lic.api.requirements.Requirement;
+import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
+import org.eclipse.passage.lic.api.restrictions.Restriction;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.diagnostic.BaseDiagnostic;
+import org.eclipse.passage.lic.base.diagnostic.code.NoServicesOfType;
+import org.eclipse.passage.lic.base.diagnostic.code.ServiceFailedOnMorsel;
+import org.eclipse.passage.lic.base.diagnostic.code.TentativeAccess;
+import org.eclipse.passage.lic.base.restrictions.CertificateIsRestrictive;
+import org.eclipse.passage.lic.base.restrictions.RequirementDemandsExecutionStop;
+import org.eclipse.passage.lic.internal.base.access.storage.GrantReleased;
+import org.eclipse.passage.lic.internal.base.i18n.AccessCycleMessages;
+
+final class Lock {
+
+ private final LicenseAcquisitionServicesRegistry acquirers;
+ private final GrantsTraceService traces;
+
+ Lock(LicenseAcquisitionServicesRegistry acquirers, GrantsTraceService traces) {
+ this.acquirers = acquirers;
+ this.traces = traces;
+ }
+
+ Lock(Framework framework) {
+ this(framework.accessCycleConfiguration().acquirers(), framework.accessCycleConfiguration().grantsTrace());
+ }
+
+ /**
+ * Appeals to a LicenseAcquisitionService in order to lock an actual grant for a
+ * requested feature
+ *
+ * @param valid, positive, not-restrictive certificate
+ * @see ExaminationCertificate
+ * @see CertificateIsRestrictive
+ * @see LicenseAcquisitionService
+ */
+ ServiceInvocationResult lock(ExaminationCertificate certificate) {
+ if (notPermissive(certificate)) {
+ return tentativeGrant(certificate);
+ }
+ Permission permission = permission(certificate);
+ ConditionMiningTarget target = permission.conditionOrigin().miner();
+ if (!acquirers.get().hasService(target)) {
+ return noService(new BaseGrantLockAttempt.Failed(certificate), target);
+ }
+ ServiceInvocationResult grant = acquirers.get().service(target)//
+ .acquire(permission.product(), permission.condition().feature());
+ if (!grant.data().isPresent()) {
+ return canIssueTentativeGrant(certificate) //
+ ? tentativeGrant(certificate) //
+ : noGrant(certificate, grant);
+ }
+ traces.trace(grant.data().get());
+ return grant(certificate, grant.data().get(), grant.diagnostic());
+ }
+
+ ServiceInvocationResult unlock(GrantLockAttempt lock) {
+ if (!lock.successful()) {
+ return wrongLockWarning(); // It's illegal state actually. Should we throw something?
+ }
+ if (new TentativeFeatureAccess().test(lock.grant())) {
+ return new BaseServiceInvocationResult<>(Boolean.TRUE);
+ }
+ Permission permission = permission(lock.certificate());
+ ConditionMiningTarget target = permission.conditionOrigin().miner();
+ if (!acquirers.get().hasService(target)) {
+ return noService(Boolean.FALSE, target);
+ }
+ ServiceInvocationResult response = acquirers.get().service(target)//
+ .release(permission.product(), lock.grant());
+ if (new GrantReleased().test(response)) {
+ traces.forget(lock.grant());
+ }
+ return response;
+ }
+
+ private BaseServiceInvocationResult noGrant(ExaminationCertificate certificate,
+ ServiceInvocationResult grant) {
+ return new BaseServiceInvocationResult<>(//
+ grant.diagnostic(), //
+ new BaseGrantLockAttempt.Failed(certificate));
+ }
+
+ private ServiceInvocationResult grant(ExaminationCertificate certificate, GrantAcquisition grant,
+ Diagnostic diagnostic) {
+ return new BaseServiceInvocationResult<>(//
+ diagnostic, //
+ new BaseGrantLockAttempt.Successful(certificate, grant));
+ }
+
+ private ServiceInvocationResult wrongLockWarning() {
+ return new BaseServiceInvocationResult<>(fail("Lock.wrong_release")); //$NON-NLS-1$
+ }
+
+ private BaseDiagnostic fail(String details) {
+ return new BaseDiagnostic(//
+ Collections.emptyList(), //
+ Collections.singletonList(//
+ new Trouble(//
+ new ServiceFailedOnMorsel(), //
+ AccessCycleMessages.getString(details))));
+ }
+
+ private ServiceInvocationResult noService(T data, ConditionMiningTarget target) {
+ return new BaseServiceInvocationResult(//
+ new BaseDiagnostic(new Trouble(//
+ new NoServicesOfType(AccessCycleMessages.getString("Lock.service_type")), //$NON-NLS-1$
+ String.format(//
+ AccessCycleMessages.getString("Lock.no_service_for_target"), //$NON-NLS-1$
+ target.toString())//
+ )), //
+ data);
+ }
+
+ /**
+ * {@code Warning} and {@code Info} {@code requirement}s can stay unsatisfied
+ * and still a feature must be accessible for usage
+ */
+ private boolean notPermissive(ExaminationCertificate certificate) {
+ return certificate.satisfied().isEmpty();
+ }
+
+ /**
+ * Certificate must be permissive: must contain at least one properly satisfied
+ * requirement // #569004
+ */
+ private Permission permission(ExaminationCertificate certificate) {
+ Requirement any = certificate.satisfied().iterator().next(); // guaranteed to exist
+ return certificate.satisfaction(any); // guaranteed to exist and be not null
+ }
+
+ private ServiceInvocationResult tentativeGrant(ExaminationCertificate certificate) {
+ return grant(certificate, new TentativeFeatureAccess(feature(certificate)).get(), tentativeReport(certificate));
+ }
+
+ private Diagnostic tentativeReport(ExaminationCertificate certificate) {
+ return new BaseDiagnostic(//
+ Collections.emptyList(), //
+ certificate.restrictions().stream()//
+ .map(this::explained)//
+ .collect(Collectors.toList()));
+ }
+
+ private Trouble explained(Restriction restriction) {
+ return new Trouble(new TentativeAccess(), //
+ String.format(//
+ AccessCycleMessages.getString("Lock.temp_access"), //$NON-NLS-1$
+ feature(restriction.unsatisfiedRequirement())));
+ }
+
+ /**
+ * Certificate is guaranteed to be not empty: either restrictions or
+ * satisfactions are present
+ */
+ private String feature(ExaminationCertificate certificate) {
+ return feature(//
+ certificate.restrictions().isEmpty() //
+ ? certificate.satisfied().iterator().next()//
+ : certificate.restrictions().iterator().next().unsatisfiedRequirement()//
+ );
+ }
+
+ private String feature(Requirement requirement) {
+ return requirement.feature().identifier();
+ }
+
+ private boolean canIssueTentativeGrant(ExaminationCertificate certificate) {
+ return certificate.satisfied().stream().noneMatch(new RequirementDemandsExecutionStop());
+ }
+
+}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Permissions.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Permissions.java
index d6742a654..51e30d408 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Permissions.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/access/Permissions.java
@@ -1,131 +1,131 @@
-/*******************************************************************************
- * 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.internal.base.access;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Optional;
-import java.util.function.BiFunction;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
-import org.eclipse.passage.lic.api.LicensedProduct;
-import org.eclipse.passage.lic.api.ServiceInvocationResult;
-import org.eclipse.passage.lic.api.agreements.GlobalAgreement;
-import org.eclipse.passage.lic.api.conditions.ConditionPack;
-import org.eclipse.passage.lic.api.conditions.evaluation.Emission;
-import org.eclipse.passage.lic.api.conditions.evaluation.Permission;
-import org.eclipse.passage.lic.api.conditions.evaluation.PermissionEmittingService;
-import org.eclipse.passage.lic.api.registry.Registry;
-import org.eclipse.passage.lic.api.registry.StringServiceId;
-import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
-import org.eclipse.passage.lic.base.SumOfCollections;
-import org.eclipse.passage.lic.internal.base.access.Permissions.AppliedLicenses;
-
-/**
- * FIXME: Has public visibility only for testing.
- *
- * @since 2.1
- */
-public final class Permissions implements Supplier> {
-
- private final Registry registry;
- private final Collection conditions;
- private final LicensedProduct product;
-
- public Permissions(Registry registry,
- Collection conditions, LicensedProduct product) {
- this.registry = registry;
- this.conditions = conditions;
- this.product = product;
- }
-
- @Override
- public ServiceInvocationResult get() {
- BaseServiceInvocationResult> permissions = permissions();
- return new BaseServiceInvocationResult<>(//
- permissions.diagnostic(), //
- new AppliedLicenses(//
- permissions.data().get(), //
- agreements())//
- );
- }
-
- private BaseServiceInvocationResult> permissions() {
- return registry.services().stream() //
- .map(service -> service.emit(conditions, product))//
- .reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCollections()))//
- .map(r -> new BaseServiceInvocationResult>(//
- r.diagnostic(), //
- allPermissions(r.data())))//
- .orElse(new BaseServiceInvocationResult<>(Collections.emptyList()));
- }
-
- private Collection allPermissions(Optional> emissions) {
- if (!emissions.isPresent()) {
- return Collections.emptyList();
- }
- return emissions.get().stream() //
- .reduce(//
- new ArrayList(), //
- new SumEmissionsToData(), //
- new SumOfCollections());
- }
-
- private Collection agreements() {
- return conditions.stream()//
- .map(ConditionPack::agreements)//
- .flatMap(Collection::stream)//
- .collect(Collectors.toList());
- }
-
- /**
- * Here we do not need `ConditionPack` granularity, thus unfold each one to
- * amass all the permissions we have.
- */
- private final static class SumEmissionsToData
- implements BiFunction, Emission, Collection> {
-
- @Override
- public Collection apply(Collection sum, Emission emission) {
- sum.addAll(emission.permissions());
- return sum;
- }
-
- }
-
- public static final class AppliedLicenses {
-
- private final Collection permissions;
- private final Collection agreements;
-
- AppliedLicenses() {
- this(Collections.emptyList(), Collections.emptyList());
- }
-
- AppliedLicenses(Collection permissions, Collection agreements) {
- this.permissions = permissions;
- this.agreements = agreements;
- }
-
- Collection permissions() {
- return permissions;
- }
-
- Collection agreements() {
- return agreements;
- }
- }
-
-}
+/*******************************************************************************
+ * 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.internal.base.access;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.function.BiFunction;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+import org.eclipse.passage.lic.api.LicensedProduct;
+import org.eclipse.passage.lic.api.ServiceInvocationResult;
+import org.eclipse.passage.lic.api.agreements.GlobalAgreement;
+import org.eclipse.passage.lic.api.conditions.ConditionPack;
+import org.eclipse.passage.lic.api.conditions.evaluation.Emission;
+import org.eclipse.passage.lic.api.conditions.evaluation.Permission;
+import org.eclipse.passage.lic.api.conditions.evaluation.PermissionEmittingService;
+import org.eclipse.passage.lic.api.registry.Registry;
+import org.eclipse.passage.lic.api.registry.StringServiceId;
+import org.eclipse.passage.lic.base.BaseServiceInvocationResult;
+import org.eclipse.passage.lic.base.SumOfCollections;
+import org.eclipse.passage.lic.internal.base.access.Permissions.AppliedLicenses;
+
+/**
+ * FIXME: Has public visibility only for testing.
+ *
+ * @since 2.1
+ */
+public final class Permissions implements Supplier> {
+
+ private final Registry registry;
+ private final Collection conditions;
+ private final LicensedProduct product;
+
+ public Permissions(Registry registry,
+ Collection conditions, LicensedProduct product) {
+ this.registry = registry;
+ this.conditions = conditions;
+ this.product = product;
+ }
+
+ @Override
+ public ServiceInvocationResult get() {
+ BaseServiceInvocationResult> permissions = permissions();
+ return new BaseServiceInvocationResult<>(//
+ permissions.diagnostic(), //
+ new AppliedLicenses(//
+ permissions.data().get(), //
+ agreements())//
+ );
+ }
+
+ private BaseServiceInvocationResult> permissions() {
+ return registry.services().stream() //
+ .map(service -> service.emit(conditions, product))//
+ .reduce(new BaseServiceInvocationResult.Sum<>(new SumOfCollections()))//
+ .map(r -> new BaseServiceInvocationResult>(//
+ r.diagnostic(), //
+ allPermissions(r.data())))//
+ .orElse(new BaseServiceInvocationResult<>(Collections.emptyList()));
+ }
+
+ private Collection allPermissions(Optional> emissions) {
+ if (!emissions.isPresent()) {
+ return Collections.emptyList();
+ }
+ return emissions.get().stream() //
+ .reduce(//
+ new ArrayList(), //
+ new SumEmissionsToData(), //
+ new SumOfCollections());
+ }
+
+ private Collection agreements() {
+ return conditions.stream()//
+ .map(ConditionPack::agreements)//
+ .flatMap(Collection::stream)//
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Here we do not need `ConditionPack` granularity, thus unfold each one to
+ * amass all the permissions we have.
+ */
+ private final static class SumEmissionsToData
+ implements BiFunction, Emission, Collection> {
+
+ @Override
+ public Collection