Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1453] Evolve raw string identifier to semantic entity #1460

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* 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.api;

import org.eclipse.passage.lic.api.acquire.GrantAcquisition;

/**
* Identifies a grant acquired to use a feature under license protection
*
* @see GrantAcquisition#grant()
*
* @since 4.0
*/
public interface GrantIdentifier {

String identifier();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Date;

import org.eclipse.passage.lic.api.FeatureIdentifier;
import org.eclipse.passage.lic.api.GrantIdentifier;

/**
*
Expand All @@ -25,7 +26,10 @@ public interface GrantAcquisition {

String identifier();

String grant();
/**
* @since 4.0
*/
GrantIdentifier grant();

/**
* @since 4.0
Expand Down
Original file line number Diff line number Diff line change
@@ -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.GrantIdentifier;

/**
* Base implementation for {@link GrantIdentifier}
*
* @since 4.0
*/
public record BaseGrantIdentifier(String identifier) implements GrantIdentifier {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Objects;

import org.eclipse.passage.lic.api.FeatureIdentifier;
import org.eclipse.passage.lic.api.GrantIdentifier;
import org.eclipse.passage.lic.api.acquire.GrantAcquisition;

/**
Expand All @@ -28,15 +29,16 @@ public final class BaseGrantAcquisition implements GrantAcquisition, Serializabl

private static final long serialVersionUID = 2755031536488685673L;
private final String id;
private final String grant;
private final GrantIdentifier grant;
private final FeatureIdentifier feature;
private final String user;
private final Date created;

/**
* @since 4.0
*/
public BaseGrantAcquisition(String id, String grant, FeatureIdentifier feature, String user, Date created) {
public BaseGrantAcquisition(String id, GrantIdentifier grant, FeatureIdentifier feature, String user,
Date created) {
this.id = Objects.requireNonNull(id);
this.grant = Objects.requireNonNull(grant);
this.feature = Objects.requireNonNull(feature);
Expand All @@ -50,7 +52,7 @@ public String identifier() {
}

@Override
public String grant() {
public GrantIdentifier grant() {
return grant;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.passage.lic.api.ServiceInvocationResult;
import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
import org.eclipse.passage.lic.api.acquire.LicenseAcquisitionService;
import org.eclipse.passage.lic.base.BaseGrantIdentifier;
import org.eclipse.passage.lic.base.BaseServiceInvocationResult;

// FIXME: just stub for now. Implement properly. #568791
Expand All @@ -34,7 +35,7 @@ public final ServiceInvocationResult<GrantAcquisition> acquire(LicensedProduct p
return new BaseServiceInvocationResult<>(//
new BaseGrantAcquisition(//
"local", //$NON-NLS-1$
"temp", //$NON-NLS-1$
new BaseGrantIdentifier("temp"), //$NON-NLS-1$
feature, //
"user", //$NON-NLS-1$
new Date())//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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.BaseGrantIdentifier;
import org.eclipse.passage.lic.base.acquire.BaseGrantAcquisition;

final class TentativeFeatureAccess implements Supplier<GrantAcquisition>, Predicate<GrantAcquisition> {
Expand All @@ -40,7 +41,7 @@ final class TentativeFeatureAccess implements Supplier<GrantAcquisition>, Predic
public GrantAcquisition get() {
return new BaseGrantAcquisition(//
String.format("%s-id", tentative), //$NON-NLS-1$
String.format("%s-grant", tentative), //$NON-NLS-1$
new BaseGrantIdentifier(String.format("%s-grant", tentative)), //$NON-NLS-1$
feature, //
String.format("%s-user", tentative), //$NON-NLS-1$
new Date());
Expand All @@ -49,7 +50,7 @@ public GrantAcquisition get() {
@Override
public boolean test(GrantAcquisition grant) {
return grant.identifier().startsWith(tentative) //
&& grant.grant().startsWith(tentative) //
&& grant.grant().identifier().startsWith(tentative) //
&& grant.user().startsWith(tentative);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public EGrantAcquisition(org.eclipse.passage.lic.api.acquire.GrantAcquisition so
public GrantAcqisition get() {
GrantAcqisition grant = LicensesFactory.eINSTANCE.createGrantAcqisition();
grant.setIdentifier(source.identifier());
grant.setGrant(source.grant());
grant.setGrant(source.grant().identifier());
grant.setFeature(source.feature().identifier());
grant.setUser(source.user());
grant.setCreated(source.created());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.function.Supplier;

import org.eclipse.passage.lic.base.BaseFeatureIdentifier;
import org.eclipse.passage.lic.base.BaseGrantIdentifier;
import org.eclipse.passage.lic.base.acquire.BaseGrantAcquisition;
import org.eclipse.passage.lic.licenses.model.api.GrantAcqisition;

Expand All @@ -32,7 +33,7 @@ public PGrantAcquisition(GrantAcqisition source) {
public org.eclipse.passage.lic.api.acquire.GrantAcquisition get() {
return new BaseGrantAcquisition(//
source.getIdentifier(), //
source.getGrant(), //
new BaseGrantIdentifier(source.getGrant()), //
new BaseFeatureIdentifier(source.getFeature()), //
source.getUser(), //
source.getCreated());
Expand Down
Loading