Skip to content

Commit

Permalink
Merge pull request #893 from eclipse-passage/575183
Browse files Browse the repository at this point in the history
575183 license status check with all options must have headless version
  • Loading branch information
eparovyshnaya authored Sep 3, 2021
2 parents 43142b1 + cd189f7 commit 5885bc3
Show file tree
Hide file tree
Showing 28 changed files with 792 additions and 39 deletions.
6 changes: 5 additions & 1 deletion bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.passage.lic.api,
org.eclipse.passage.lic.api.access,
org.eclipse.passage.lic.api.acquire,
org.eclipse.passage.lic.api.agreements;x-friends:="org.eclipse.passage.lic.base,org.eclipse.passage.lic.base.tests,org.eclipse.passage.lic.jface",
org.eclipse.passage.lic.api.agreements;
x-friends:="org.eclipse.passage.lic.base,
org.eclipse.passage.lic.base.tests,
org.eclipse.passage.lic.jface,
org.eclipse.passage.lic.equinox",
org.eclipse.passage.lic.api.conditions,
org.eclipse.passage.lic.api.conditions.evaluation,
org.eclipse.passage.lic.api.conditions.mining,
Expand Down
1 change: 1 addition & 0 deletions bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Export-Package: org.eclipse.passage.lic.base,
org.eclipse.passage.lic.base.restrictions,
org.eclipse.passage.lic.base.version,
org.eclipse.passage.lic.internal.base;x-friends:="org.eclipse.passage.lic.equinox.tests",
org.eclipse.passage.lic.internal.base.conditions;x-internal:=true,
org.eclipse.passage.lic.internal.base.i18n;x-internal:=true,
org.eclipse.passage.lic.internal.base.inspection.hardware;x-friends:="org.eclipse.passage.loc.licenses.core,org.eclipse.passage.lic.oshi",
org.eclipse.passage.lic.internal.base.logging;x-friends:="org.eclipse.passage.lic.jetty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public final class GlobalAgreementSupportFeature implements Supplier<Feature> {
public Feature get() {
return new BaseFeature(//
"passage.global-agreement-support.feature", //$NON-NLS-1$
"0.0.0", //$NON-NLS-1$
"Global Agreements Support", //$NON-NLS-1$
"1.0.0", //$NON-NLS-1$
"Global Agreements Support by Passage", //$NON-NLS-1$
"Eclipse Passage Runtime" //$NON-NLS-1$
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;

/**
*
* @since 2.1
*/
public final class LicensingStatus implements Supplier<List<RequirementStatus>> {
public final class RequirementsCoverage implements Supplier<List<RequirementStatus>> {

private final ExaminationCertificate certificate;

public LicensingStatus(ExaminationCertificate certificate) {
public RequirementsCoverage(ExaminationCertificate certificate) {
this.certificate = certificate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.internal.jetty.interaction;
package org.eclipse.passage.lic.base.diagnostic;

import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate;
import org.eclipse.passage.lic.base.diagnostic.LicensingStatus;
import org.eclipse.passage.lic.base.diagnostic.RequirementStatus;

final class RequirementsLicensingStatusExplained {
/**
* @since 2.1
*/
public final class RequirementsCoverageExplained {

private final ExaminationCertificate certificate;

public RequirementsLicensingStatusExplained(ExaminationCertificate certificate) {
public RequirementsCoverageExplained(ExaminationCertificate certificate) {
this.certificate = certificate;
}

public String get() {
StringBuilder out = new StringBuilder();
new LicensingStatus(certificate).get().forEach(status -> append(status, out));
new RequirementsCoverage(certificate).get().forEach(status -> append(status, out));
return out.toString();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 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.conditions;

import java.nio.file.Path;
import java.util.Collection;
import java.util.function.Supplier;

import org.eclipse.passage.lic.api.ServiceInvocationResult;
import org.eclipse.passage.lic.api.conditions.ConditionPack;
import org.eclipse.passage.lic.api.conditions.mining.LicenseReadingService;
import org.eclipse.passage.lic.base.BaseServiceInvocationResult;

public final class LicenseConditions implements Supplier<ServiceInvocationResult<Collection<ConditionPack>>> {

private final Path file;
private final Supplier<ServiceInvocationResult<LicenseReadingService>> provider;

public LicenseConditions(Path file, Supplier<ServiceInvocationResult<LicenseReadingService>> provider) {
this.file = file;
this.provider = provider;
}

@Override
public ServiceInvocationResult<Collection<ConditionPack>> get() {
ServiceInvocationResult<LicenseReadingService> reader = provider.get();
if (!reader.data().isPresent()) {
return new BaseServiceInvocationResult<>(reader.diagnostic());
}
return reader.data().get().read(file);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.osgi;bundle-version="0.0.0";visibility:=reexport,
org.eclipse.passage.lic.base;bundle-version="1.0.0";visibility:=reexport,
org.apache.logging.log4j;bundle-version="2.8.2"
Export-Package: org.eclipse.passage.lic.equinox,
org.eclipse.passage.lic.equinox.access;x-friends:="org.eclipse.passage.lic.jetty",
org.eclipse.passage.lic.equinox.acquire,
org.eclipse.passage.lic.equinox.conditions,
org.eclipse.passage.lic.equinox.io,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 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.equinox.access;

abstract class BaseOption<D extends Enum<?>> implements Option<D> {

private final char key;
private final String name;
private final String description;
protected final Interaction.Smart interaction;

BaseOption(char key, String name, String description, Interaction.Smart interaction) {
this.key = key;
this.name = name;
this.description = description;
this.interaction = interaction;
}

@Override
public String documentation() {
return String.format("%s (%s): %s", key, name, description); //$NON-NLS-1$
}

@Override
public char key() {
return key;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 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.equinox.access;

import java.io.IOException;

public final class ConsoleInteraction implements Interaction {

@Override
public void prompt(String information) {
System.out.printf("%s\n", information); //$NON-NLS-1$
}

@Override
public String input() {
byte[] bytes = new byte[1024];
int length = 0;
try {
for (int symbol = System.in.read(); symbol != 13; symbol = System.in.read()) {
bytes[length++] = (byte) symbol;
}
} catch (IOException e) {
swear(e);
return e.getClass().getName();
}
return new String(bytes, 0, length);
}

@Override
public void swear(Throwable thro) {
thro.printStackTrace(System.err);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 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.equinox.access;

enum CoverageCheckOptionDecision {

proceed, quit, reassess;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 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.equinox.access;

import java.util.Optional;

public interface Interaction {

void prompt(String information);

void swear(Throwable thro);

String input();

public static final class Smart implements Interaction {
private final Interaction delegate;

public Smart(Interaction delegate) {
this.delegate = delegate;
}

void head(String title) {
head(title, Optional.empty());
}

void head(String title, String message) {
head(title, Optional.of(message));
}

private void head(String title, Optional<String> message) {
delegate.prompt("------------------------------------"); //$NON-NLS-1$
delegate.prompt(String.format("--- %s", title)); //$NON-NLS-1$
message.ifPresent(delegate::prompt);
delegate.prompt("------------------------------------"); //$NON-NLS-1$
}

@Override
public void prompt(String information) {
delegate.prompt(information);
}

@Override
public void swear(Throwable thro) {
delegate.swear(thro);
}

@Override
public String input() {
return delegate.input();
}
}

}
Loading

0 comments on commit 5885bc3

Please sign in to comment.