Merge remote-tracking branch 'origin/master' into
fix_Consitent_table_muliselect Conflicts: hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -53,3 +53,5 @@ local.properties
|
||||
# Maven
|
||||
maven.properties
|
||||
/*/maven.properties
|
||||
|
||||
hawkbit-repository/hawkbit-repository-jpa/.springBeans
|
||||
|
||||
0
3rd-dependencies/listDeps.sh
Executable file → Normal file
0
3rd-dependencies/listDeps.sh
Executable file → Normal file
@@ -11,3 +11,10 @@
|
||||
### REST API model changes for clients
|
||||
- ENTITYPagedList classes have been removed; generic PagedList used instead (e.g. PagedList<TargetRest> instead of TargetPagedList).
|
||||
- ENTITYsrest classes have been removed; List<ENTITYrest> used instead (e.g. List<TargetRest> instead of TargetsRest)
|
||||
|
||||
### Renamed api annotations
|
||||
- Annotation `org.eclipse.hawkbit.rest.resource.EnableRestResources` have changed to `org.eclipse.hawkbit.mgmt.annotation.EnableMgmtApi`
|
||||
- Annotation `org.eclipse.hawkbit.ddi.resource.EnableDirectDeviceApi` have changed to `org.eclipse.hawkbit.ddi.annotation.EnableDdiApi`
|
||||
|
||||
### Renamed maven modules
|
||||
- Module hawkbit-mgmt-api-client have changed to hawkbit-example-mgmt-simulator
|
||||
38
README.md
38
README.md
@@ -41,9 +41,9 @@ $ java -jar ./examples/hawkbit-example-app/target/hawkbit-example-app-#version#.
|
||||
$ java -jar ./examples/hawkbit-device-simulator/target/hawkbit-device-simulator-#version#.jar
|
||||
```
|
||||
#### Generate Getting Started data
|
||||
[Example Management API Client](examples/hawkbit-mgmt-api-client)
|
||||
[Example Management API Client](examples/hawkbit-example-mgmt-simulator)
|
||||
```
|
||||
$ java -jar ./examples/hawkbit-mgmt-api-client/target/hawkbit-mgmt-api-client-#version#.jar
|
||||
$ java -jar ./examples/hawkbit-example-mgmt-simulator/target/hawkbit-example-mgmt-simulator-#version#.jar
|
||||
```
|
||||
|
||||
# Releases and Roadmap
|
||||
@@ -52,21 +52,27 @@ $ java -jar ./examples/hawkbit-mgmt-api-client/target/hawkbit-mgmt-api-client-#v
|
||||
* The master branch contains future development towards 0.2. We are currently focusing on:
|
||||
* Rollout Management for large scale rollouts.
|
||||
* Clustering capabilities for the update server.
|
||||
* Upgrade of Spring Boot and Vaadin depedencies.
|
||||
* Upgrade of Spring Boot and Vaadin dependencies.
|
||||
* And of course tons of usability improvements and bug fixes.
|
||||
|
||||
|
||||
# Modules
|
||||
`hawkbit-core` : core elements.
|
||||
`hawkbit-security-core` : core security elements.
|
||||
`hawkbit-security-integration` : security integration elements to integrate security into hawkbit.
|
||||
`hawkbit-artifact-repository-mongo` : artifact repository implementation to mongoDB.
|
||||
`hawkbit-autoconfigure` : spring-boot auto-configuration.
|
||||
`hawkbit-dmf-api` : API for the Device Management Integration.
|
||||
`hawkbit-dmf-amqp` : AMQP endpoint implementation for the DMF API.
|
||||
`hawkbit-repository` : repository implemenation based on SQL for all meta-data.
|
||||
`hawkbit-http-security` : implementation for security filters for HTTP.
|
||||
`hawkbit-rest-api` : API classes for the REST Management API.
|
||||
`hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API.
|
||||
`hawkbit-ui` : Vaadin UI.
|
||||
`hawkbit-cache-redis` : spring cache manager configuration and implementation with redis, distributed cache and distributed events.
|
||||
* `examples` : hawkBit examples
|
||||
* `hawkbit-artifact-repository-mongo` : Artifact repository implementation to mongoDB.
|
||||
* `hawkbit-autoconfigure` : Spring-boot auto-configuration.
|
||||
* `hawkbit-cache-redis` : Spring cache manager configuration and implementation with redis, distributed cache and distributed events.
|
||||
* `hawkbit-core` : Core elements for internal interfaces and utility classes.
|
||||
* `hawkbit-ddi-api` : The hawkBit DDI API.
|
||||
* `hawkbit-ddi-dl-api` : The hawkBit DDI Download API.
|
||||
* `hawkbit-ddi-resource` : Implementation of the hawkBit DDI API
|
||||
* `hawkbit-dmf-amqp` : AMQP endpoint implementation for the DMF API.
|
||||
* `hawkbit-dmf-api` : API for the Device Management Integration.
|
||||
* `hawkbit-http-security` : Implementation for security filters for HTTP.
|
||||
* `hawkbit-mgmt-api` : The hawkBit Management API
|
||||
* `hawkbit-mgmt-resource` : Implementation of the hawkBit Management API
|
||||
* `hawkbit-repository` : Repository implementation based on SQL for all meta-data.
|
||||
* `hawkbit-rest-core` : Core elements for the rest modules.
|
||||
* `hawkbit-security-core` : Core security elements.
|
||||
* `hawkbit-security-integration` : Security integration elements to integrate security into hawkBit.
|
||||
* `hawkbit-test-report` : Test reports
|
||||
* `hawkbit-ui` : Vaadin UI.
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
Example projects that show how _hawkBit_ can be used to create, run or access an _hawkBit_ empowered update server.
|
||||
|
||||
- `hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options.
|
||||
- `hawkbit-example-app` : Allows you to run a Spring Boot and hawkBit based update server. Includes all _hawkBit_ interfaces, i.e. DDI, DMF, Mgmt-API, Mgmt-UI.
|
||||
- `hawkbit-custom-theme-example` : Example for a customized theme for Management UI.
|
||||
- `hawkbit-mgmt-api-client` : Example client for the _hawkBit_ Management API.
|
||||
- `hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options.
|
||||
- `hawkbit-example-app` : Allows you to run the Spring Boot hawkBit app. Includes all _hawkBit_ interfaces, i.e. DDI, DMF, Mgmt-API, Mgmt-UI.
|
||||
- `hawkbit-example-core-feign-client` : Core resources for the client examples.
|
||||
- `hawkbit-example-ddi-feign-client` : Example _hawkBit_ DDI client based on the _hawkBit_ DDI API.
|
||||
- `hawkbit-example-mgmt-feign-client` : Example _hawkBit_ Management client based on the _hawkBit_ Management API
|
||||
- `hawkbit-example-mgmt-simulator` : Example client simulation for the _hawkBit_ Management API based on Spring Boot and the hawkbit-example-mgmt-feign-client.
|
||||
|
||||
|
||||
@@ -79,6 +79,11 @@
|
||||
<artifactId>hawkbit-http-security</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
|
||||
@@ -8,11 +8,10 @@ package org.eclipse.hawkbit.app;
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.EnableJpaRepository;
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* A {@link SpringBootApplication} annotated class with a main method to start.
|
||||
@@ -20,16 +19,19 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@Import({ RepositoryApplicationConfiguration.class })
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
// Exception squid:S1118 - Spring boot standard behavior
|
||||
@SuppressWarnings({ "squid:S1118" })
|
||||
@EnableJpaRepository
|
||||
public class Start {
|
||||
|
||||
/**
|
||||
* Main method to start the spring-boot application.
|
||||
*
|
||||
* @param args
|
||||
* the VM arguments.
|
||||
*/
|
||||
// Exception squid:S2095 - Spring boot standard behavior
|
||||
@SuppressWarnings({ "squid:S2095" })
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Start.class, args);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
@@ -9,7 +8,8 @@
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
@@ -19,7 +19,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>hawkbit-device-simulator</artifactId>
|
||||
<name>hawkBit :: Device Simulator</name>
|
||||
<name>hawkBit-example :: Device Simulator</name>
|
||||
<description>Device Management Federation API based simulator</description>
|
||||
|
||||
<build>
|
||||
@@ -82,16 +82,26 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Log4j API and Core implementation required for binding -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for java-util-logging e.g. Tomcat -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for Jakarta Commons Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for Log4J Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vaadin</groupId>
|
||||
@@ -106,10 +116,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
@@ -117,12 +123,10 @@
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<version>8.14.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>8.12.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
@@ -133,13 +137,17 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.vaadin</groupId>
|
||||
<artifactId>vaadin-bom</artifactId>
|
||||
<version>7.6.3</version>
|
||||
<version>${vaadin.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.UpdateStatus.ResponseStatus;
|
||||
|
||||
/**
|
||||
* The bean of a simulated device which can be stored in the
|
||||
* {@link DeviceSimulatorRepository} or shown in the UI.
|
||||
@@ -22,16 +24,15 @@ public abstract class AbstractSimulatedDevice {
|
||||
private Status status;
|
||||
private double progress;
|
||||
private String swversion = "unknown";
|
||||
private ResponseStatus responseStatus = ResponseStatus.SUCCESSFUL;
|
||||
private UpdateStatus updateStatus = new UpdateStatus(ResponseStatus.SUCCESSFUL, "Simulation complete!");
|
||||
private Protocol protocol = Protocol.DMF_AMQP;
|
||||
private String targetSecurityToken;
|
||||
|
||||
private int nextPollCounterSec;
|
||||
|
||||
/**
|
||||
* Enum definition of the protocol to be used for the simulated device.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public enum Protocol {
|
||||
/**
|
||||
@@ -69,24 +70,6 @@ public abstract class AbstractSimulatedDevice {
|
||||
ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status to response to the hawkbit update server if an simulated
|
||||
* update process should be respond with successful or failure update.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public enum ResponseStatus {
|
||||
/**
|
||||
* updated has been successful and response the successful update.
|
||||
*/
|
||||
SUCCESSFUL,
|
||||
/**
|
||||
* updated has been not successful and response the error update.
|
||||
*/
|
||||
ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* empty constructor.
|
||||
*/
|
||||
@@ -158,12 +141,12 @@ public abstract class AbstractSimulatedDevice {
|
||||
this.swversion = swversion;
|
||||
}
|
||||
|
||||
public ResponseStatus getResponseStatus() {
|
||||
return responseStatus;
|
||||
public UpdateStatus getUpdateStatus() {
|
||||
return updateStatus;
|
||||
}
|
||||
|
||||
public void setResponseStatus(final ResponseStatus responseStatus) {
|
||||
this.responseStatus = responseStatus;
|
||||
public void setUpdateStatus(final UpdateStatus updateStatus) {
|
||||
this.updateStatus = updateStatus;
|
||||
}
|
||||
|
||||
public Protocol getProtocol() {
|
||||
@@ -177,4 +160,13 @@ public abstract class AbstractSimulatedDevice {
|
||||
public void setNextPollCounterSec(final int nextPollDelayInSec) {
|
||||
this.nextPollCounterSec = nextPollDelayInSec;
|
||||
}
|
||||
|
||||
public String getTargetSecurityToken() {
|
||||
return targetSecurityToken;
|
||||
}
|
||||
|
||||
public void setTargetSecurityToken(final String targetSecurityToken) {
|
||||
this.targetSecurityToken = targetSecurityToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.http.ControllerResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -18,7 +16,7 @@ import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.PathNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Michael Hirsch
|
||||
* A simulated device using the DDI API of the hawkBit update server.
|
||||
*
|
||||
*/
|
||||
public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
||||
@@ -26,12 +24,12 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DDISimulatedDevice.class);
|
||||
|
||||
private final int pollDelaySec;
|
||||
private final ScheduledExecutorService pollthreadpool;
|
||||
private final ControllerResource controllerResource;
|
||||
|
||||
private final DeviceSimulatorUpdater deviceUpdater;
|
||||
|
||||
private volatile boolean removed;
|
||||
private volatile Long currentActionId;
|
||||
private final DeviceSimulatorUpdater deviceUpdater;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
@@ -42,18 +40,14 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
||||
* the delay of the poll interval in sec
|
||||
* @param controllerResource
|
||||
* the http controller resource
|
||||
* @param pollthreadpool
|
||||
* the threadpool for polling endpoint
|
||||
* @param deviceUpdater
|
||||
* the service to update devices
|
||||
*/
|
||||
public DDISimulatedDevice(final String id, final String tenant, final int pollDelaySec,
|
||||
final ControllerResource controllerResource, final ScheduledExecutorService pollthreadpool,
|
||||
final DeviceSimulatorUpdater deviceUpdater) {
|
||||
final ControllerResource controllerResource, final DeviceSimulatorUpdater deviceUpdater) {
|
||||
super(id, tenant, Protocol.DDI_HTTP);
|
||||
this.pollDelaySec = pollDelaySec;
|
||||
this.controllerResource = controllerResource;
|
||||
this.pollthreadpool = pollthreadpool;
|
||||
this.deviceUpdater = deviceUpdater;
|
||||
setNextPollCounterSec(pollDelaySec);
|
||||
}
|
||||
@@ -76,27 +70,12 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
||||
final String basePollJson = controllerResource.get(getTenant(), getId());
|
||||
try {
|
||||
final String href = JsonPath.parse(basePollJson).read("_links.deploymentBase.href");
|
||||
final long actionId = Long.parseLong(href.substring(href.lastIndexOf("/") + 1, href.indexOf("?")));
|
||||
final long actionId = Long.parseLong(href.substring(href.lastIndexOf('/') + 1, href.indexOf('?')));
|
||||
if (currentActionId == null) {
|
||||
final String deploymentJson = controllerResource.getDeployment(getTenant(), getId(), actionId);
|
||||
final String swVersion = JsonPath.parse(deploymentJson).read("deployment.chunks[0].version");
|
||||
currentActionId = actionId;
|
||||
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, (device, actionId1) -> {
|
||||
switch (device.getResponseStatus()) {
|
||||
case SUCCESSFUL:
|
||||
controllerResource.postSuccessFeedback(getTenant(), getId(),
|
||||
actionId1);
|
||||
break;
|
||||
case ERROR:
|
||||
controllerResource.postErrorFeedback(getTenant(), getId(),
|
||||
actionId1);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(
|
||||
"simulated device has an unknown response status + " + device.getResponseStatus());
|
||||
}
|
||||
currentActionId = null;
|
||||
});
|
||||
startDdiUpdate(actionId, swVersion);
|
||||
}
|
||||
} catch (final PathNotFoundException e) {
|
||||
// href might not be in the json response, so ignore
|
||||
@@ -106,4 +85,21 @@ public class DDISimulatedDevice extends AbstractSimulatedDevice {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void startDdiUpdate(final long actionId, final String swVersion) {
|
||||
deviceUpdater.startUpdate(getTenant(), getId(), actionId, swVersion, null, null, (device, actionId1) -> {
|
||||
switch (device.getUpdateStatus().getResponseStatus()) {
|
||||
case SUCCESSFUL:
|
||||
controllerResource.postSuccessFeedback(getTenant(), getId(), actionId1);
|
||||
break;
|
||||
case ERROR:
|
||||
controllerResource.postErrorFeedback(getTenant(), getId(), actionId1);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("simulated device has an unknown response status + "
|
||||
+ device.getUpdateStatus().getResponseStatus());
|
||||
}
|
||||
currentActionId = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
/**
|
||||
* An simulated device using the DMF API of the hawkbit update server.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
* A simulated device using the DMF API of the hawkBit update server.
|
||||
*/
|
||||
public class DMFSimulatedDevice extends AbstractSimulatedDevice {
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.vaadin.spring.annotation.EnableVaadin;
|
||||
/**
|
||||
* The main-method to start the Spring-Boot application.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableVaadin
|
||||
@@ -46,6 +44,8 @@ public class DeviceSimulator {
|
||||
* @param args
|
||||
* the args
|
||||
*/
|
||||
// Exception squid:S2095 - Spring boot standard behavior
|
||||
@SuppressWarnings({ "squid:S2095" })
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(DeviceSimulator.class, args);
|
||||
}
|
||||
|
||||
@@ -8,27 +8,56 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.SSLContextBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.eclipse.hawkbit.dmf.json.model.Artifact;
|
||||
import org.eclipse.hawkbit.dmf.json.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||
import org.eclipse.hawkbit.simulator.UpdateStatus.ResponseStatus;
|
||||
import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
||||
import org.eclipse.hawkbit.simulator.event.InitUpdate;
|
||||
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
/**
|
||||
* @author Michael Hirsch
|
||||
* Update simulation handler.
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class DeviceSimulatorUpdater {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceSimulatorUpdater.class);
|
||||
|
||||
private static final ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(4);
|
||||
|
||||
@@ -54,14 +83,18 @@ public class DeviceSimulatorUpdater {
|
||||
* @param actionId
|
||||
* the actionId from the hawkbit update server to start the
|
||||
* update.
|
||||
* @param swVersion
|
||||
* @param modules
|
||||
* the software module version from the hawkbit update server
|
||||
* @param swVersion
|
||||
* the software version as static value in case modules is null
|
||||
* @param targetSecurityToken
|
||||
* the target security token for download authentication
|
||||
* @param callback
|
||||
* the callback which gets called when the simulated update
|
||||
* process has been finished
|
||||
*/
|
||||
public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
|
||||
final UpdaterCallback callback) {
|
||||
final List<SoftwareModule> modules, final String targetSecurityToken, final UpdaterCallback callback) {
|
||||
AbstractSimulatedDevice device = repository.get(tenant, id);
|
||||
|
||||
// plug and play - non existing device will be auto created
|
||||
@@ -70,14 +103,23 @@ public class DeviceSimulatorUpdater {
|
||||
}
|
||||
|
||||
device.setProgress(0.0);
|
||||
device.setSwversion(swVersion);
|
||||
|
||||
if (modules == null || modules.isEmpty()) {
|
||||
device.setSwversion(swVersion);
|
||||
} else {
|
||||
device.setSwversion(modules.stream().map(sm -> sm.getModuleVersion()).collect(Collectors.joining(", ")));
|
||||
}
|
||||
device.setTargetSecurityToken(targetSecurityToken);
|
||||
eventbus.post(new InitUpdate(device));
|
||||
|
||||
threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
|
||||
2_000, TimeUnit.MILLISECONDS);
|
||||
threadPool.schedule(
|
||||
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback, modules), 2_000,
|
||||
TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private static final class DeviceSimulatorUpdateThread implements Runnable {
|
||||
private static final int MINIMUM_TOKENLENGTH_FOR_HINT = 6;
|
||||
|
||||
private static final Random rndSleep = new SecureRandom();
|
||||
|
||||
private final AbstractSimulatedDevice device;
|
||||
@@ -85,38 +127,215 @@ public class DeviceSimulatorUpdater {
|
||||
private final long actionId;
|
||||
private final EventBus eventbus;
|
||||
private final UpdaterCallback callback;
|
||||
private final List<SoftwareModule> modules;
|
||||
|
||||
private DeviceSimulatorUpdateThread(final AbstractSimulatedDevice device, final SpSenderService spSenderService,
|
||||
final long actionId, final EventBus eventbus, final UpdaterCallback callback) {
|
||||
final long actionId, final EventBus eventbus, final UpdaterCallback callback,
|
||||
final List<SoftwareModule> modules) {
|
||||
this.device = device;
|
||||
this.spSenderService = spSenderService;
|
||||
this.actionId = actionId;
|
||||
this.eventbus = eventbus;
|
||||
this.callback = callback;
|
||||
this.modules = modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (device.getProgress() <= 0 && modules != null) {
|
||||
device.setUpdateStatus(simulateDownloads(device.getTargetSecurityToken()));
|
||||
if (isErrorResponse(device.getUpdateStatus())) {
|
||||
callback.updateFinished(device, actionId);
|
||||
eventbus.post(new ProgressUpdate(device));
|
||||
return;
|
||||
}
|
||||
// download is 80% of the game after all
|
||||
device.setProgress(0.8);
|
||||
}
|
||||
|
||||
final double newProgress = device.getProgress() + 0.2;
|
||||
device.setProgress(newProgress);
|
||||
if (newProgress < 1.0) {
|
||||
threadPool.schedule(
|
||||
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
|
||||
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback, modules),
|
||||
rndSleep.nextInt(5_000), TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
callback.updateFinished(device, actionId);
|
||||
}
|
||||
eventbus.post(new ProgressUpdate(device));
|
||||
}
|
||||
|
||||
private UpdateStatus simulateDownloads(final String targetToken) {
|
||||
final List<UpdateStatus> status = new ArrayList<>();
|
||||
|
||||
LOGGER.info("Simulate downloads for {}", device.getId());
|
||||
|
||||
modules.forEach(module -> module.getArtifacts()
|
||||
.forEach(artifact -> handleArtifacts(targetToken, status, artifact)));
|
||||
|
||||
final UpdateStatus result = new UpdateStatus(ResponseStatus.SUCCESSFUL);
|
||||
result.getStatusMessages().add("Simulation complete!");
|
||||
status.forEach(download -> {
|
||||
result.getStatusMessages().addAll(download.getStatusMessages());
|
||||
if (isErrorResponse(download)) {
|
||||
result.setResponseStatus(ResponseStatus.ERROR);
|
||||
}
|
||||
});
|
||||
|
||||
LOGGER.info("Download simulations complete for {}", device.getId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isErrorResponse(final UpdateStatus status) {
|
||||
if (status == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ResponseStatus.ERROR.equals(status.getResponseStatus());
|
||||
}
|
||||
|
||||
private static void handleArtifacts(final String targetToken, final List<UpdateStatus> status,
|
||||
final Artifact artifact) {
|
||||
artifact.getUrls().entrySet().forEach(entry -> {
|
||||
switch (entry.getKey()) {
|
||||
case HTTP:
|
||||
case HTTPS:
|
||||
status.add(downloadUrl(entry.getValue(), targetToken, artifact.getHashes().getSha1(),
|
||||
artifact.getSize()));
|
||||
break;
|
||||
default:
|
||||
// not supported yet
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static UpdateStatus downloadUrl(final String url, final String targetToken, final String sha1Hash,
|
||||
final long size) {
|
||||
LOGGER.debug("Downloading {} with token {}, expected sha1 hash {} and size {}", url,
|
||||
hideTokenDetails(targetToken), sha1Hash, size);
|
||||
|
||||
long overallread = 0;
|
||||
try {
|
||||
final CloseableHttpClient httpclient = createHttpClientThatAcceptsAllServerCerts();
|
||||
final HttpGet request = new HttpGet(url);
|
||||
request.addHeader(HttpHeaders.AUTHORIZATION, "TargetToken " + targetToken);
|
||||
|
||||
final String sha1HashResult;
|
||||
try (final CloseableHttpResponse response = httpclient.execute(request)) {
|
||||
|
||||
if (response.getStatusLine().getStatusCode() != HttpStatus.OK.value()) {
|
||||
final String message = wrongStatusCode(url, response);
|
||||
return new UpdateStatus(ResponseStatus.ERROR, message);
|
||||
}
|
||||
|
||||
if (response.getEntity().getContentLength() != size) {
|
||||
final String message = wrongContentLength(url, size, response);
|
||||
return new UpdateStatus(ResponseStatus.ERROR, message);
|
||||
}
|
||||
|
||||
final File tempFile = File.createTempFile("uploadFile", null);
|
||||
|
||||
// Exception squid:S2070 - not used for hashing sensitive
|
||||
// data
|
||||
@SuppressWarnings("squid:S2070")
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
|
||||
try (final DigestOutputStream dos = new DigestOutputStream(new FileOutputStream(tempFile), md)) {
|
||||
try (final BufferedOutputStream bdos = new BufferedOutputStream(dos)) {
|
||||
try (BufferedInputStream bis = new BufferedInputStream(response.getEntity().getContent())) {
|
||||
overallread = ByteStreams.copy(bis, bdos);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (tempFile != null && !tempFile.delete()) {
|
||||
LOGGER.error("Could not delete temporary file: {}", tempFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (overallread != size) {
|
||||
final String message = incompleteRead(url, size, overallread);
|
||||
return new UpdateStatus(ResponseStatus.ERROR, message);
|
||||
}
|
||||
|
||||
sha1HashResult = BaseEncoding.base16().lowerCase().encode(md.digest());
|
||||
}
|
||||
|
||||
if (!sha1Hash.equalsIgnoreCase(sha1HashResult)) {
|
||||
final String message = wrongHash(url, sha1Hash, overallread, sha1HashResult);
|
||||
return new UpdateStatus(ResponseStatus.ERROR, message);
|
||||
}
|
||||
|
||||
} catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
|
||||
LOGGER.error("Failed to download" + url, e);
|
||||
return new UpdateStatus(ResponseStatus.ERROR, "Failed to download " + url + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
final String message = "Downloaded " + url + " (" + overallread + " bytes)";
|
||||
LOGGER.debug(message);
|
||||
return new UpdateStatus(ResponseStatus.SUCCESSFUL, message);
|
||||
}
|
||||
|
||||
private static String hideTokenDetails(final String targetToken) {
|
||||
if (targetToken == null) {
|
||||
return "<NULL!>";
|
||||
}
|
||||
|
||||
if (targetToken.isEmpty()) {
|
||||
return "<EMTPTY!>";
|
||||
}
|
||||
|
||||
if (targetToken.length() <= MINIMUM_TOKENLENGTH_FOR_HINT) {
|
||||
return "***";
|
||||
}
|
||||
|
||||
return targetToken.substring(0, 2) + "***"
|
||||
+ targetToken.substring(targetToken.length() - 2, targetToken.length());
|
||||
}
|
||||
|
||||
private static String wrongHash(final String url, final String sha1Hash, final long overallread,
|
||||
final String sha1HashResult) {
|
||||
final String message = "Download " + url + " failed with SHA1 hash missmatch (Expected: " + sha1Hash
|
||||
+ " but got: " + sha1HashResult + ") (" + overallread + " bytes)";
|
||||
LOGGER.error(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String incompleteRead(final String url, final long size, final long overallread) {
|
||||
final String message = "Download " + url + " is incomplete (Expected: " + size + " but got: " + overallread
|
||||
+ ")";
|
||||
LOGGER.error(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String wrongContentLength(final String url, final long size,
|
||||
final CloseableHttpResponse response) {
|
||||
final String message = "Download " + url + " has wrong content length (Expected: " + size + " but got: "
|
||||
+ response.getEntity().getContentLength() + ")";
|
||||
LOGGER.error(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String wrongStatusCode(final String url, final CloseableHttpResponse response) {
|
||||
final String message = "Download " + url + " failed (" + response.getStatusLine().getStatusCode() + ")";
|
||||
LOGGER.error(message);
|
||||
return message;
|
||||
}
|
||||
|
||||
private static CloseableHttpClient createHttpClientThatAcceptsAllServerCerts()
|
||||
throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
final SSLContextBuilder builder = new SSLContextBuilder();
|
||||
builder.loadTrustMaterial(null, (chain, authType) -> true);
|
||||
final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
|
||||
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback interface which is called when the simulated update process has
|
||||
* been finished and the caller of starting the simulated update process can
|
||||
* send the result to the hawkbit update server back.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
* send the result back to the hawkBit update server.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface UpdaterCallback {
|
||||
|
||||
@@ -26,9 +26,6 @@ import com.google.common.eventbus.EventBus;
|
||||
/**
|
||||
* Poll time trigger which executes the {@link DDISimulatedDevice#poll()} every
|
||||
* second.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class NextPollTimeController {
|
||||
@@ -59,16 +56,15 @@ public class NextPollTimeController {
|
||||
|
||||
devices.forEach(device -> {
|
||||
int nextCounter = device.getNextPollCounterSec() - 1;
|
||||
if (nextCounter < 0) {
|
||||
if (device instanceof DDISimulatedDevice) {
|
||||
try {
|
||||
pollService.submit(() -> ((DDISimulatedDevice) device).poll());
|
||||
} catch (final IllegalStateException e) {
|
||||
LOGGER.trace("Device could not be polled", e);
|
||||
}
|
||||
nextCounter = ((DDISimulatedDevice) device).getPollDelaySec();
|
||||
if (nextCounter < 0 && device instanceof DDISimulatedDevice) {
|
||||
try {
|
||||
pollService.submit(() -> ((DDISimulatedDevice) device).poll());
|
||||
} catch (final IllegalStateException e) {
|
||||
LOGGER.trace("Device could not be polled", e);
|
||||
}
|
||||
nextCounter = ((DDISimulatedDevice) device).getPollDelaySec();
|
||||
}
|
||||
|
||||
device.setNextPollCounterSec(nextCounter);
|
||||
});
|
||||
eventBus.post(new NextPollCounterUpdate(devices));
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||
import org.eclipse.hawkbit.simulator.http.ControllerResource;
|
||||
@@ -24,15 +22,9 @@ import feign.Logger;
|
||||
/**
|
||||
* The simulated device factory to create either {@link DMFSimulatedDevice} or
|
||||
* {@link DDISimulatedDevice#}.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class SimulatedDeviceFactory {
|
||||
|
||||
private static final ScheduledExecutorService pollThreadPool = Executors.newScheduledThreadPool(4);
|
||||
|
||||
@Autowired
|
||||
private DeviceSimulatorUpdater deviceUpdater;
|
||||
|
||||
@@ -47,7 +39,8 @@ public class SimulatedDeviceFactory {
|
||||
* the protocol of the device
|
||||
* @return the created simulated device
|
||||
*/
|
||||
public AbstractSimulatedDevice createSimulatedDevice(final String id, final String tenant, final Protocol protocol) {
|
||||
public AbstractSimulatedDevice createSimulatedDevice(final String id, final String tenant,
|
||||
final Protocol protocol) {
|
||||
return createSimulatedDevice(id, tenant, protocol, 30, null, null);
|
||||
}
|
||||
|
||||
@@ -80,7 +73,7 @@ public class SimulatedDeviceFactory {
|
||||
final ControllerResource controllerResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.requestInterceptor(new GatewayTokenInterceptor(gatewayToken)).logLevel(Logger.Level.BASIC)
|
||||
.target(ControllerResource.class, baseEndpoint.toString());
|
||||
return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, pollThreadPool, deviceUpdater);
|
||||
return new DDISimulatedDevice(id, tenant, pollDelaySec, controllerResource, deviceUpdater);
|
||||
default:
|
||||
throw new IllegalArgumentException("Protocol " + protocol + " unknown");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "hawkbit.device.simulator", name = "autostart", matchIfMissing = true)
|
||||
public class SimulatorStartup implements ApplicationListener<ContextRefreshedEvent> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Update status of the simulated update.
|
||||
*
|
||||
*/
|
||||
public class UpdateStatus {
|
||||
private ResponseStatus responseStatus;
|
||||
private List<String> statusMessages;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param responseStatus
|
||||
* of the update
|
||||
*/
|
||||
public UpdateStatus(final ResponseStatus responseStatus) {
|
||||
this.responseStatus = responseStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor including status message.
|
||||
*
|
||||
* @param responseStatus
|
||||
* of the update
|
||||
* @param message
|
||||
* of the update status
|
||||
*/
|
||||
public UpdateStatus(final ResponseStatus responseStatus, final String message) {
|
||||
this(responseStatus);
|
||||
statusMessages = new ArrayList<>();
|
||||
statusMessages.add(message);
|
||||
}
|
||||
|
||||
public ResponseStatus getResponseStatus() {
|
||||
return responseStatus;
|
||||
}
|
||||
|
||||
public void setResponseStatus(final ResponseStatus responseStatus) {
|
||||
this.responseStatus = responseStatus;
|
||||
}
|
||||
|
||||
public List<String> getStatusMessages() {
|
||||
if (statusMessages == null) {
|
||||
statusMessages = new ArrayList<>();
|
||||
}
|
||||
|
||||
return statusMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status to response to the hawkBit update server if an simulated
|
||||
* update process should be respond with successful or failure update.
|
||||
*/
|
||||
public enum ResponseStatus {
|
||||
/**
|
||||
* Update has been successful and response the successful update.
|
||||
*/
|
||||
SUCCESSFUL,
|
||||
|
||||
/**
|
||||
* Update has been not successful and response the error update.
|
||||
*/
|
||||
ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,6 +39,12 @@ public class AmqpProperties {
|
||||
*/
|
||||
private String deadLetterExchange = "simulator.deadletter";
|
||||
|
||||
/**
|
||||
* Message time to live (ttl) for the deadletter queue. Default ttl is 1
|
||||
* hour.
|
||||
*/
|
||||
private int deadLetterTtl = 60_000;
|
||||
|
||||
public String getReceiverConnectorQueueFromSp() {
|
||||
return receiverConnectorQueueFromSp;
|
||||
}
|
||||
@@ -70,4 +76,12 @@ public class AmqpProperties {
|
||||
public void setSenderForSpExchange(final String senderForSpExchange) {
|
||||
this.senderForSpExchange = senderForSpExchange;
|
||||
}
|
||||
|
||||
public int getDeadLetterTtl() {
|
||||
return deadLetterTtl;
|
||||
}
|
||||
|
||||
public void setDeadLetterTtl(final int deadLetterTtl) {
|
||||
this.deadLetterTtl = deadLetterTtl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Handle all incoming Messages from hawkBit update server.
|
||||
*
|
||||
@@ -88,6 +90,8 @@ public class SpReceiverService extends ReceiverService {
|
||||
if (eventHeader == null) {
|
||||
logAndThrowMessageError(message, "Event Topic is not set");
|
||||
}
|
||||
// Exception squid:S2259 - Checked before
|
||||
@SuppressWarnings({ "squid:S2259" })
|
||||
final EventTopic eventTopic = EventTopic.valueOf(eventHeader.toString());
|
||||
switch (eventTopic) {
|
||||
case DOWNLOAD_AND_INSTALL:
|
||||
@@ -109,7 +113,7 @@ public class SpReceiverService extends ReceiverService {
|
||||
final Long actionId = convertMessage(message, Long.class);
|
||||
|
||||
final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
|
||||
spSenderService.finishUpdateProcess(update, "Simulation canceled");
|
||||
spSenderService.finishUpdateProcess(update, Lists.newArrayList("Simulation canceled"));
|
||||
}
|
||||
|
||||
private void handleUpdateProcess(final Message message, final String thingId) {
|
||||
@@ -120,19 +124,20 @@ public class SpReceiverService extends ReceiverService {
|
||||
final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(message,
|
||||
DownloadAndUpdateRequest.class);
|
||||
final Long actionId = downloadAndUpdateRequest.getActionId();
|
||||
final String targetSecurityToken = downloadAndUpdateRequest.getTargetSecurityToken();
|
||||
|
||||
deviceUpdater.startUpdate(tenant, thingId, actionId,
|
||||
downloadAndUpdateRequest.getSoftwareModules().get(0).getModuleVersion(), (device, actionId1) -> {
|
||||
switch (device.getResponseStatus()) {
|
||||
deviceUpdater.startUpdate(tenant, thingId, actionId, null, downloadAndUpdateRequest.getSoftwareModules(),
|
||||
targetSecurityToken, (device, actionId1) -> {
|
||||
switch (device.getUpdateStatus().getResponseStatus()) {
|
||||
case SUCCESSFUL:
|
||||
spSenderService.finishUpdateProcess(
|
||||
new SimulatedUpdate(device.getTenant(), device.getId(), actionId1),
|
||||
"Simulation complete!");
|
||||
device.getUpdateStatus().getStatusMessages());
|
||||
break;
|
||||
case ERROR:
|
||||
spSenderService.finishUpdateProcessWithError(
|
||||
new SimulatedUpdate(device.getTenant(), device.getId(), actionId1),
|
||||
"Simulation complete with error!");
|
||||
device.getUpdateStatus().getStatusMessages());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator.amqp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
|
||||
@@ -23,13 +24,9 @@ import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Sender service to send message to SP.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Sender service to send messages to update server.
|
||||
*/
|
||||
@Service
|
||||
public class SpSenderService extends SenderService {
|
||||
@@ -59,8 +56,9 @@ public class SpSenderService extends SenderService {
|
||||
* @param description
|
||||
* a description according the update process
|
||||
*/
|
||||
public void finishUpdateProcess(final SimulatedUpdate update, final String description) {
|
||||
final Message updateResultMessage = createUpdateResultMessage(update, ActionStatus.FINISHED, description);
|
||||
public void finishUpdateProcess(final SimulatedUpdate update, final List<String> updateResultMessages) {
|
||||
final Message updateResultMessage = createUpdateResultMessage(update, ActionStatus.FINISHED,
|
||||
updateResultMessages);
|
||||
sendMessage(spExchange, updateResultMessage);
|
||||
}
|
||||
|
||||
@@ -72,9 +70,9 @@ public class SpSenderService extends SenderService {
|
||||
* @param messageDescription
|
||||
* a description according the update process
|
||||
*/
|
||||
public void finishUpdateProcessWithError(final SimulatedUpdate update, final String messageDescription) {
|
||||
sendErrorgMessage(update, messageDescription);
|
||||
LOGGER.debug("Update process finished with error \"{}\" reported by thing {}", messageDescription,
|
||||
public void finishUpdateProcessWithError(final SimulatedUpdate update, final List<String> updateResultMessages) {
|
||||
sendErrorgMessage(update, updateResultMessages);
|
||||
LOGGER.debug("Update process finished with error \"{}\" reported by thing {}", updateResultMessages,
|
||||
update.getThingId());
|
||||
}
|
||||
|
||||
@@ -88,8 +86,8 @@ public class SpSenderService extends SenderService {
|
||||
* @param actionId
|
||||
* the ID of the action for the error message
|
||||
*/
|
||||
public void sendErrorMessage(final String tenant, final String messageDescription, final Long actionId) {
|
||||
final Message message = createActionStatusMessage(tenant, ActionStatus.ERROR, messageDescription, actionId);
|
||||
public void sendErrorMessage(final String tenant, final List<String> updateResultMessages, final Long actionId) {
|
||||
final Message message = createActionStatusMessage(tenant, ActionStatus.ERROR, updateResultMessages, actionId);
|
||||
sendMessage(spExchange, message);
|
||||
}
|
||||
|
||||
@@ -101,8 +99,8 @@ public class SpSenderService extends SenderService {
|
||||
* @param warningMessage
|
||||
* a warning description
|
||||
*/
|
||||
public void sendWarningMessage(final SimulatedUpdate update, final String warningMessage) {
|
||||
final Message message = createActionStatusMessage(update, warningMessage, ActionStatus.WARNING);
|
||||
public void sendWarningMessage(final SimulatedUpdate update, final List<String> updateResultMessages) {
|
||||
final Message message = createActionStatusMessage(update, updateResultMessages, ActionStatus.WARNING);
|
||||
sendMessage(spExchange, message);
|
||||
}
|
||||
|
||||
@@ -119,8 +117,8 @@ public class SpSenderService extends SenderService {
|
||||
* the cached value
|
||||
*/
|
||||
public void sendActionStatusMessage(final String tenant, final ActionStatus actionStatus,
|
||||
final String actionMessage, final Long actionId) {
|
||||
final Message message = createActionStatusMessage(tenant, actionStatus, actionMessage, actionId);
|
||||
final List<String> updateResultMessages, final Long actionId) {
|
||||
final Message message = createActionStatusMessage(tenant, actionStatus, updateResultMessages, actionId);
|
||||
sendMessage(message);
|
||||
|
||||
}
|
||||
@@ -162,11 +160,11 @@ public class SpSenderService extends SenderService {
|
||||
*
|
||||
* @param context
|
||||
* the current context
|
||||
* @param messageDescription
|
||||
* a description according the update process
|
||||
* @param updateResultMessages
|
||||
* a list of descriptions according the update process
|
||||
*/
|
||||
private void sendErrorgMessage(final SimulatedUpdate update, final String messageDescription) {
|
||||
final Message message = createActionStatusMessage(update, messageDescription, ActionStatus.ERROR);
|
||||
private void sendErrorgMessage(final SimulatedUpdate update, final List<String> updateResultMessages) {
|
||||
final Message message = createActionStatusMessage(update, updateResultMessages, ActionStatus.ERROR);
|
||||
sendMessage(spExchange, message);
|
||||
}
|
||||
|
||||
@@ -183,7 +181,7 @@ public class SpSenderService extends SenderService {
|
||||
* the cacheValue value
|
||||
*/
|
||||
private Message createActionStatusMessage(final String tenant, final ActionStatus actionStatus,
|
||||
final String actionMessage, final Long actionId) {
|
||||
final List<String> updateResultMessages, final Long actionId) {
|
||||
final MessageProperties messageProperties = new MessageProperties();
|
||||
final Map<String, Object> headers = messageProperties.getHeaders();
|
||||
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
|
||||
@@ -192,15 +190,14 @@ public class SpSenderService extends SenderService {
|
||||
headers.put(MessageHeaderKey.TENANT, tenant);
|
||||
headers.put(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||
headers.put(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON);
|
||||
if (!StringUtils.isEmpty(actionMessage)) {
|
||||
actionUpdateStatus.getMessage().add(actionMessage);
|
||||
}
|
||||
actionUpdateStatus.getMessage().addAll(updateResultMessages);
|
||||
|
||||
actionUpdateStatus.setActionId(actionId);
|
||||
return convertMessage(actionUpdateStatus, messageProperties);
|
||||
}
|
||||
|
||||
private Message createUpdateResultMessage(final SimulatedUpdate cacheValue, final ActionStatus actionStatus,
|
||||
final String updateResultMessage) {
|
||||
final List<String> updateResultMessages) {
|
||||
final MessageProperties messageProperties = new MessageProperties();
|
||||
final Map<String, Object> headers = messageProperties.getHeaders();
|
||||
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
|
||||
@@ -209,14 +206,14 @@ public class SpSenderService extends SenderService {
|
||||
headers.put(MessageHeaderKey.TENANT, cacheValue.getTenant());
|
||||
headers.put(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||
headers.put(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON);
|
||||
actionUpdateStatus.getMessage().add(updateResultMessage);
|
||||
actionUpdateStatus.getMessage().addAll(updateResultMessages);
|
||||
actionUpdateStatus.setActionId(cacheValue.getActionId());
|
||||
return convertMessage(actionUpdateStatus, messageProperties);
|
||||
}
|
||||
|
||||
private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription,
|
||||
private Message createActionStatusMessage(final SimulatedUpdate update, final List<String> updateResultMessages,
|
||||
final ActionStatus status) {
|
||||
return createActionStatusMessage(update.getTenant(), status, messageDescription, update.getActionId());
|
||||
return createActionStatusMessage(update.getTenant(), status, updateResultMessages, update.getActionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,6 @@ import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice;
|
||||
/**
|
||||
* Event definition object which is published if the simulated device updated
|
||||
* its update progress.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public class ProgressUpdate {
|
||||
|
||||
@@ -8,21 +8,19 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.simulator.ui;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice;
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.ResponseStatus;
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Status;
|
||||
import org.eclipse.hawkbit.simulator.DeviceSimulatorRepository;
|
||||
import org.eclipse.hawkbit.simulator.SimulatedDeviceFactory;
|
||||
import org.eclipse.hawkbit.simulator.UpdateStatus.ResponseStatus;
|
||||
import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
||||
import org.eclipse.hawkbit.simulator.event.InitUpdate;
|
||||
import org.eclipse.hawkbit.simulator.event.NextPollCounterUpdate;
|
||||
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
|
||||
import org.eclipse.hawkbit.simulator.ui.GenerateDialog.GenerateDialogCallback;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -52,13 +50,29 @@ import com.vaadin.ui.renderers.ProgressBarRenderer;
|
||||
* Vaadin view which allows to generate devices through the DMF API and show the
|
||||
* current simulated devices in a grid with their current status and update
|
||||
* progress.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
@SpringView(name = "")
|
||||
// The inheritance comes from Vaadin
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth")
|
||||
public class SimulatorView extends VerticalLayout implements View {
|
||||
|
||||
private static final String NEXT_POLL_COUNTER_SEC_COL = "nextPollCounterSec";
|
||||
|
||||
private static final String RESPONSE_STATUS_COL = "updateStatus";
|
||||
|
||||
private static final String PROTOCOL_COL = "protocol";
|
||||
|
||||
private static final String TENANT_COL = "tenant";
|
||||
|
||||
private static final String PROGRESS_COL = "progress";
|
||||
|
||||
private static final String SWVERSION_COL = "swversion";
|
||||
|
||||
private static final String STATUS_COL = "status";
|
||||
|
||||
private static final String ID_COL = "id";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
@@ -79,6 +93,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
|
||||
private BeanContainer<String, AbstractSimulatedDevice> beanContainer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void enter(final ViewChangeEvent event) {
|
||||
eventbus.register(this);
|
||||
@@ -91,7 +106,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
createToolbar();
|
||||
|
||||
beanContainer = new BeanContainer<>(AbstractSimulatedDevice.class);
|
||||
beanContainer.setBeanIdProperty("id");
|
||||
beanContainer.setBeanIdProperty(ID_COL);
|
||||
|
||||
grid.setSizeFull();
|
||||
grid.setCellStyleGenerator(new CellStyleGenerator() {
|
||||
@@ -100,38 +115,37 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
|
||||
@Override
|
||||
public String getStyle(final CellReference cellReference) {
|
||||
return cellReference.getPropertyId().equals("status") ? "centeralign" : null;
|
||||
return cellReference.getPropertyId().equals(STATUS_COL) ? "centeralign" : null;
|
||||
}
|
||||
});
|
||||
|
||||
grid.setSelectionMode(SelectionMode.NONE);
|
||||
grid.setContainerDataSource(beanContainer);
|
||||
grid.appendHeaderRow().getCell("responseStatus").setComponent(responseComboBox);
|
||||
grid.setColumnOrder("id", "status", "swversion", "progress", "tenant", "protocol", "responseStatus",
|
||||
"nextPollCounterSec");
|
||||
grid.appendHeaderRow().getCell(RESPONSE_STATUS_COL).setComponent(responseComboBox);
|
||||
grid.setColumnOrder(ID_COL, STATUS_COL, SWVERSION_COL, PROGRESS_COL, TENANT_COL, PROTOCOL_COL,
|
||||
RESPONSE_STATUS_COL, NEXT_POLL_COUNTER_SEC_COL);
|
||||
// header widths
|
||||
grid.getColumn("status").setMaximumWidth(80);
|
||||
grid.getColumn("protocol").setMaximumWidth(180);
|
||||
grid.getColumn("responseStatus").setMaximumWidth(240);
|
||||
grid.getColumn("nextPollCounterSec").setMaximumWidth(210);
|
||||
grid.getColumn(STATUS_COL).setMaximumWidth(80);
|
||||
grid.getColumn(PROTOCOL_COL).setMaximumWidth(180);
|
||||
grid.getColumn(RESPONSE_STATUS_COL).setMaximumWidth(240);
|
||||
grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setMaximumWidth(210);
|
||||
|
||||
grid.getColumn("nextPollCounterSec").setHeaderCaption("Next Poll in (sec)");
|
||||
grid.getColumn("swversion").setHeaderCaption("SW Version");
|
||||
grid.getColumn("responseStatus").setHeaderCaption("Response Update Status");
|
||||
grid.getColumn("progress").setRenderer(new ProgressBarRenderer());
|
||||
grid.getColumn("protocol").setConverter(createProtocolConverter());
|
||||
grid.getColumn("status").setRenderer(new HtmlRenderer(), createStatusConverter());
|
||||
grid.removeColumn("tenant");
|
||||
grid.getColumn(NEXT_POLL_COUNTER_SEC_COL).setHeaderCaption("Next Poll in (sec)");
|
||||
grid.getColumn(SWVERSION_COL).setHeaderCaption("SW Version");
|
||||
grid.getColumn(RESPONSE_STATUS_COL).setHeaderCaption("Response Update Status");
|
||||
grid.getColumn(PROGRESS_COL).setRenderer(new ProgressBarRenderer());
|
||||
grid.getColumn(PROTOCOL_COL).setConverter(createProtocolConverter());
|
||||
grid.getColumn(STATUS_COL).setRenderer(new HtmlRenderer(), createStatusConverter());
|
||||
grid.removeColumn(TENANT_COL);
|
||||
|
||||
// grid combobox
|
||||
responseComboBox.setItemIcon(ResponseStatus.SUCCESSFUL, FontAwesome.CHECK_CIRCLE);
|
||||
responseComboBox.setItemIcon(ResponseStatus.ERROR, FontAwesome.EXCLAMATION_CIRCLE);
|
||||
responseComboBox.setNullSelectionAllowed(false);
|
||||
responseComboBox.setValue(ResponseStatus.SUCCESSFUL);
|
||||
responseComboBox.addValueChangeListener(valueChangeEvent -> {
|
||||
beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId).getItemProperty("responseStatus")
|
||||
.setValue(valueChangeEvent.getProperty().getValue()));
|
||||
});
|
||||
responseComboBox.addValueChangeListener(
|
||||
valueChangeEvent -> beanContainer.getItemIds().forEach(itemId -> beanContainer.getItem(itemId)
|
||||
.getItemProperty(RESPONSE_STATUS_COL).setValue(valueChangeEvent.getProperty().getValue())));
|
||||
|
||||
// add all components
|
||||
addComponent(caption);
|
||||
@@ -141,7 +155,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
setExpandRatio(grid, 1.0F);
|
||||
|
||||
// load beans
|
||||
repository.getAll().forEach(device -> beanContainer.addBean(device));
|
||||
repository.getAll().forEach(beanContainer::addBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,21 +164,16 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
eventbus.unregister(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Subscribe
|
||||
public void pollCounterUpdate(final NextPollCounterUpdate update) {
|
||||
final List<AbstractSimulatedDevice> devices = update.getDevices();
|
||||
this.getUI().access(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
devices.forEach(device -> {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item != null) {
|
||||
item.getItemProperty("nextPollCounterSec").setValue(device.getNextPollCounterSec());
|
||||
}
|
||||
});
|
||||
this.getUI().access(() -> devices.forEach(device -> {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item != null) {
|
||||
item.getItemProperty(NEXT_POLL_COUNTER_SEC_COL).setValue(device.getNextPollCounterSec());
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,21 +182,19 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
* @param update
|
||||
* the update event posted on the event bus
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Subscribe
|
||||
public void initUpdate(final InitUpdate update) {
|
||||
final AbstractSimulatedDevice device = update.getDevice();
|
||||
this.getUI().access(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item != null) {
|
||||
item.getItemProperty("progress").setValue(device.getProgress());
|
||||
item.getItemProperty("status").setValue(Status.PEDNING);
|
||||
item.getItemProperty("swversion").setValue(device.getSwversion());
|
||||
}
|
||||
|
||||
this.getUI().access(() -> {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
item.getItemProperty(PROGRESS_COL).setValue(device.getProgress());
|
||||
item.getItemProperty(STATUS_COL).setValue(Status.PEDNING);
|
||||
item.getItemProperty(SWVERSION_COL).setValue(device.getSwversion());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -197,35 +204,37 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
* @param update
|
||||
* the update event posted on the event bus
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Subscribe
|
||||
public void progessUpdate(final ProgressUpdate update) {
|
||||
final AbstractSimulatedDevice device = update.getDevice();
|
||||
this.getUI().access(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item != null) {
|
||||
item.getItemProperty("progress").setValue(device.getProgress());
|
||||
if (device.getProgress() >= 1) {
|
||||
switch (device.getResponseStatus()) {
|
||||
case SUCCESSFUL:
|
||||
item.getItemProperty("status").setValue(Status.FINISH);
|
||||
break;
|
||||
case ERROR:
|
||||
item.getItemProperty("status").setValue(Status.ERROR);
|
||||
break;
|
||||
default:
|
||||
item.getItemProperty("status").setValue(Status.UNKNWON);
|
||||
}
|
||||
} else {
|
||||
item.getItemProperty("status").setValue(Status.PEDNING);
|
||||
}
|
||||
}
|
||||
|
||||
this.getUI().access(() -> {
|
||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||
if (item != null) {
|
||||
item.getItemProperty(PROGRESS_COL).setValue(device.getProgress());
|
||||
setStatusColumn(device, item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setStatusColumn(final AbstractSimulatedDevice device, final BeanItem<AbstractSimulatedDevice> item) {
|
||||
if (device.getProgress() >= 1) {
|
||||
switch (device.getUpdateStatus().getResponseStatus()) {
|
||||
case SUCCESSFUL:
|
||||
item.getItemProperty(STATUS_COL).setValue(Status.FINISH);
|
||||
break;
|
||||
case ERROR:
|
||||
item.getItemProperty(STATUS_COL).setValue(Status.ERROR);
|
||||
break;
|
||||
default:
|
||||
item.getItemProperty(STATUS_COL).setValue(Status.UNKNWON);
|
||||
}
|
||||
} else {
|
||||
item.getItemProperty(STATUS_COL).setValue(Status.PEDNING);
|
||||
}
|
||||
}
|
||||
|
||||
private void createToolbar() {
|
||||
final Button createDevicesButton = new Button("generate...");
|
||||
createDevicesButton.setIcon(FontAwesome.GEARS);
|
||||
@@ -246,18 +255,15 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
}
|
||||
|
||||
private void openGenerateDialog() {
|
||||
UI.getCurrent().addWindow(new GenerateDialog(new GenerateDialogCallback() {
|
||||
@Override
|
||||
public void okButton(final String namePrefix, final String tenant, final int amount, final int pollDelay,
|
||||
final URL basePollUrl, final String gatewayToken, final Protocol protocol) {
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String deviceId = namePrefix + index;
|
||||
beanContainer.addBean(repository.add(deviceFactory.createSimulatedDevice(deviceId,
|
||||
tenant.toLowerCase(), protocol, pollDelay, basePollUrl, gatewayToken)));
|
||||
spSenderService.createOrUpdateThing(tenant, deviceId);
|
||||
}
|
||||
}
|
||||
}));
|
||||
UI.getCurrent().addWindow(
|
||||
new GenerateDialog((namePrefix, tenant, amount, pollDelay, basePollUrl, gatewayToken, protocol) -> {
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String deviceId = namePrefix + index;
|
||||
beanContainer.addBean(repository.add(deviceFactory.createSimulatedDevice(deviceId,
|
||||
tenant.toLowerCase(), protocol, pollDelay, basePollUrl, gatewayToken)));
|
||||
spSenderService.createOrUpdateThing(tenant, deviceId);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private Converter<String, Protocol> createProtocolConverter() {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
|
||||
<logger name="org.eclipse.hawkbit.eventbus.DeadEventListener" level="WARN" />
|
||||
<Logger name="org.springframework.boot.actuate.audit.listener.AuditListener" level="WARN" />
|
||||
|
||||
<Logger name="org.hibernate.validator.internal.util.Version" level="WARN" />
|
||||
|
||||
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.jdbc.pool.ConnectionPool" level="DEBUG" />
|
||||
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
|
||||
|
||||
<!-- Security Log with hints on potential attacks -->
|
||||
<logger name="server-security" level="INFO" />
|
||||
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
|
||||
</configuration>
|
||||
@@ -4,16 +4,20 @@ The hawkBit example application is a standalone spring-boot application with an
|
||||
We have have described several options for you to get access to the example.
|
||||
|
||||
## Try out the example application in our hawkBit sandbox on Bluemix
|
||||
- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI
|
||||
- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header)
|
||||
- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE
|
||||
- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI (username: admin, passwd: admin)
|
||||
- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header; username: admin, passwd: admin)
|
||||
- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE (authentication disabled)
|
||||
|
||||
## On your own workstation
|
||||
### Run
|
||||
```
|
||||
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar
|
||||
```
|
||||
|
||||
_(Note: you have to add the JDBC driver also to your class path if you intend to use another database than H2.)_
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
run org eclipse.hawkbit.app.Start
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-example-app</artifactId>
|
||||
<name>hawkBit :: Example App</name>
|
||||
<name>hawkBit-example :: UI Application</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -64,7 +64,12 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-rest-resource</artifactId>
|
||||
<artifactId>hawkbit-mgmt-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ddi-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -87,6 +92,11 @@
|
||||
<artifactId>hawkbit-http-security</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
@@ -96,16 +106,26 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Log4j API and Core implementation required for binding -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for java-util-logging e.g. Tomcat -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for Jakarta Commons Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
<!-- Logging binding for Log4J Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
|
||||
@@ -20,11 +20,11 @@ import com.vaadin.spring.annotation.SpringUI;
|
||||
* login path. The easiest way to get an hawkBit login UI running is to extend
|
||||
* the {@link HawkbitLoginUI} and to annotated it with {@link SpringUI} as in
|
||||
* this example to the defined {@link HawkbitTheme#LOGIN_UI_PATH}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SpringUI(path = HawkbitTheme.LOGIN_UI_PATH)
|
||||
// Exception squid:MaximumInheritanceDepth - Most of the inheritance comes from
|
||||
// Vaadin.
|
||||
@SuppressWarnings({ "squid:MaximumInheritanceDepth" })
|
||||
public class MyLoginUI extends HawkbitLoginUI {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -29,6 +29,9 @@ import com.vaadin.spring.annotation.SpringUI;
|
||||
*/
|
||||
@SpringUI
|
||||
@Push(value = PushMode.AUTOMATIC, transport = Transport.WEBSOCKET)
|
||||
// Exception squid:MaximumInheritanceDepth - Most of the inheritance comes from
|
||||
// Vaadin.
|
||||
@SuppressWarnings({ "squid:MaximumInheritanceDepth" })
|
||||
public class MyUI extends HawkbitUI {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.EnableJpaRepository;
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.eclipse.hawkbit.controller.EnableDirectDeviceApi;
|
||||
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.mgmt.EnableMgmtApi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* A {@link SpringBootApplication} annotated class with a main method to start.
|
||||
@@ -22,10 +21,12 @@ import org.springframework.context.annotation.Import;
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@Import({ RepositoryApplicationConfiguration.class })
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
@EnableRestResources
|
||||
@EnableDirectDeviceApi
|
||||
@EnableMgmtApi
|
||||
@EnableDdiApi
|
||||
@EnableJpaRepository
|
||||
// Exception squid:S1118 - Spring boot standard behavior
|
||||
@SuppressWarnings({ "squid:S1118" })
|
||||
public class Start {
|
||||
|
||||
/**
|
||||
@@ -34,6 +35,8 @@ public class Start {
|
||||
* @param args
|
||||
* the VM arguments.
|
||||
*/
|
||||
// Exception squid:S2095 - Spring boot standard behavior
|
||||
@SuppressWarnings({ "squid:S2095" })
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Start.class, args);
|
||||
}
|
||||
|
||||
@@ -8,3 +8,9 @@
|
||||
#
|
||||
|
||||
vaadin.servlet.productionMode=true
|
||||
|
||||
hawkbit.artifact.url.coap.enabled=false
|
||||
hawkbit.artifact.url.http.enabled=false
|
||||
hawkbit.artifact.url.https.enabled=true
|
||||
hawkbit.artifact.url.https.pattern={protocol}://{hostname}/{tenant}/controller/v1/{targetId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}
|
||||
hawkbit.artifact.url.https.hostname=hawkbit.eu-gb.mybluemix.net
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
|
||||
# This profile adds basic configurations for a MySQL DB usage.
|
||||
# Keep in mind that you need the MariaDB driver in your classpath on compile.
|
||||
# see https://github.com/eclipse/hawkbit/wiki/Run-hawkBit
|
||||
|
||||
spring.jpa.database=MYSQL
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/hawkbit
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
|
||||
|
||||
spring.datasource.max-active=100
|
||||
spring.datasource.max-idle=10
|
||||
spring.datasource.min-idle=10
|
||||
spring.datasource.initial-size=10
|
||||
spring.datasource.validation-query=select 1 from dual
|
||||
spring.datasource.validation-interval=30000
|
||||
spring.datasource.test-on-borrow=true
|
||||
spring.datasource.test-on-return=false
|
||||
spring.datasource.test-while-idle=true
|
||||
spring.datasource.time-between-eviction-runs-millis=30000
|
||||
spring.datasource.min-evictable-idle-time-millis=60000
|
||||
spring.datasource.max-wait=10000
|
||||
spring.datasource.jmx-enabled=true
|
||||
@@ -7,21 +7,28 @@
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
|
||||
# DDI authentication configuration
|
||||
hawkbit.server.ddi.security.authentication.anonymous.enabled=true
|
||||
hawkbit.server.ddi.security.authentication.targettoken.enabled=false
|
||||
hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false
|
||||
hawkbit.server.ddi.security.authentication.targettoken.enabled=true
|
||||
hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=true
|
||||
|
||||
spring.profiles.active=amqp
|
||||
# Download URL generation config
|
||||
hawkbit.artifact.url.coap.enabled=false
|
||||
hawkbit.artifact.url.http.enabled=true
|
||||
hawkbit.artifact.url.http.port=8080
|
||||
hawkbit.artifact.url.https.enabled=false
|
||||
|
||||
## Vaadin configuration
|
||||
vaadin.servlet.productionMode=false
|
||||
|
||||
## Configuration for RabbitMQ integration
|
||||
## Configuration for DMF/RabbitMQ integration
|
||||
spring.profiles.active=amqp
|
||||
spring.rabbitmq.username=guest
|
||||
spring.rabbitmq.password=guest
|
||||
spring.rabbitmq.virtualHost=/
|
||||
spring.rabbitmq.host=localhost
|
||||
spring.rabbitmq.port=5672
|
||||
hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter
|
||||
hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl
|
||||
hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter
|
||||
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver
|
||||
|
||||
|
||||
32
examples/hawkbit-example-app/src/main/resources/logback.xml
Normal file
32
examples/hawkbit-example-app/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
|
||||
<logger name="org.eclipse.hawkbit.eventbus.DeadEventListener" level="WARN" />
|
||||
<Logger name="org.springframework.boot.actuate.audit.listener.AuditListener" level="WARN" />
|
||||
|
||||
<Logger name="org.hibernate.validator.internal.util.Version" level="WARN" />
|
||||
|
||||
<Logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="WARN" />
|
||||
<Logger name="org.apache.tomcat.jdbc.pool.ConnectionPool" level="DEBUG" />
|
||||
<Logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR" />
|
||||
|
||||
<!-- Security Log with hints on potential attacks -->
|
||||
<logger name="server-security" level="INFO" />
|
||||
|
||||
<Root level="INFO">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
|
||||
</configuration>
|
||||
13
examples/hawkbit-example-core-feign-client/README.md
Normal file
13
examples/hawkbit-example-core-feign-client/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Eclipse.IoT hawkBit - Example Core Feign Client
|
||||
|
||||
This modules contains core beans that are needed to create a [Feign Client](https://github.com/Netflix/feign) with hwakBit.
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-example-core-feign-client
|
||||
|
||||
```
|
||||
$ cd hawkbit/examples/hawkbit-example-core-feign-client
|
||||
$ mvn clean install
|
||||
```
|
||||
|
||||
46
examples/hawkbit-example-core-feign-client/pom.xml
Normal file
46
examples/hawkbit-example-core-feign-client/pom.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>hawkbit-example-core-feign-client</artifactId>
|
||||
<name>hawkBit-example :: Feign Core Client</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix-core</artifactId>
|
||||
<version>1.0.7.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-slf4j</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
package org.eclipse.hawkbit.feign.core.client;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.feign.core.client;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.cloud.netflix.feign.FeignClientsConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import feign.Contract;
|
||||
import feign.Feign;
|
||||
|
||||
/**
|
||||
* Spring annotated java configuration class which defines necessary beans for
|
||||
* configure the feign-client.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(Feign.class)
|
||||
@Import(FeignClientsConfiguration.class)
|
||||
public class FeignClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public ApplicationJsonRequestHeaderInterceptor jsonHeaderInterceptor() {
|
||||
return new ApplicationJsonRequestHeaderInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Contract feignContract() {
|
||||
return new IgnoreMultipleConsumersProducersSpringMvcContract();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
package org.eclipse.hawkbit.feign.core.client;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
14
examples/hawkbit-example-ddi-feign-client/README.md
Normal file
14
examples/hawkbit-example-ddi-feign-client/README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Eclipse.IoT hawkBit - Example DDI Feign Client API
|
||||
|
||||
This modules contains the declarative client binding resources of the DDI API.
|
||||
For more information see 'Feign Inheritance Support' at [Spring Cloud] (http://projects.spring.io/spring-cloud/spring-cloud.html).
|
||||
Powered by [Feign](https://github.com/Netflix/feign).
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-example-ddi-feign-client
|
||||
|
||||
```
|
||||
$ cd hawkbit/examples/hawkbit-example-ddi-feign-client
|
||||
$ mvn clean install
|
||||
```
|
||||
68
examples/hawkbit-example-ddi-feign-client/pom.xml
Normal file
68
examples/hawkbit-example-ddi-feign-client/pom.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-example-ddi-feign-client</artifactId>
|
||||
|
||||
<name>hawkBit-example :: DDI Feign Client</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix</artifactId>
|
||||
<version>1.0.7.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-example-core-feign-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ddi-dl-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ddi-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi;
|
||||
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the artifact store controller resource of the DDI-DL API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiDlRestConstants.ARTIFACTS_V1_REQUEST_MAPPING)
|
||||
public interface DdiDlArtifactStoreControllerResourceClient extends DdiDlArtifactStoreControllerRestApi {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
|
||||
import org.eclipse.hawkbit.ddi.rest.api.DdiRootControllerRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the Rootcontroller resource of the DDI API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + DdiRestConstants.BASE_V1_REQUEST_MAPPING)
|
||||
public interface RootControllerResourceClient extends DdiRootControllerRestApi {
|
||||
|
||||
}
|
||||
15
examples/hawkbit-example-mgmt-feign-client/README.md
Normal file
15
examples/hawkbit-example-mgmt-feign-client/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Eclipse.IoT hawkBit - Example Management Feign Client API
|
||||
|
||||
This modules contains the declarative client binding resources of the Management API.
|
||||
For more information see 'Feign Inheritance Support' at [Spring Cloud] (http://projects.spring.io/spring-cloud/spring-cloud.html).
|
||||
Powered by [Feign](https://github.com/Netflix/feign).
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-example-mgmt-feign-client
|
||||
|
||||
```
|
||||
$ cd hawkbit/examples/hawkbit-example-mgmt-feign-client
|
||||
$ mvn clean install
|
||||
```
|
||||
|
||||
56
examples/hawkbit-example-mgmt-feign-client/pom.xml
Normal file
56
examples/hawkbit-example-mgmt-feign-client/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>hawkbit-example-mgmt-feign-client</artifactId>
|
||||
<name>hawkBit-example :: Management client API</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-example-core-feign-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-mgmt-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -8,13 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.DistributionSetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the DistributionSet resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsets")
|
||||
public interface DistributionSetResourceClient extends DistributionSetRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
|
||||
public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi {
|
||||
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.DistributionSetTagRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the DistributionSetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettags")
|
||||
public interface DistributionSetTagResourceClient extends DistributionSetTagRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
|
||||
public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi {
|
||||
}
|
||||
@@ -8,14 +8,15 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.DistributionSetTypeRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the DistributionSetType resource of the management API.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettypes")
|
||||
public interface DistributionSetTypeResourceClient extends DistributionSetTypeRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)
|
||||
public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* A feign-client interface declaration which allows to build a feign-client
|
||||
* stub.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
|
||||
public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi {
|
||||
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleRestAPI;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the SoftwareModule resource of the management API.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremodules")
|
||||
public interface SoftwareModuleResourceClient extends SoftwareModuleRestAPI {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE)
|
||||
public interface MgmtDownloadClientResource extends MgmtDownloadRestApi {
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.RolloutRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the Rollout resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/rollouts")
|
||||
public interface RolloutResourceClient extends RolloutRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
|
||||
public interface MgmtRolloutClientResource extends MgmtRolloutRestApi {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import feign.Param;
|
||||
|
||||
/**
|
||||
* Client binding for the SoftwareModule resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
|
||||
public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi {
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts")
|
||||
ResponseEntity<MgmtArtifact> uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@Param("file") final MultipartFile file,
|
||||
@RequestParam(value = "filename", required = false) final String optionalFileName,
|
||||
@RequestParam(value = "md5sum", required = false) final String md5Sum,
|
||||
@RequestParam(value = "sha1sum", required = false) final String sha1Sum);
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.SoftwareModuleTypeRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the oftwareModuleType resource of the management API.
|
||||
* Client binding for the SoftwareModuleType resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremoduletypes")
|
||||
public interface SoftwareModuleTypeResourceClient extends SoftwareModuleTypeRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)
|
||||
public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the {@link MgmtSystemRestApi}.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING)
|
||||
public interface MgmtSystemClientResource extends MgmtSystemRestApi {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemManagementRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the {@link MgmtSystemManagementRestApi}.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SYSTEM_ADMIN_MAPPING)
|
||||
public interface MgmtSystemManagementClientResource extends MgmtSystemManagementRestApi {
|
||||
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.TargetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the Target resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targets")
|
||||
public interface TargetResourceClient extends TargetRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
|
||||
public interface MgmtTargetClientResource extends MgmtTargetRestApi {
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.api.TargetTagRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
* Client binding for the TargetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targettags")
|
||||
public interface TargetTagResourceClient extends TargetTagRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
|
||||
public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi {
|
||||
}
|
||||
@@ -11,18 +11,23 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Builder pattern for building {@link DistributionSetRequestBodyPost}.
|
||||
* Builder pattern for building {@link MgmtDistributionSetRequestBodyPost}.
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class DistributionSetBuilder {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private String type;
|
||||
private String description;
|
||||
private final List<MgmtSoftwareModuleAssigment> modules = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -34,6 +39,13 @@ public class DistributionSetBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetBuilder moduleByID(final Long id) {
|
||||
final MgmtSoftwareModuleAssigment softwareModuleAssigmentRest = new MgmtSoftwareModuleAssigment();
|
||||
softwareModuleAssigmentRest.setId(id);
|
||||
modules.add(softwareModuleAssigmentRest);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* the version of the distribution set
|
||||
@@ -55,28 +67,38 @@ public class DistributionSetBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link DistributionSetRequestBodyPost} which can directly be used to post
|
||||
* on the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link DistributionSetRequestBodyPost}
|
||||
* @param description
|
||||
* the description
|
||||
* @return the builder itself
|
||||
*/
|
||||
public List<DistributionSetRequestBodyPost> build() {
|
||||
public DistributionSetBuilder description(final String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link MgmtDistributionSetRequestBodyPost} which can directly be used to
|
||||
* post on the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link MgmtDistributionSetRequestBodyPost}
|
||||
*/
|
||||
public List<MgmtDistributionSetRequestBodyPost> build() {
|
||||
return Lists.newArrayList(doBuild(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link DistributionSetRequestBodyPost} to
|
||||
* Builds a list of multiple {@link MgmtDistributionSetRequestBodyPost} to
|
||||
* create multiple distribution sets at once. An increasing number will be
|
||||
* added to the name of the distribution set. The version and type will
|
||||
* remain the same.
|
||||
*
|
||||
* @param count
|
||||
* the amount of distribution sets body which should be created
|
||||
* @return a list of {@link DistributionSetRequestBodyPost}
|
||||
* @return a list of {@link MgmtDistributionSetRequestBodyPost}
|
||||
*/
|
||||
public List<DistributionSetRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<DistributionSetRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
public List<MgmtDistributionSetRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<MgmtDistributionSetRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(name + index));
|
||||
}
|
||||
@@ -84,11 +106,13 @@ public class DistributionSetBuilder {
|
||||
return bodyList;
|
||||
}
|
||||
|
||||
private DistributionSetRequestBodyPost doBuild(final String prefixName) {
|
||||
final DistributionSetRequestBodyPost body = new DistributionSetRequestBodyPost();
|
||||
private MgmtDistributionSetRequestBodyPost doBuild(final String prefixName) {
|
||||
final MgmtDistributionSetRequestBodyPost body = new MgmtDistributionSetRequestBodyPost();
|
||||
body.setName(prefixName);
|
||||
body.setVersion(version);
|
||||
body.setType(type);
|
||||
body.setDescription(description);
|
||||
body.setModules(modules);
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -11,22 +11,25 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeAssigmentRest;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link DistributionSetTypeRequestBodyPost}.
|
||||
* Builder pattern for building {@link MgmtDistributionSetTypeRequestBodyPost}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class DistributionSetTypeBuilder {
|
||||
|
||||
private String key;
|
||||
private String name;
|
||||
private final List<SoftwareModuleTypeAssigmentRest> mandatorymodules = Lists.newArrayList();
|
||||
private final List<SoftwareModuleTypeAssigmentRest> optionalmodules = Lists.newArrayList();
|
||||
private String description;
|
||||
private final List<MgmtSoftwareModuleTypeAssigment> mandatorymodules = Lists.newArrayList();
|
||||
private final List<MgmtSoftwareModuleTypeAssigment> optionalmodules = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* @param key
|
||||
@@ -48,6 +51,16 @@ public class DistributionSetTypeBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description
|
||||
* @return the builder itself
|
||||
*/
|
||||
public DistributionSetTypeBuilder description(final String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param softwareModuleTypeIds
|
||||
* the IDs of the software module types which should be mandatory
|
||||
@@ -56,7 +69,7 @@ public class DistributionSetTypeBuilder {
|
||||
*/
|
||||
public DistributionSetTypeBuilder mandatorymodules(final Long... softwareModuleTypeIds) {
|
||||
for (final Long id : softwareModuleTypeIds) {
|
||||
final SoftwareModuleTypeAssigmentRest softwareModuleTypeAssigmentRest = new SoftwareModuleTypeAssigmentRest();
|
||||
final MgmtSoftwareModuleTypeAssigment softwareModuleTypeAssigmentRest = new MgmtSoftwareModuleTypeAssigment();
|
||||
softwareModuleTypeAssigmentRest.setId(id);
|
||||
this.mandatorymodules.add(softwareModuleTypeAssigmentRest);
|
||||
}
|
||||
@@ -72,7 +85,7 @@ public class DistributionSetTypeBuilder {
|
||||
*/
|
||||
public DistributionSetTypeBuilder optionalmodules(final Long... softwareModuleTypeIds) {
|
||||
for (final Long id : softwareModuleTypeIds) {
|
||||
final SoftwareModuleTypeAssigmentRest softwareModuleTypeAssigmentRest = new SoftwareModuleTypeAssigmentRest();
|
||||
final MgmtSoftwareModuleTypeAssigment softwareModuleTypeAssigmentRest = new MgmtSoftwareModuleTypeAssigment();
|
||||
softwareModuleTypeAssigmentRest.setId(id);
|
||||
this.optionalmodules.add(softwareModuleTypeAssigmentRest);
|
||||
}
|
||||
@@ -81,28 +94,29 @@ public class DistributionSetTypeBuilder {
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link DistributionSetTypeRequestBodyPost} which can directly be used in
|
||||
* the RESTful-API.
|
||||
* {@link MgmtDistributionSetTypeRequestBodyPost} which can directly be used
|
||||
* in the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link DistributionSetTypeRequestBodyPost}
|
||||
* @return a single entry list of
|
||||
* {@link MgmtDistributionSetTypeRequestBodyPost}
|
||||
*/
|
||||
public List<DistributionSetTypeRequestBodyPost> build() {
|
||||
public List<MgmtDistributionSetTypeRequestBodyPost> build() {
|
||||
return Lists.newArrayList(doBuild(name, key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link DistributionSetTypeRequestBodyPost} to
|
||||
* create multiple distribution set types at once. An increasing number will
|
||||
* be added to the name and key of the distribution set type. The optional
|
||||
* and mandatory software module types will remain the same.
|
||||
* Builds a list of multiple {@link MgmtDistributionSetTypeRequestBodyPost}
|
||||
* to create multiple distribution set types at once. An increasing number
|
||||
* will be added to the name and key of the distribution set type. The
|
||||
* optional and mandatory software module types will remain the same.
|
||||
*
|
||||
* @param count
|
||||
* the amount of distribution sets type body which should be
|
||||
* created
|
||||
* @return a list of {@link DistributionSetTypeRequestBodyPost}
|
||||
* @return a list of {@link MgmtDistributionSetTypeRequestBodyPost}
|
||||
*/
|
||||
public List<DistributionSetTypeRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<DistributionSetTypeRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
public List<MgmtDistributionSetTypeRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<MgmtDistributionSetTypeRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(name + index, key + index));
|
||||
}
|
||||
@@ -110,10 +124,11 @@ public class DistributionSetTypeBuilder {
|
||||
|
||||
}
|
||||
|
||||
private DistributionSetTypeRequestBodyPost doBuild(final String prefixName, final String prefixKey) {
|
||||
final DistributionSetTypeRequestBodyPost body = new DistributionSetTypeRequestBodyPost();
|
||||
private MgmtDistributionSetTypeRequestBodyPost doBuild(final String prefixName, final String prefixKey) {
|
||||
final MgmtDistributionSetTypeRequestBodyPost body = new MgmtDistributionSetTypeRequestBodyPost();
|
||||
body.setKey(prefixKey);
|
||||
body.setName(prefixName);
|
||||
body.setDescription(description);
|
||||
body.setMandatorymodules(mandatorymodules);
|
||||
body.setOptionalmodules(optionalmodules);
|
||||
return body;
|
||||
@@ -8,15 +8,17 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutCondition;
|
||||
import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutCondition.Condition;
|
||||
import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition.Condition;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutRestRequestBody;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link RolloutRestRequestBody}.
|
||||
* Builder pattern for building {@link MgmtRolloutRestRequestBody}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class RolloutBuilder {
|
||||
|
||||
private String name;
|
||||
@@ -25,6 +27,7 @@ public class RolloutBuilder {
|
||||
private long distributionSetId;
|
||||
private String successThreshold;
|
||||
private String errorThreshold;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -57,6 +60,16 @@ public class RolloutBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutBuilder description(final String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param distributionSetId
|
||||
* the ID of the distribution set to assign to the target in the
|
||||
@@ -95,18 +108,19 @@ public class RolloutBuilder {
|
||||
*
|
||||
* @return the rest request body for creating a rollout
|
||||
*/
|
||||
public RolloutRestRequestBody build() {
|
||||
public MgmtRolloutRestRequestBody build() {
|
||||
return doBuild();
|
||||
}
|
||||
|
||||
private RolloutRestRequestBody doBuild() {
|
||||
final RolloutRestRequestBody body = new RolloutRestRequestBody();
|
||||
private MgmtRolloutRestRequestBody doBuild() {
|
||||
final MgmtRolloutRestRequestBody body = new MgmtRolloutRestRequestBody();
|
||||
body.setName(name);
|
||||
body.setAmountGroups(groupSize);
|
||||
body.setTargetFilterQuery(targetFilterQuery);
|
||||
body.setDistributionSetId(distributionSetId);
|
||||
body.setSuccessCondition(new RolloutCondition(Condition.THRESHOLD, successThreshold));
|
||||
body.setErrorCondition(new RolloutCondition(Condition.THRESHOLD, errorThreshold));
|
||||
body.setDescription(description);
|
||||
body.setSuccessCondition(new MgmtRolloutCondition(Condition.THRESHOLD, successThreshold));
|
||||
body.setErrorCondition(new MgmtRolloutCondition(Condition.THRESHOLD, errorThreshold));
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,15 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleAssigmentRest}.
|
||||
* Builder pattern for building {@link MgmtSoftwareModuleAssigment}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class SoftwareModuleAssigmentBuilder {
|
||||
|
||||
private final List<Long> ids;
|
||||
@@ -37,15 +39,15 @@ public class SoftwareModuleAssigmentBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of {@link SoftwareModuleAssigmentRest}
|
||||
* Builds a list with a single entry of {@link MgmtSoftwareModuleAssigment}
|
||||
* which can directly be used in the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link SoftwareModuleAssigmentRest}
|
||||
* @return a single entry list of {@link MgmtSoftwareModuleAssigment}
|
||||
*/
|
||||
public List<SoftwareModuleAssigmentRest> build() {
|
||||
final List<SoftwareModuleAssigmentRest> softwareModuleAssigmentRestList = new ArrayList<>();
|
||||
public List<MgmtSoftwareModuleAssigment> build() {
|
||||
final List<MgmtSoftwareModuleAssigment> softwareModuleAssigmentRestList = new ArrayList<>();
|
||||
for (final Long id : ids) {
|
||||
final SoftwareModuleAssigmentRest softwareModuleAssigmentRest = new SoftwareModuleAssigmentRest();
|
||||
final MgmtSoftwareModuleAssigment softwareModuleAssigmentRest = new MgmtSoftwareModuleAssigment();
|
||||
softwareModuleAssigmentRest.setId(id);
|
||||
softwareModuleAssigmentRestList.add(softwareModuleAssigmentRest);
|
||||
}
|
||||
@@ -11,21 +11,25 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||
* Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class SoftwareModuleBuilder {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
private String type;
|
||||
private String vendor;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
@@ -59,28 +63,48 @@ public class SoftwareModuleBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link SoftwareModuleRequestBodyPost} which can directly be used in the
|
||||
* RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link SoftwareModuleRequestBodyPost}
|
||||
* @param vendor
|
||||
* the vendor
|
||||
* @return the builder itself
|
||||
*/
|
||||
public List<SoftwareModuleRequestBodyPost> build() {
|
||||
public SoftwareModuleBuilder vendor(final String vendor) {
|
||||
this.vendor = vendor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description
|
||||
* @return the builder itself
|
||||
*/
|
||||
public SoftwareModuleBuilder description(final String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link MgmtSoftwareModuleRequestBodyPost} which can directly be used in
|
||||
* the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link MgmtSoftwareModuleRequestBodyPost}
|
||||
*/
|
||||
public List<MgmtSoftwareModuleRequestBodyPost> build() {
|
||||
return Lists.newArrayList(doBuild(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link SoftwareModuleRequestBodyPost} to create
|
||||
* multiple software module at once. An increasing number will be added to
|
||||
* the name of the software module. The version and type will remain the
|
||||
* same.
|
||||
* Builds a list of multiple {@link MgmtSoftwareModuleRequestBodyPost} to
|
||||
* create multiple software module at once. An increasing number will be
|
||||
* added to the name of the software module. The version and type will
|
||||
* remain the same.
|
||||
*
|
||||
* @param count
|
||||
* the amount of software module body which should be created
|
||||
* @return a list of {@link DistributionSetTypeRequestBodyPost}
|
||||
* @return a list of {@link MgmtDistributionSetTypeRequestBodyPost}
|
||||
*/
|
||||
public List<SoftwareModuleRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<SoftwareModuleRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
public List<MgmtSoftwareModuleRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<MgmtSoftwareModuleRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(name + index));
|
||||
}
|
||||
@@ -88,11 +112,13 @@ public class SoftwareModuleBuilder {
|
||||
return bodyList;
|
||||
}
|
||||
|
||||
private SoftwareModuleRequestBodyPost doBuild(final String prefixName) {
|
||||
final SoftwareModuleRequestBodyPost body = new SoftwareModuleRequestBodyPost();
|
||||
private MgmtSoftwareModuleRequestBodyPost doBuild(final String prefixName) {
|
||||
final MgmtSoftwareModuleRequestBodyPost body = new MgmtSoftwareModuleRequestBodyPost();
|
||||
body.setName(prefixName);
|
||||
body.setVersion(version);
|
||||
body.setType(type);
|
||||
body.setVendor(vendor);
|
||||
body.setDescription(description);
|
||||
return body;
|
||||
}
|
||||
|
||||
@@ -11,16 +11,18 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||
* Builder pattern for building {@link MgmtSoftwareModuleRequestBodyPost}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class SoftwareModuleTypeBuilder {
|
||||
|
||||
private String key;
|
||||
@@ -60,35 +62,36 @@ public class SoftwareModuleTypeBuilder {
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of
|
||||
* {@link SoftwareModuleTypeRequestBodyPost} which can directly be used in
|
||||
* the RESTful-API.
|
||||
* {@link MgmtSoftwareModuleTypeRequestBodyPost} which can directly be used
|
||||
* in the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link SoftwareModuleTypeRequestBodyPost}
|
||||
* @return a single entry list of
|
||||
* {@link MgmtSoftwareModuleTypeRequestBodyPost}
|
||||
*/
|
||||
public List<SoftwareModuleTypeRequestBodyPost> build() {
|
||||
public List<MgmtSoftwareModuleTypeRequestBodyPost> build() {
|
||||
return Lists.newArrayList(doBuild(key, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link SoftwareModuleTypeRequestBodyPost} to
|
||||
* create multiple software module types at once. An increasing number will
|
||||
* be added to the name and key of the software module type.
|
||||
* Builds a list of multiple {@link MgmtSoftwareModuleTypeRequestBodyPost}
|
||||
* to create multiple software module types at once. An increasing number
|
||||
* will be added to the name and key of the software module type.
|
||||
*
|
||||
* @param count
|
||||
* the amount of software module type bodies which should be
|
||||
* created
|
||||
* @return a list of {@link SoftwareModuleTypeRequestBodyPost}
|
||||
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
|
||||
*/
|
||||
public List<SoftwareModuleTypeRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<SoftwareModuleTypeRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
public List<MgmtSoftwareModuleTypeRequestBodyPost> buildAsList(final int count) {
|
||||
final ArrayList<MgmtSoftwareModuleTypeRequestBodyPost> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(key + index, name + index));
|
||||
}
|
||||
return bodyList;
|
||||
}
|
||||
|
||||
private SoftwareModuleTypeRequestBodyPost doBuild(final String prefixKey, final String prefixName) {
|
||||
final SoftwareModuleTypeRequestBodyPost body = new SoftwareModuleTypeRequestBodyPost();
|
||||
private MgmtSoftwareModuleTypeRequestBodyPost doBuild(final String prefixKey, final String prefixName) {
|
||||
final MgmtSoftwareModuleTypeRequestBodyPost body = new MgmtSoftwareModuleTypeRequestBodyPost();
|
||||
body.setKey(prefixKey);
|
||||
body.setName(prefixName);
|
||||
body.setDescription(description);
|
||||
@@ -11,14 +11,16 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Builder pattern for building {@link TagRequestBodyPut}.
|
||||
* Builder pattern for building {@link MgmtTagRequestBodyPut}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class TagBuilder {
|
||||
|
||||
private String name;
|
||||
@@ -56,26 +58,26 @@ public class TagBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of {@link TagRequestBodyPut} which can
|
||||
* directly be used in the RESTful-API.
|
||||
* Builds a list with a single entry of {@link MgmtTagRequestBodyPut} which
|
||||
* can directly be used in the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link TagRequestBodyPut}
|
||||
* @return a single entry list of {@link MgmtTagRequestBodyPut}
|
||||
*/
|
||||
public List<TagRequestBodyPut> build() {
|
||||
public List<MgmtTagRequestBodyPut> build() {
|
||||
return Lists.newArrayList(doBuild(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link TagRequestBodyPut} to create multiple
|
||||
* tags at once. An increasing number will be added to the name of the tag.
|
||||
* The color and description will remain the same.
|
||||
* Builds a list of multiple {@link MgmtTagRequestBodyPut} to create
|
||||
* multiple tags at once. An increasing number will be added to the name of
|
||||
* the tag. The color and description will remain the same.
|
||||
*
|
||||
* @param count
|
||||
* the amount of distribution sets body which should be created
|
||||
* @return a list of {@link TagRequestBodyPut}
|
||||
* @return a list of {@link MgmtTagRequestBodyPut}
|
||||
*/
|
||||
public List<TagRequestBodyPut> buildAsList(final int count) {
|
||||
final ArrayList<TagRequestBodyPut> bodyList = Lists.newArrayList();
|
||||
public List<MgmtTagRequestBodyPut> buildAsList(final int count) {
|
||||
final ArrayList<MgmtTagRequestBodyPut> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(name + index));
|
||||
}
|
||||
@@ -83,8 +85,8 @@ public class TagBuilder {
|
||||
return bodyList;
|
||||
}
|
||||
|
||||
private TagRequestBodyPut doBuild(final String prefixName) {
|
||||
final TagRequestBodyPut body = new TagRequestBodyPut();
|
||||
private MgmtTagRequestBodyPut doBuild(final String prefixName) {
|
||||
final MgmtTagRequestBodyPut body = new MgmtTagRequestBodyPut();
|
||||
body.setName(prefixName);
|
||||
body.setDescription(description);
|
||||
body.setColour(color);
|
||||
@@ -11,16 +11,18 @@ package org.eclipse.hawkbit.mgmt.client.resource.builder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link TargetRequestBody}.
|
||||
* Builder pattern for building {@link MgmtTargetRequestBody}.
|
||||
*
|
||||
*/
|
||||
// Exception squid:S1701 - builder pattern
|
||||
@SuppressWarnings({ "squid:S1701" })
|
||||
public class TargetBuilder {
|
||||
|
||||
private String controllerId;
|
||||
@@ -58,35 +60,35 @@ public class TargetBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list with a single entry of {@link TargetRequestBody} which can
|
||||
* directly be used in the RESTful-API.
|
||||
* Builds a list with a single entry of {@link MgmtTargetRequestBody} which
|
||||
* can directly be used in the RESTful-API.
|
||||
*
|
||||
* @return a single entry list of {@link TargetRequestBody}
|
||||
* @return a single entry list of {@link MgmtTargetRequestBody}
|
||||
*/
|
||||
public List<TargetRequestBody> build() {
|
||||
public List<MgmtTargetRequestBody> build() {
|
||||
return Lists.newArrayList(doBuild(controllerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of multiple {@link TargetRequestBody} to create multiple
|
||||
* targets at once. An increasing number will be added to the controllerId
|
||||
* of the target. The name and description will remain.
|
||||
* Builds a list of multiple {@link MgmtTargetRequestBody} to create
|
||||
* multiple targets at once. An increasing number will be added to the
|
||||
* controllerId of the target. The name and description will remain.
|
||||
*
|
||||
* @param count
|
||||
* the amount of software module type bodies which should be
|
||||
* created
|
||||
* @return a list of {@link SoftwareModuleTypeRequestBodyPost}
|
||||
* @return a list of {@link MgmtSoftwareModuleTypeRequestBodyPost}
|
||||
*/
|
||||
public List<TargetRequestBody> buildAsList(final int count) {
|
||||
final ArrayList<TargetRequestBody> bodyList = Lists.newArrayList();
|
||||
public List<MgmtTargetRequestBody> buildAsList(final int count) {
|
||||
final ArrayList<MgmtTargetRequestBody> bodyList = Lists.newArrayList();
|
||||
for (int index = 0; index < count; index++) {
|
||||
bodyList.add(doBuild(controllerId + index));
|
||||
}
|
||||
return bodyList;
|
||||
}
|
||||
|
||||
private TargetRequestBody doBuild(final String prefixControllerId) {
|
||||
final TargetRequestBody body = new TargetRequestBody();
|
||||
private MgmtTargetRequestBody doBuild(final String prefixControllerId) {
|
||||
final MgmtTargetRequestBody body = new MgmtTargetRequestBody();
|
||||
body.setControllerId(prefixControllerId);
|
||||
body.setName(name);
|
||||
body.setDescription(description);
|
||||
4
examples/hawkbit-example-mgmt-simulator/.gitignore
vendored
Normal file
4
examples/hawkbit-example-mgmt-simulator/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/target/
|
||||
/bin/
|
||||
/.apt_generated/
|
||||
/.springBeans
|
||||
@@ -1,6 +1,6 @@
|
||||
# hawkBit Management API example client
|
||||
# Eclipse.IoT hawkBit - Example Management Feign Client
|
||||
|
||||
Example client that shows how to efficiently use the hawkBit management API.
|
||||
Example Spring Boot client that shows how to efficiently use the hawkBit Example Management Feign Client and the hawkBit Management API.
|
||||
|
||||
Powered by [Feign](https://github.com/Netflix/feign).
|
||||
|
||||
@@ -10,13 +10,13 @@ Run getting started example
|
||||
|
||||
|
||||
|
||||
$ java -jar hawkbit-mgmt-api-client-#version#.jar
|
||||
$ java -jar hawkbit-example-mgmt-simulator-#version#.jar
|
||||
|
||||
|
||||
Run create and start rollout example
|
||||
|
||||
|
||||
$ java -jar hawkbit-mgmt-api-client-#version#.jar --createrollout
|
||||
$ java -jar hawkbit-example-mgmt-simulator-#version#.jar --createrollout
|
||||
|
||||
|
||||
## This example shows
|
||||
@@ -28,7 +28,7 @@ In getting started example:
|
||||
* creating software modules
|
||||
* assigning software modules to distribution sets
|
||||
|
||||
In rollout mode:
|
||||
In create rollout example:
|
||||
* creating software modules type
|
||||
* creating distribution set type
|
||||
* creating distribution sets
|
||||
@@ -17,8 +17,8 @@
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>hawkbit-mgmt-api-client</artifactId>
|
||||
<name>hawkBit Management API example client</name>
|
||||
<artifactId>hawkbit-example-mgmt-simulator</artifactId>
|
||||
<name>hawkBit-example :: Management feign client simulator</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -57,14 +57,20 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-rest-api</artifactId>
|
||||
<artifactId>hawkbit-example-mgmt-feign-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
<version>8.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
@@ -82,11 +88,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0-rc2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
@@ -8,22 +8,28 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
|
||||
import org.eclipse.hawkbit.feign.core.client.FeignClientConfiguration;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.CreateStartedRolloutExample;
|
||||
import org.eclipse.hawkbit.mgmt.client.scenarios.GettingStartedDefaultScenario;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import feign.Contract;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
@EnableConfigurationProperties(ClientConfigurationProperties.class)
|
||||
@Configuration
|
||||
@AutoConfigureAfter(FeignClientConfiguration.class)
|
||||
@Import(FeignClientConfiguration.class)
|
||||
public class Application implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
@@ -57,13 +63,13 @@ public class Application implements CommandLineRunner {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationJsonRequestHeaderInterceptor jsonHeaderInterceptor() {
|
||||
return new ApplicationJsonRequestHeaderInterceptor();
|
||||
public GettingStartedDefaultScenario gettingStartedDefaultScenario() {
|
||||
return new GettingStartedDefaultScenario();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Contract feignContract() {
|
||||
return new IgnoreMultipleConsumersProducersSpringMvcContract();
|
||||
public CreateStartedRolloutExample createStartedRolloutExample() {
|
||||
return new CreateStartedRolloutExample();
|
||||
}
|
||||
|
||||
private boolean containsArg(final String containsArg, final String... args) {
|
||||
@@ -10,12 +10,12 @@ package org.eclipse.hawkbit.mgmt.client.scenarios;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.RolloutResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.TargetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtRolloutClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.RolloutBuilder;
|
||||
@@ -23,18 +23,16 @@ import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentB
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.TargetBuilder;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutResponseBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Example for creating and starting a Rollout.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class CreateStartedRolloutExample {
|
||||
|
||||
/* known software module type name and key */
|
||||
@@ -44,22 +42,22 @@ public class CreateStartedRolloutExample {
|
||||
private static final String DS_MODULE_TYPE = SM_MODULE_TYPE;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
private MgmtDistributionSetClientResource distributionSetResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleResourceClient softwareModuleResource;
|
||||
private MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
@Autowired
|
||||
private TargetResourceClient targetResource;
|
||||
private MgmtTargetClientResource targetResource;
|
||||
|
||||
@Autowired
|
||||
private RolloutResourceClient rolloutResource;
|
||||
private MgmtRolloutClientResource rolloutResource;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTypeResourceClient distributionSetTypeResource;
|
||||
private MgmtDistributionSetTypeClientResource distributionSetTypeResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleTypeResourceClient softwareModuleTypeResource;
|
||||
private MgmtSoftwareModuleTypeClientResource softwareModuleTypeResource;
|
||||
|
||||
/**
|
||||
* Run the Rollout scenario.
|
||||
@@ -67,7 +65,7 @@ public class CreateStartedRolloutExample {
|
||||
public void run() {
|
||||
|
||||
// create three SoftwareModuleTypes
|
||||
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
final List<MgmtSoftwareModuleType> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||
.maxAssignments(1).build())
|
||||
.getBody();
|
||||
@@ -78,12 +76,12 @@ public class CreateStartedRolloutExample {
|
||||
.getBody();
|
||||
|
||||
// create one DistributionSet
|
||||
final List<DistributionSetRest> distributionSetsRest = distributionSetResource.createDistributionSets(
|
||||
final List<MgmtDistributionSet> distributionSetsRest = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name("rollout-example").version("1.0.0").type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
// create three SoftwareModules
|
||||
final List<SoftwareModuleRest> softwareModulesRest = softwareModuleResource
|
||||
final List<MgmtSoftwareModule> softwareModulesRest = softwareModuleResource
|
||||
.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name("firmware").version("1.0.0").type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
@@ -97,7 +95,7 @@ public class CreateStartedRolloutExample {
|
||||
.description("Targets used for rollout example").buildAsList(10));
|
||||
|
||||
// create a Rollout
|
||||
final RolloutResponseBody rolloutResponseBody = rolloutResource
|
||||
final MgmtRolloutResponseBody rolloutResponseBody = rolloutResource
|
||||
.create(new RolloutBuilder().name("MyRollout").groupSize(2).targetFilterQuery("name==00-FF-AA-0*")
|
||||
.distributionSetId(distributionSetsRest.get(0).getDsId()).successThreshold("80")
|
||||
.errorThreshold("50").build())
|
||||
@@ -10,29 +10,27 @@ package org.eclipse.hawkbit.mgmt.client.scenarios;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* Default getting started scenario.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class GettingStartedDefaultScenario {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GettingStartedDefaultScenario.class);
|
||||
@@ -50,16 +48,16 @@ public class GettingStartedDefaultScenario {
|
||||
private static final String DS_EXAMPLE_NAME = SM_EXAMPLE_NAME;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
private MgmtDistributionSetClientResource distributionSetResource;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTypeResourceClient distributionSetTypeResource;
|
||||
private MgmtDistributionSetTypeClientResource distributionSetTypeResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleResourceClient softwareModuleResource;
|
||||
private MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleTypeResourceClient softwareModuleTypeResource;
|
||||
private MgmtSoftwareModuleTypeClientResource softwareModuleTypeResource;
|
||||
|
||||
/**
|
||||
* Run the default getting started scenario.
|
||||
@@ -70,7 +68,7 @@ public class GettingStartedDefaultScenario {
|
||||
|
||||
// create one SoftwareModuleTypes
|
||||
LOGGER.info("Creating software module type {}", SM_MODULE_TYPE);
|
||||
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
final List<MgmtSoftwareModuleType> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||
.maxAssignments(1).build())
|
||||
.getBody();
|
||||
@@ -86,17 +84,17 @@ public class GettingStartedDefaultScenario {
|
||||
final String dsVersion3 = "2.1.0";
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion1);
|
||||
final List<DistributionSetRest> distributionSetsRest1 = distributionSetResource.createDistributionSets(
|
||||
final List<MgmtDistributionSet> distributionSetsRest1 = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion1).type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion2);
|
||||
final List<DistributionSetRest> distributionSetsRest2 = distributionSetResource.createDistributionSets(
|
||||
final List<MgmtDistributionSet> distributionSetsRest2 = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion2).type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion3);
|
||||
final List<DistributionSetRest> distributionSetsRest3 = distributionSetResource.createDistributionSets(
|
||||
final List<MgmtDistributionSet> distributionSetsRest3 = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion3).type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
@@ -106,15 +104,15 @@ public class GettingStartedDefaultScenario {
|
||||
final String swVersion3 = "3";
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion1);
|
||||
final List<SoftwareModuleRest> softwareModulesRest1 = softwareModuleResource.createSoftwareModules(
|
||||
final List<MgmtSoftwareModule> softwareModulesRest1 = softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion1).type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion2);
|
||||
final List<SoftwareModuleRest> softwareModulesRest2 = softwareModuleResource.createSoftwareModules(
|
||||
final List<MgmtSoftwareModule> softwareModulesRest2 = softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion2).type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion3);
|
||||
final List<SoftwareModuleRest> softwareModulesRest3 = softwareModuleResource.createSoftwareModules(
|
||||
final List<MgmtSoftwareModule> softwareModulesRest3 = softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion3).type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
@@ -19,13 +18,45 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<name>hawkBit :: Examples Parent</name>
|
||||
<name>hawkBit-example :: Parent</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>hawkbit-device-simulator</module>
|
||||
<module>hawkbit-example-app</module>
|
||||
<module>hawkbit-mgmt-api-client</module>
|
||||
</modules>
|
||||
<module>hawkbit-example-core-feign-client</module>
|
||||
<module>hawkbit-example-ddi-feign-client</module>
|
||||
<module>hawkbit-example-mgmt-feign-client</module>
|
||||
<module>hawkbit-example-mgmt-simulator</module>
|
||||
</modules>
|
||||
|
||||
|
||||
<properties>
|
||||
<feign.version>8.14.2</feign.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
<!-- <version>8.16.0</version> -->
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
<!-- <version>8.16.0</version> -->
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-slf4j</artifactId>
|
||||
<version>${feign.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
@@ -8,11 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.artifact.repository;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -121,8 +124,10 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
try {
|
||||
LOGGER.debug("storing file {} of content {}", filename, contentType);
|
||||
tempFile = File.createTempFile("uploadFile", null);
|
||||
try (final FileOutputStream os = new FileOutputStream(tempFile)) {
|
||||
return store(content, contentType, os, tempFile, hash);
|
||||
try (final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
|
||||
try (BufferedInputStream bis = new BufferedInputStream(content)) {
|
||||
return store(bis, contentType, bos, tempFile, hash);
|
||||
}
|
||||
}
|
||||
} catch (final IOException | MongoException e1) {
|
||||
throw new ArtifactStoreException(e1.getMessage(), e1);
|
||||
@@ -162,7 +167,7 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
|
||||
}
|
||||
|
||||
private DbArtifact store(final InputStream content, final String contentType, final FileOutputStream os,
|
||||
private DbArtifact store(final InputStream content, final String contentType, final OutputStream os,
|
||||
final File tempFile, final DbArtifactHash hash) {
|
||||
final GridFsArtifact storedArtifact;
|
||||
try {
|
||||
@@ -185,7 +190,8 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
throw new ArtifactStoreException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (hash != null && hash.getMd5() != null && !storedArtifact.getHashes().getMd5().equals(hash.getMd5())) {
|
||||
if (hash != null && hash.getMd5() != null
|
||||
&& !storedArtifact.getHashes().getMd5().equalsIgnoreCase(hash.getMd5())) {
|
||||
throw new HashNotMatchException("The given md5 hash " + hash.getMd5()
|
||||
+ " not matching the calculated md5 hash " + storedArtifact.getHashes().getMd5(),
|
||||
HashNotMatchException.MD5);
|
||||
@@ -195,14 +201,17 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
|
||||
}
|
||||
|
||||
private static String computeSHA1Hash(final InputStream stream, final FileOutputStream os,
|
||||
final String providedSHA1Sum) throws NoSuchAlgorithmException, IOException {
|
||||
private static String computeSHA1Hash(final InputStream stream, final OutputStream os, final String providedSHA1Sum)
|
||||
throws NoSuchAlgorithmException, IOException {
|
||||
String sha1Hash;
|
||||
// compute digest
|
||||
// Exception squid:S2070 - not used for hashing sensitive
|
||||
// data
|
||||
@SuppressWarnings("squid:S2070")
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
final DigestOutputStream dos = new DigestOutputStream(os, md);
|
||||
ByteStreams.copy(stream, dos);
|
||||
dos.close();
|
||||
try (final DigestOutputStream dos = new DigestOutputStream(os, md)) {
|
||||
ByteStreams.copy(stream, dos);
|
||||
}
|
||||
sha1Hash = BaseEncoding.base16().lowerCase().encode(md.digest());
|
||||
if (providedSHA1Sum != null && !providedSHA1Sum.equalsIgnoreCase(sha1Hash)) {
|
||||
throw new HashNotMatchException(
|
||||
|
||||
@@ -71,6 +71,8 @@ public class MongoConfiguration extends AbstractMongoConfiguration {
|
||||
@Override
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
// Closed by pre-destroy
|
||||
@SuppressWarnings({ "squid:S2095" })
|
||||
public Mongo mongo() throws UnknownHostException {
|
||||
final MongoClientURI uri = new MongoClientURI(properties.getUri(), createBuilderOutOfOptions(options));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository</artifactId>
|
||||
<artifactId>hawkbit-repository-jpa</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
@@ -64,7 +64,13 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-rest-resource</artifactId>
|
||||
<artifactId>hawkbit-ddi-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-mgmt-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.concurrent.Executor;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.EventBusSubscriberProcessor;
|
||||
import org.eclipse.hawkbit.eventbus.EventSubscriber;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.autoconfigure.repository;
|
||||
|
||||
import org.eclipse.hawkbit.EnableJpaRepository;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Auto-Configuration for enabling the REST-Resources.
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableJpaRepository.class })
|
||||
@Import({ EnableJpaRepository.class })
|
||||
public class JpaRepositoryAutoConfiguration {
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ import org.eclipse.hawkbit.im.authentication.PermissionService;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
|
||||
import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter;
|
||||
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
|
||||
import org.eclipse.hawkbit.security.DdiSecurityProperties;
|
||||
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
|
||||
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.im.authentication.TenantUserPasswordAuthenticationToken;
|
||||
import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||
import org.eclipse.hawkbit.security.ControllerTenantAwareAuthenticationDetailsSource;
|
||||
import org.eclipse.hawkbit.security.DdiSecurityProperties;
|
||||
import org.eclipse.hawkbit.security.DosFilter;
|
||||
@@ -292,8 +292,9 @@ public class SecurityManagedConfiguration {
|
||||
new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement),
|
||||
RequestHeaderAuthenticationFilter.class)
|
||||
.authorizeRequests().anyRequest().authenticated()
|
||||
.antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
||||
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**")
|
||||
.antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**")
|
||||
.hasAnyAuthority(SpPermission.SYSTEM_ADMIN)
|
||||
.antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/**")
|
||||
.hasAnyAuthority(SpPermission.SYSTEM_DIAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,19 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.autoconfigure.web;
|
||||
|
||||
import org.eclipse.hawkbit.controller.EnableDirectDeviceApi;
|
||||
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||
import org.eclipse.hawkbit.ddi.EnableDdiApi;
|
||||
import org.eclipse.hawkbit.mgmt.EnableMgmtApi;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* Auto-Configuration for enabling the REST-Resources.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableDirectDeviceApi.class, EnableRestResources.class })
|
||||
@Import({ EnableDirectDeviceApi.class, EnableRestResources.class })
|
||||
@ConditionalOnClass({ EnableDdiApi.class, EnableMgmtApi.class })
|
||||
@Import({ EnableDdiApi.class, EnableMgmtApi.class })
|
||||
public class ResourceControllerAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ hawkbit.controller.minPollingTime=00:00:30
|
||||
|
||||
|
||||
# Configuration for RabbitMQ integration
|
||||
hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter
|
||||
hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl
|
||||
hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter
|
||||
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver
|
||||
3
hawkbit-core/README.md
Normal file
3
hawkbit-core/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# hawkBit Core
|
||||
|
||||
Various internal interfaces and utility classes.
|
||||
@@ -22,11 +22,10 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
* This resource bundles using specified basenames, to resource loading. This
|
||||
* MessageSource implementation supports more than 1 properties file with the
|
||||
* same name. All properties files will be merged.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributedResourceBundleMessageSource extends ReloadableResourceBundleMessageSource {
|
||||
// Exception squid:S2387 - Follows our upper case convention
|
||||
@SuppressWarnings({ "squid:S2387" })
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DistributedResourceBundleMessageSource.class);
|
||||
private static final String PROPERTIES_SUFFIX = ".properties";
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@@ -13,7 +13,6 @@ package org.eclipse.hawkbit.api;
|
||||
* URLs to specific artifacts.
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ArtifactUrlHandler {
|
||||
|
||||
/**
|
||||
@@ -34,4 +33,11 @@ public interface ArtifactUrlHandler {
|
||||
*/
|
||||
String getUrl(String controllerId, final Long softwareModuleId, final String filename, final String sha1Hash,
|
||||
final UrlProtocol protocol);
|
||||
|
||||
/**
|
||||
* @param protocol
|
||||
* to check support for
|
||||
* @return <code>true</code> of the handler supports given protocol.
|
||||
*/
|
||||
boolean protocolSupported(UrlProtocol protocol);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties("hawkbit.artifact.url")
|
||||
public class ArtifactUrlHandlerProperties {
|
||||
private static final String DEFAULT_IP_LOCALHOST = "127.0.0.1";
|
||||
private static final String DEFAULT_PORT = "8080";
|
||||
private static final String LOCALHOST = "localhost";
|
||||
|
||||
private final Http http = new Http();
|
||||
@@ -78,6 +79,12 @@ public class ArtifactUrlHandlerProperties {
|
||||
* @return the pattern to build the URL.
|
||||
*/
|
||||
String getPattern();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the {@link ProtocolProperties} is
|
||||
* enabled.
|
||||
*/
|
||||
boolean isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,13 +93,27 @@ public class ArtifactUrlHandlerProperties {
|
||||
public static class Http implements ProtocolProperties {
|
||||
private String hostname = LOCALHOST;
|
||||
private String ip = DEFAULT_IP_LOCALHOST;
|
||||
private String port = "";
|
||||
private String port = DEFAULT_PORT;
|
||||
/**
|
||||
* An ant-URL pattern with placeholder to build the URL on. The URL can
|
||||
* have specific artifact placeholder.
|
||||
*/
|
||||
private String pattern = "{protocol}://{hostname}:{port}/{tenant}/controller/v1/{targetId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}";
|
||||
|
||||
/**
|
||||
* Enables HTTP URI generation in DDI and DMF.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
@@ -136,13 +157,27 @@ public class ArtifactUrlHandlerProperties {
|
||||
public static class Https implements ProtocolProperties {
|
||||
private String hostname = LOCALHOST;
|
||||
private String ip = DEFAULT_IP_LOCALHOST;
|
||||
private String port = "";
|
||||
private String port = DEFAULT_PORT;
|
||||
/**
|
||||
* An ant-URL pattern with placeholder to build the URL on. The URL can
|
||||
* have specific artifact placeholder.
|
||||
*/
|
||||
private String pattern = "{protocol}://{hostname}:{port}/{tenant}/controller/v1/{targetId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}";
|
||||
|
||||
/**
|
||||
* Enables HTTPS URI generation in DDI and DMF.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
@@ -193,6 +228,20 @@ public class ArtifactUrlHandlerProperties {
|
||||
*/
|
||||
private String pattern = "{protocol}://{ip}:{port}/fw/{tenant}/{targetId}/sha1/{artifactSHA1}";
|
||||
|
||||
/**
|
||||
* Enables CoAP URI generation in DMF.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
for (final Entry<String, String> entry : entrySet) {
|
||||
if (entry.getKey().equals(PORT_PLACEHOLDER)) {
|
||||
urlPattern = urlPattern.replace(":{" + entry.getKey() + "}",
|
||||
Strings.isNullOrEmpty(entry.getValue()) ? "" : ":" + entry.getValue());
|
||||
Strings.isNullOrEmpty(entry.getValue()) ? "" : (":" + entry.getValue()));
|
||||
} else {
|
||||
urlPattern = urlPattern.replace("{" + entry.getKey() + "}", entry.getValue());
|
||||
}
|
||||
@@ -84,4 +84,15 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
|
||||
return replaceMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean protocolSupported(final UrlProtocol protocol) {
|
||||
final String protocolString = protocol.name().toLowerCase();
|
||||
final ProtocolProperties properties = urlHandlerProperties.getProperties(protocolString);
|
||||
if (properties == null || properties.getPattern() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return properties.isEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,60 +30,45 @@ public enum TenantConfigurationKey {
|
||||
/**
|
||||
* boolean value {@code true} {@code false}.
|
||||
*/
|
||||
AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled",
|
||||
"hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(),
|
||||
TenantConfigurationBooleanValidator.class),
|
||||
AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled", "hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority",
|
||||
"hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(),
|
||||
TenantConfigurationStringValidator.class),
|
||||
AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority", "hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(), TenantConfigurationStringValidator.class),
|
||||
/**
|
||||
* boolean value {@code true} {@code false}.
|
||||
*/
|
||||
AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled",
|
||||
"hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(),
|
||||
TenantConfigurationBooleanValidator.class),
|
||||
AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled", "hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
|
||||
|
||||
/**
|
||||
* boolean value {@code true} {@code false}.
|
||||
*/
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled",
|
||||
"hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(),
|
||||
TenantConfigurationBooleanValidator.class),
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled", "hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
|
||||
/**
|
||||
* string value which holds the name of the security token key.
|
||||
*/
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name",
|
||||
"hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null,
|
||||
TenantConfigurationStringValidator.class),
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name", "hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null, TenantConfigurationStringValidator.class),
|
||||
|
||||
/**
|
||||
* string value which holds the actual security-key of the gateway security
|
||||
* token.
|
||||
*/
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key",
|
||||
"hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null,
|
||||
TenantConfigurationStringValidator.class),
|
||||
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key", "hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null, TenantConfigurationStringValidator.class),
|
||||
|
||||
/**
|
||||
* string value which holds the polling time interval in the format HH:mm:ss
|
||||
*/
|
||||
POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null,
|
||||
TenantConfigurationPollingDurationValidator.class),
|
||||
POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, TenantConfigurationPollingDurationValidator.class),
|
||||
|
||||
/**
|
||||
* string value which holds the polling time interval in the format HH:mm:ss
|
||||
*/
|
||||
POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null,
|
||||
TenantConfigurationPollingDurationValidator.class),
|
||||
POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null, TenantConfigurationPollingDurationValidator.class),
|
||||
|
||||
/**
|
||||
* boolean value {@code true} {@code false}.
|
||||
*/
|
||||
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled",
|
||||
Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
|
||||
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
|
||||
|
||||
private final String keyName;
|
||||
private final String defaultKeyName;
|
||||
@@ -140,8 +125,9 @@ public enum TenantConfigurationKey {
|
||||
* @return the data type of the tenant configuration value. (e.g.
|
||||
* Integer.class, String.class)
|
||||
*/
|
||||
public Class<?> getDataType() {
|
||||
return dataType;
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Class<T> getDataType() {
|
||||
return (Class<T>) dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,8 @@ public class TenantConfigurationPollingDurationValidator implements TenantConfig
|
||||
}
|
||||
|
||||
@Override
|
||||
// Exception squid:S1166 - Hide origin exception
|
||||
@SuppressWarnings({ "squid:S1166" })
|
||||
public void validate(final Object tenantConfigurationObject) {
|
||||
TenantConfigurationValidator.super.validate(tenantConfigurationObject);
|
||||
final String tenantConfigurationString = (String) tenantConfigurationObject;
|
||||
|
||||
12
hawkbit-ddi-api/README.md
Normal file
12
hawkbit-ddi-api/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Eclipse.IoT hawkBit - DDI API
|
||||
|
||||
The Direct Device Integration (DDI) API is used by devices for communicating with the HawkBit Update Server through HTTP.
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-ddi-api
|
||||
|
||||
```
|
||||
$ cd hawkbit/hawkbit-ddi-api
|
||||
$ mvn clean install
|
||||
```
|
||||
45
hawkbit-ddi-api/pom.xml
Normal file
45
hawkbit-ddi-api/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<!--
|
||||
|
||||
Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-ddi-api</artifactId>
|
||||
<name>hawkBit :: DDI API</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.hateoas</groupId>
|
||||
<artifactId>spring-hateoas</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@@ -15,16 +15,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>
|
||||
* After the SP Target has executed an action, received by a GET(URL) request it
|
||||
* reports the completion of it to the SP Server with a action status message,
|
||||
* i.e. with a PUT message to the feedback channel, i.e. PUT URL/feedback. This
|
||||
* message could be used not only at the end of execution but also as status
|
||||
* updates during a longer lasting execution period. The format of each action
|
||||
* answer message is defined below at each action. But it is expected, that the
|
||||
* contents of the message answers have all a similar structure: The content
|
||||
* starts with a generic header and additional elements. *
|
||||
* After the HawkBit Target has executed an action, received by a GET(URL)
|
||||
* request it reports the completion of it to the HawkBit Server with a action
|
||||
* status message, i.e. with a PUT message to the feedback channel, i.e. PUT
|
||||
* URL/feedback. This message could be used not only at the end of execution but
|
||||
* also as status updates during a longer lasting execution period. The format
|
||||
* of each action answer message is defined below at each action. But it is
|
||||
* expected, that the contents of the message answers have all a similar
|
||||
* structure: The content starts with a generic header and additional elements.
|
||||
* *
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
@@ -35,12 +35,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
*
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ActionFeedback {
|
||||
public class DdiActionFeedback {
|
||||
private final Long id;
|
||||
private final String time;
|
||||
|
||||
@NotNull
|
||||
private final Status status;
|
||||
private final DdiStatus status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -53,8 +53,8 @@ public class ActionFeedback {
|
||||
* is the feedback itself
|
||||
*/
|
||||
@JsonCreator
|
||||
public ActionFeedback(@JsonProperty("id") final Long id, @JsonProperty("time") final String time,
|
||||
@JsonProperty("status") final Status status) {
|
||||
public DdiActionFeedback(@JsonProperty("id") final Long id, @JsonProperty("time") final String time,
|
||||
@JsonProperty("status") final DdiStatus status) {
|
||||
this.id = id;
|
||||
this.time = time;
|
||||
this.status = status;
|
||||
@@ -68,15 +68,10 @@ public class ActionFeedback {
|
||||
return time;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
public DdiStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ActionFeedback [id=" + id + ", time=" + time + ", status=" + status + "]";
|
||||
@@ -6,72 +6,50 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash;
|
||||
import org.springframework.hateoas.ResourceSupport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Download information for all artifacts related to a specific {@link Chunk}.
|
||||
*
|
||||
* Download information for all artifacts related to a specific {@link DdiChunk}
|
||||
* .
|
||||
*/
|
||||
public class Artifact extends ResourceSupport {
|
||||
public class DdiArtifact extends ResourceSupport {
|
||||
|
||||
@NotNull
|
||||
@JsonProperty
|
||||
private String filename;
|
||||
|
||||
@JsonProperty
|
||||
private ArtifactHash hashes;
|
||||
private DdiArtifactHash hashes;
|
||||
|
||||
@JsonProperty
|
||||
private Long size;
|
||||
|
||||
/**
|
||||
* @return the hashes
|
||||
*/
|
||||
public ArtifactHash getHashes() {
|
||||
public DdiArtifactHash getHashes() {
|
||||
return hashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hashes
|
||||
* the hashes to set
|
||||
*/
|
||||
public void setHashes(final ArtifactHash hashes) {
|
||||
public void setHashes(final DdiArtifactHash hashes) {
|
||||
this.hashes = hashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName
|
||||
* the fileName to set
|
||||
*/
|
||||
public void setFilename(final String fileName) {
|
||||
filename = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size
|
||||
*/
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size
|
||||
* the size to set
|
||||
*/
|
||||
public void setSize(final Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Hashes for given Artifact.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DdiArtifactHash {
|
||||
|
||||
@JsonProperty
|
||||
private String sha1;
|
||||
|
||||
@JsonProperty
|
||||
private String md5;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public DdiArtifactHash() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Public constructor.
|
||||
*
|
||||
* @param sha1
|
||||
* @param md5
|
||||
*/
|
||||
public DdiArtifactHash(final String sha1, final String md5) {
|
||||
this.sha1 = sha1;
|
||||
this.md5 = md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sha1
|
||||
*/
|
||||
public String getSha1() {
|
||||
return sha1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the md5
|
||||
*/
|
||||
public String getMd5() {
|
||||
return md5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,53 +6,42 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Cancel action to be provided to the target.
|
||||
*
|
||||
*/
|
||||
public class Cancel {
|
||||
public class DdiCancel {
|
||||
|
||||
private final String id;
|
||||
|
||||
@NotNull
|
||||
private final CancelActionToStop cancelAction;
|
||||
private final DdiCancelActionToStop cancelAction;
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param id
|
||||
* of the {@link CancelAction}
|
||||
* of the cancel action
|
||||
* @param cancelAction
|
||||
* the action
|
||||
*/
|
||||
public Cancel(final String id, final CancelActionToStop cancelAction) {
|
||||
public DdiCancel(final String id, final DdiCancelActionToStop cancelAction) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.cancelAction = cancelAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cancelAction
|
||||
*/
|
||||
public CancelActionToStop getCancelAction() {
|
||||
public DdiCancelActionToStop getCancelAction() {
|
||||
return cancelAction;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cancel [id=" + id + ", cancelAction=" + cancelAction + "]";
|
||||
@@ -6,17 +6,14 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* The {@link Action} that has to be stopped by the target.
|
||||
*
|
||||
* The action that has to be stopped by the target.
|
||||
*/
|
||||
public class CancelActionToStop {
|
||||
public class DdiCancelActionToStop {
|
||||
|
||||
@NotNull
|
||||
private final String stopId;
|
||||
@@ -25,25 +22,17 @@ public class CancelActionToStop {
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param stopId
|
||||
* ID of the {@link Action} to be stoppedW
|
||||
* ID of the action to be stoppedW
|
||||
*/
|
||||
public CancelActionToStop(final String stopId) {
|
||||
public DdiCancelActionToStop(final String stopId) {
|
||||
super();
|
||||
this.stopId = stopId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stopId
|
||||
*/
|
||||
public String getStopId() {
|
||||
return stopId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CancelAction [stopId=" + stopId + "]";
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,20 +14,23 @@ import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Deployment chunks.
|
||||
*
|
||||
*/
|
||||
public class Chunk {
|
||||
public class DdiChunk {
|
||||
|
||||
@NotNull
|
||||
private final String part;
|
||||
private String part;
|
||||
|
||||
@NotNull
|
||||
private final String version;
|
||||
private String version;
|
||||
|
||||
@NotNull
|
||||
private final String name;
|
||||
private String name;
|
||||
|
||||
private final List<Artifact> artifacts;
|
||||
private List<DdiArtifact> artifacts;
|
||||
|
||||
public DdiChunk() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -40,9 +43,8 @@ public class Chunk {
|
||||
* of the artifact
|
||||
* @param artifacts
|
||||
* download information
|
||||
*
|
||||
*/
|
||||
public Chunk(final String part, final String version, final String name, final List<Artifact> artifacts) {
|
||||
public DdiChunk(final String part, final String version, final String name, final List<DdiArtifact> artifacts) {
|
||||
super();
|
||||
this.part = part;
|
||||
this.version = version;
|
||||
@@ -58,17 +60,11 @@ public class Chunk {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the artifacts
|
||||
*/
|
||||
public List<Artifact> getArtifacts() {
|
||||
public List<DdiArtifact> getArtifacts() {
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
@@ -6,15 +6,22 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Standard configuration for the target.
|
||||
*
|
||||
*/
|
||||
public class Config {
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DdiConfig {
|
||||
|
||||
private final Polling polling;
|
||||
@JsonProperty
|
||||
private DdiPolling polling;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -22,12 +29,16 @@ public class Config {
|
||||
* @param polling
|
||||
* configuration of the SP target
|
||||
*/
|
||||
public Config(final Polling polling) {
|
||||
public DdiConfig(final DdiPolling polling) {
|
||||
super();
|
||||
this.polling = polling;
|
||||
}
|
||||
|
||||
public Polling getPolling() {
|
||||
public DdiConfig() {
|
||||
|
||||
}
|
||||
|
||||
public DdiPolling getPolling() {
|
||||
return polling;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.controller.model;
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,9 +17,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Feedback channel for ConfigData action.
|
||||
*
|
||||
*/
|
||||
public class ConfigData extends ActionFeedback {
|
||||
public class DdiConfigData extends DdiActionFeedback {
|
||||
|
||||
@NotEmpty
|
||||
private final Map<String, String> data;
|
||||
@@ -35,28 +34,19 @@ public class ConfigData extends ActionFeedback {
|
||||
* is the feedback itself
|
||||
* @param data
|
||||
* contains the attributes.
|
||||
*
|
||||
*/
|
||||
@JsonCreator
|
||||
public ConfigData(@JsonProperty(value = "id") final Long id, @JsonProperty(value = "time") final String time,
|
||||
@JsonProperty(value = "status") final Status status,
|
||||
public DdiConfigData(@JsonProperty(value = "id") final Long id, @JsonProperty(value = "time") final String time,
|
||||
@JsonProperty(value = "status") final DdiStatus status,
|
||||
@JsonProperty(value = "data") final Map<String, String> data) {
|
||||
super(id, time, status);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data
|
||||
*/
|
||||
public Map<String, String> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigData [data=" + data + ", toString()=" + super.toString() + "]";
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user