-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rest.packages.provider): add endpoint for Package Descriptor ret…
…rieval [backport release-5.4.0] (#4968) feat(rest.packages.provider): add endpoint for Package Descriptor retrieval (#4934) * feat: add MarketplacePackageDescriptor.java * feat: add barebone getMarketplacePackageDescriptor method implementation WIP * feat: add getMarketplacePackageDescriptor to DeploymentAgentService interface * feat: add isEclipseMarketplaceUrl check WIP * style: fix variable name * feat: add quick&dirty descriptor check endpoint STILL WIP: we should at least have a dedicated request type instead of recycling InstallRequest * feat: return json object * debug: add debugging log * feat: actually perform check on input url * feat: add proper Kura version retrival * refactor: move instantiation * refactor: use proper exceptions * style: add copyright header * feat: use QueryParam for passing the URL to be checked * feat: provide equals and hashCode overrides * fix: do not log user-controlled data * fix: replace character class by the character itself * test: add unit tests for MarketplacePackageDescriptor * style: add copyright header * style: refactor into gerkhin style * refactor: move given/when/then methods in their sections * refactor: use the builder for gods sake * style: add forgotten about files * test: add DeploymentRestServiceUnitTest for marketplace descriptor * refactor: move URL checks outside DeploymentAgentService to allow for testing * test: update unit tests * refactor: move method into its section * test: add integration tests * fix: remove commented out code * test: add some more tests * test: add test case for failing getMarketplacePackageDescriptor call * docs: add Javadocs for DeploymentRestService * docs: add javadocs for DeploymentAgentService * test: add DeploymentAgentTest:getMarketplacePackageDescriptor tests (#11) * ci(debug): set envvar to run testcontainers with podman * refactor: user raw Mockserver instead of going through Testcontainers * refactor: remove unnecessary dependencies * ci: roll-back changes * test: use random free port * test: add null URL test * test: reset MockServer status after each test * feat: GET -> PUT * test: GET -> PUT * refactor(web2): modify UI so that it uses the newly introduced method * build: downgrade mockserver 5.15.0 -> 5.14.0 * build: I'm a dum dum * docs: add "since" annotation for newly introduced method * style: update copyright headers * chore: deployment agent service version bump to 1.1.0 * feat: add method for overriding SslManagerService used to establish connection * style: restore formatting * style: update copyright headers * style: update copyright header * build: switched to mockserver v 5.15.0 * docs: remove newly added test deps from NOTICE file
- Loading branch information
Showing
19 changed files
with
1,508 additions
and
206 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
142 changes: 142 additions & 0 deletions
142
...t.agent/src/main/java/org/eclipse/kura/deployment/agent/MarketplacePackageDescriptor.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,142 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Eurotech and/or its affiliates and others | ||
* | ||
* 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: | ||
* Eurotech | ||
*******************************************************************************/ | ||
package org.eclipse.kura.deployment.agent; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
public class MarketplacePackageDescriptor implements Serializable { | ||
|
||
private String nodeId; | ||
private String url; | ||
private String dpUrl; | ||
private String minKuraVersion; | ||
private String maxKuraVersion; | ||
private String currentKuraVersion; | ||
private boolean isCompatible; | ||
|
||
private MarketplacePackageDescriptor(MarketplacePackageDescriptorBuilder builder) { | ||
this.nodeId = builder.nodeId; | ||
this.url = builder.url; | ||
this.dpUrl = builder.dpUrl; | ||
this.minKuraVersion = builder.minKuraVersion; | ||
this.maxKuraVersion = builder.maxKuraVersion; | ||
this.currentKuraVersion = builder.currentKuraVersion; | ||
this.isCompatible = builder.isCompatible; | ||
} | ||
|
||
public String getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getDpUrl() { | ||
return dpUrl; | ||
} | ||
|
||
public String getMinKuraVersion() { | ||
return minKuraVersion; | ||
} | ||
|
||
public String getMaxKuraVersion() { | ||
return maxKuraVersion; | ||
} | ||
|
||
public String getCurrentKuraVersion() { | ||
return currentKuraVersion; | ||
} | ||
|
||
public boolean isCompatible() { | ||
return isCompatible; | ||
} | ||
|
||
public static MarketplacePackageDescriptorBuilder builder() { | ||
return new MarketplacePackageDescriptorBuilder(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (!(obj instanceof MarketplacePackageDescriptor)) { | ||
return false; | ||
} | ||
MarketplacePackageDescriptor other = (MarketplacePackageDescriptor) obj; | ||
return Objects.equals(this.nodeId, other.nodeId) && Objects.equals(this.url, other.url) | ||
&& Objects.equals(this.dpUrl, other.dpUrl) && Objects.equals(this.minKuraVersion, other.minKuraVersion) | ||
&& Objects.equals(this.maxKuraVersion, other.maxKuraVersion) | ||
&& Objects.equals(this.currentKuraVersion, other.currentKuraVersion) | ||
&& Objects.equals(this.isCompatible, other.isCompatible); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.nodeId, this.url, this.dpUrl, this.minKuraVersion, this.maxKuraVersion, | ||
this.currentKuraVersion, this.isCompatible); | ||
} | ||
|
||
// Builder | ||
public static class MarketplacePackageDescriptorBuilder { | ||
|
||
private String nodeId = ""; | ||
private String url = ""; | ||
private String dpUrl = ""; | ||
private String minKuraVersion = ""; | ||
private String maxKuraVersion = ""; | ||
private String currentKuraVersion = ""; | ||
private boolean isCompatible = false; | ||
|
||
public MarketplacePackageDescriptorBuilder nodeId(String nodeId) { | ||
this.nodeId = nodeId; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder url(String url) { | ||
this.url = url; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder dpUrl(String dpUrl) { | ||
this.dpUrl = dpUrl; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder minKuraVersion(String minKuraVersion) { | ||
this.minKuraVersion = minKuraVersion; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder maxKuraVersion(String maxKuraVersion) { | ||
this.maxKuraVersion = maxKuraVersion; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder currentKuraVersion(String currentKuraVersion) { | ||
this.currentKuraVersion = currentKuraVersion; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptorBuilder isCompatible(boolean isCompatible) { | ||
this.isCompatible = isCompatible; | ||
return this; | ||
} | ||
|
||
public MarketplacePackageDescriptor build() { | ||
return new MarketplacePackageDescriptor(this); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.