-
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.
Bug 568632 Implement feature grant acquire/release
Implement license release request Signed-off-by: eparovyshnaya <[email protected]>
- Loading branch information
1 parent
148b4e5
commit 47b0024
Showing
10 changed files
with
223 additions
and
111 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
113 changes: 113 additions & 0 deletions
113
...passage.lic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/BaseConfiguration.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,113 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 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.hc.remote.impl; | ||
|
||
import java.io.OutputStream; | ||
import java.net.HttpURLConnection; | ||
import java.net.ProtocolException; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.passage.lic.internal.hc.remote.Configuration; | ||
|
||
public abstract class BaseConfiguration implements Configuration<HttpURLConnection> { | ||
|
||
private final int timeout; | ||
private final Map<String, String> properties; | ||
|
||
protected BaseConfiguration(int timeout, Map<String, String> properties) { | ||
Objects.requireNonNull(properties, "BaseConfiguration::properties"); //$NON-NLS-1$ | ||
this.timeout = timeout; | ||
this.properties = properties; | ||
} | ||
|
||
protected BaseConfiguration(Map<String, String> properties) { | ||
this(1000, properties); | ||
} | ||
|
||
protected BaseConfiguration() { | ||
this(Collections.emptyMap()); | ||
} | ||
|
||
@Override | ||
public final HttpURLConnection apply(HttpURLConnection connection) throws Exception { | ||
installRequestDemands(connection); | ||
installRequestProperties(connection); | ||
paveRoadForData(connection); | ||
return connection; | ||
} | ||
|
||
private void installRequestDemands(HttpURLConnection connection) throws Exception { | ||
connection.setConnectTimeout(timeout); | ||
} | ||
|
||
protected abstract void paveRoadForData(HttpURLConnection connection) throws Exception; | ||
|
||
private void installRequestProperties(HttpURLConnection connection) { | ||
properties.forEach((k, v) -> connection.addRequestProperty(k, v)); | ||
} | ||
|
||
public static final class Get extends BaseConfiguration { | ||
|
||
public Get(int timeout, Map<String, String> properties) { | ||
super(timeout, properties); | ||
} | ||
|
||
public Get(Map<String, String> properties) { | ||
super(properties); | ||
} | ||
|
||
public Get() { | ||
super(); | ||
} | ||
|
||
@Override | ||
protected void paveRoadForData(HttpURLConnection connection) throws ProtocolException { | ||
connection.setRequestMethod("GET"); //$NON-NLS-1$ | ||
connection.setDoOutput(true); | ||
} | ||
|
||
} | ||
|
||
public static final class Post extends BaseConfiguration { | ||
|
||
private final byte[] payload; | ||
|
||
public Post(int timeout, Map<String, String> properties, byte[] payload) { | ||
super(timeout, properties); | ||
this.payload = payload; | ||
} | ||
|
||
public Post(Map<String, String> properties, byte[] payload) { | ||
super(properties); | ||
this.payload = payload; | ||
} | ||
|
||
public Post(byte[] payload) { | ||
this.payload = payload; | ||
} | ||
|
||
@Override | ||
protected void paveRoadForData(HttpURLConnection connection) throws Exception { | ||
connection.setRequestMethod("PUT"); //$NON-NLS-1$ | ||
connection.setDoOutput(false); | ||
connection.setDoInput(true); | ||
try (OutputStream output = connection.getOutputStream()) { | ||
output.write(payload); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
50 changes: 0 additions & 50 deletions
50
...c/src/org/eclipse/passage/lic/internal/hc/remote/impl/HttpUrlConnectionConfiguration.java
This file was deleted.
Oops, something went wrong.
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
40 changes: 0 additions & 40 deletions
40
....lic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/acquire/OfFeatureRequest.java
This file was deleted.
Oops, something went wrong.
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
31 changes: 31 additions & 0 deletions
31
...ic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/acquire/ReleaseServiceData.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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 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.hc.remote.impl.acquire; | ||
|
||
import org.eclipse.passage.lic.internal.api.LicensedProduct; | ||
import org.eclipse.passage.lic.internal.api.acquire.GrantAcqisition; | ||
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteServiceData; | ||
|
||
final class ReleaseServiceData extends RemoteServiceData { | ||
private GrantAcqisition acqisition; | ||
|
||
ReleaseServiceData(LicensedProduct product, GrantAcqisition acqisition) { | ||
super(product); | ||
this.acqisition = acqisition; | ||
} | ||
|
||
GrantAcqisition acqisition() { | ||
return acqisition; | ||
} | ||
|
||
} |
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
Oops, something went wrong.