-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #650 from eclipse-passage/571179
Bug 571147 extend 'lic.net' with common facilities
- Loading branch information
Showing
14 changed files
with
142 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/NoGrantsAvailable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************* | ||
* 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.lbc.internal.base.acquire; | ||
|
||
import org.eclipse.passage.lic.internal.api.LicensedProduct; | ||
import org.eclipse.passage.lic.internal.net.handle.Failure; | ||
|
||
/** | ||
* Public only for test purposes | ||
*/ | ||
public final class NoGrantsAvailable extends Failure { | ||
|
||
public NoGrantsAvailable(LicensedProduct product, String feature) { | ||
super(611, String.format("No license grants available for feature %s of product %s", feature, product)); //$NON-NLS-1$ | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...lipse.passage.lbc.base/src/org/eclipse/passage/lbc/internal/base/acquire/NotReleased.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/******************************************************************************* | ||
* 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.lbc.internal.base.acquire; | ||
|
||
import org.eclipse.passage.lic.floating.model.api.GrantAcqisition; | ||
import org.eclipse.passage.lic.internal.api.LicensedProduct; | ||
import org.eclipse.passage.lic.internal.net.handle.Failure; | ||
|
||
/** | ||
* Public only for test purposes | ||
*/ | ||
public final class NotReleased extends Failure { | ||
|
||
public NotReleased(LicensedProduct product, GrantAcqisition acqisition) { | ||
super(612, String.format("Failed to release grant %s acquisition for feature %s of product %s", //$NON-NLS-1$ | ||
acqisition.getGrant(), acqisition.getFeature(), product)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
....eclipse.passage.lic.net/src/org/eclipse/passage/lic/internal/net/handle/NetServices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/******************************************************************************* | ||
* 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.net.handle; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.passage.lic.internal.api.PassageAction; | ||
import org.eclipse.passage.lic.internal.net.LicensingAction; | ||
|
||
public abstract class NetServices<R extends NetRequest> implements Chores<R> { | ||
|
||
private final Map<PassageAction, Function<R, Chore>> chores = new HashMap<>(); | ||
|
||
protected NetServices() { | ||
defineChores(chores); | ||
} | ||
|
||
protected abstract void defineChores(Map<PassageAction, Function<R, Chore>> services); | ||
|
||
@Override | ||
public NetResponse workOut(R request) { | ||
LicensingAction action = action(request); | ||
return chores// | ||
.getOrDefault(// | ||
action.get().get(), // | ||
unknown -> new Failing(action))// | ||
.apply(request)// | ||
.getDone(); | ||
} | ||
|
||
private LicensingAction action(R request) { | ||
return new LicensingAction(key -> new PassageAction.Of(String.valueOf(request.parameter(key)))); | ||
} | ||
|
||
private final class Failing implements Chore { | ||
|
||
private final LicensingAction actual; | ||
|
||
Failing(LicensingAction actual) { | ||
this.actual = actual; | ||
} | ||
|
||
@Override | ||
public NetResponse getDone() { | ||
return new Failure.BadRequestUnknownAction(actual.get().get().name()); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters