Merge branch 'master' into
Download_server_supports_download_through_HTTP_and_HTTPs Conflicts: hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationKey.java Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -7,3 +7,7 @@
|
||||
- hawkbit.server.email.support has changed to hawkbit.server.ui.links.support
|
||||
- hawkbit.server.email.request.account has changed to hawkbit.server.ui.links.requestAccount
|
||||
- hawkbit.server.im.login.url has changed to hawkbit.server.ui.links.userManagement
|
||||
|
||||
### 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)
|
||||
|
||||
@@ -14,6 +14,11 @@ see [hawkBit Wiki](https://github.com/eclipse/hawkbit/wiki)
|
||||
* Having issues with hawkBit? Open a [GitHub issue](https://github.com/eclipse/hawkbit/issues).
|
||||
* You can also check out our [Project Homepage](https://projects.eclipse.org/projects/iot.hawkbit) for further contact options.
|
||||
|
||||
# hawkBit sandbox
|
||||
|
||||
We offer a sandbox installation that is free for everyone to try out hawkBit. However, keep in mind that the sandbox database will be reset from time to time. It is also not possible to upload any artifacts into the sandbox. But you can use it to try out the Management UI, Management API and DDI API.
|
||||
|
||||
https://hawkbit.eu-gb.mybluemix.net/UI/
|
||||
|
||||
# Compile, Run and Getting Started
|
||||
|
||||
|
||||
20
deployHawkBitSandbox.sh
Normal file
20
deployHawkBitSandbox.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# 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 script allows the deployment of the complete hawkBit sandbox including
|
||||
# data example to a cloud foundry enviroment. Expects existing CF CLI
|
||||
# installation and login to be existing already.
|
||||
|
||||
cd examples/hawkbit-example-app/target/
|
||||
cf push
|
||||
cd ../..
|
||||
java -jar hawkbit-mgmt-api-client/target/hawkbit-mgmt-api-client-0.2.0-SNAPSHOT.jar --hawkbit.url=hawkbit.eu-gb.mybluemix.net
|
||||
cd hawkbit-device-simulator/target/
|
||||
cf push
|
||||
cd ../../..
|
||||
@@ -1,7 +1,9 @@
|
||||
# Examples
|
||||
|
||||
Example projects that show how hawkBit can be used to create, run or access an hawkBit empowered update server.
|
||||
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 a Spring Boot and hawkBit based update server.
|
||||
`hawkbit-mgmt-api-client` : Example client for the hawkBit management API.
|
||||
|
||||
1
examples/hawkbit-custom-theme-example/README.md
Normal file
1
examples/hawkbit-custom-theme-example/README.md
Normal file
@@ -0,0 +1 @@
|
||||
Theme customization example for Eclipse hawkBit. See wiki for the theme customization guide.
|
||||
112
examples/hawkbit-custom-theme-example/pom.xml
Normal file
112
examples/hawkbit-custom-theme-example/pom.xml
Normal file
@@ -0,0 +1,112 @@
|
||||
<!--
|
||||
|
||||
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-custom-theme-example</artifactId>
|
||||
<name>hawkBit :: Custom Theme Example App</name>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.vaadin</groupId>
|
||||
<artifactId>vaadin-maven-plugin</artifactId>
|
||||
<version>${vaadin.plugin.version}</version>
|
||||
<configuration>
|
||||
<warSourceDirectory>src/main/resources</warSourceDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>update-theme</goal>
|
||||
<goal>compile-theme</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${baseDir}</outputDirectory>
|
||||
<addResources>false</addResources>
|
||||
<mainClass>org.eclipse.hawkbit.app.Start</mainClass>
|
||||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- Hawkbit -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-ui</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-security-integration</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-http-security</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-aspects</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.app;
|
||||
|
||||
import org.eclipse.hawkbit.ui.login.HawkbitLoginUI;
|
||||
import org.eclipse.hawkbit.ui.themes.HawkbitTheme;
|
||||
|
||||
import com.vaadin.annotations.Theme;
|
||||
import com.vaadin.annotations.Title;
|
||||
import com.vaadin.spring.annotation.SpringUI;
|
||||
|
||||
/**
|
||||
* Example hawkBit login UI implementation.
|
||||
*
|
||||
* A {@link SpringUI} annotated class must be present in the classpath for the
|
||||
* 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)
|
||||
@Title("hawkBit Theme example")
|
||||
@Theme(value = "exampletheme")
|
||||
public class MyLoginUI extends HawkbitLoginUI {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.eclipse.hawkbit.app;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.vaadin.annotations.Push;
|
||||
import com.vaadin.annotations.Theme;
|
||||
import com.vaadin.annotations.Title;
|
||||
import com.vaadin.shared.communication.PushMode;
|
||||
import com.vaadin.shared.ui.ui.Transport;
|
||||
import com.vaadin.spring.annotation.SpringUI;
|
||||
|
||||
/**
|
||||
* Example hawkBit UI implementation.
|
||||
*
|
||||
* A {@link SpringUI} annotated class must be present in the classpath. The
|
||||
* easiest way to get an hawkBit UI running is to extend the {@link HawkbitUI}
|
||||
* and to annotated it with {@link SpringUI} as in this example.
|
||||
*
|
||||
*/
|
||||
@SpringUI
|
||||
@Push(value = PushMode.AUTOMATIC, transport = Transport.WEBSOCKET)
|
||||
@Title("hawkBit Theme example")
|
||||
@Theme(value = "exampletheme")
|
||||
public class MyUI extends HawkbitUI {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus,
|
||||
final UIEventProvider provider) {
|
||||
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus, provider));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.eclipse.hawkbit.app;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
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.
|
||||
* The minimal configuration for the stand alone hawkBit server.
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@Import({ RepositoryApplicationConfiguration.class })
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
public class Start {
|
||||
|
||||
/**
|
||||
* Main method to start the spring-boot application.
|
||||
*
|
||||
* @param args
|
||||
* the VM arguments.
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Start.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/addons.scss
|
||||
/styles.css
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
$dark-gray: #848484;
|
||||
|
||||
//Example color change
|
||||
$hawkbit-primary-color: $dark-gray;
|
||||
$hawkbit-primary-color-light: #D8D8D8;
|
||||
$app-selection-item-selection-color: $dark-gray;
|
||||
$app-focus-color: $dark-gray;
|
||||
$app-selection-color: $dark-gray;
|
||||
$tag-text-color: $dark-gray;
|
||||
$tab-sheet-caption-color: $dark-gray;
|
||||
$table-details-tab-font-color: $dark-gray;
|
||||
$widget-caption-color: $dark-gray;
|
||||
$accordion-action-history-title-color: $dark-gray;
|
||||
$menu-title-bg-color: $dark-gray;
|
||||
$button-icon-color: $dark-gray;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,29 @@
|
||||
<!--
|
||||
|
||||
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
|
||||
|
||||
-->
|
||||
<head>
|
||||
<style>
|
||||
.footer-content {
|
||||
margin-top: 20px ;
|
||||
}
|
||||
.doc-link {
|
||||
color: #26547a !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<footer>
|
||||
<div class="footer-content">
|
||||
<div style="color: #333; font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.8em !important;line-height: 20px;">
|
||||
<!-- Footer text goes here -->
|
||||
<a class="doc-link" target="_blank" href="https://projects.eclipse.org/projects/iot.hawkbit">Eclipe hawkBit Project Page</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
@import "../hawkbit/customstyles/hawkbitvariables";
|
||||
@import "customstyles/examplevariables";
|
||||
@import "../hawkbit/hawkbittheme";
|
||||
@import "addons";
|
||||
|
||||
// This file prefixes all rules with the theme name to avoid causing conflicts with other themes.
|
||||
.exampletheme {
|
||||
@include addons;
|
||||
@include hawkbittheme;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# UI demo account
|
||||
hawkbit.server.ui.demo.password=admin
|
||||
hawkbit.server.ui.demo.user=admin
|
||||
hawkbit.server.ui.demo.tenant=DEFAULT
|
||||
|
||||
# UI help links
|
||||
hawkbit.server.ui.links.documentation.root=https://github.com/eclipse/hawkbit
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The device simulator handles software update commands from the update server.
|
||||
|
||||
## Run
|
||||
## Run on your own workstation
|
||||
```
|
||||
java -jar examples/hawkbit-device-simulator/target/hawkbit-device-simulator-*-SNAPSHOT.jar
|
||||
```
|
||||
@@ -11,6 +11,11 @@ Or:
|
||||
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
||||
```
|
||||
|
||||
## Deploy to cloud foundry environment
|
||||
|
||||
- Go to ```target``` subfolder.
|
||||
- Run ```cf push```
|
||||
|
||||
## Notes
|
||||
|
||||
The simulator has user authentication enabled in **cloud profile**. Default credentials:
|
||||
@@ -30,9 +35,9 @@ http://localhost:8083
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -54,12 +59,12 @@ Example: for 20 simulated devices (default)
|
||||
http://localhost:8083/start
|
||||
```
|
||||
|
||||
Example: for 10 simulated devices that start with the name prefix "activeSim":
|
||||
Example: for 10 simulated devices that start with the name prefix "activeSim":
|
||||
```
|
||||
http://localhost:8083/start?amount=10&name=activeSim
|
||||
```
|
||||
|
||||
Example: for 5 simulated devices that start with the name prefix "ddi" using the Direct Device Integration API (http):
|
||||
Example: for 5 simulated devices that start with the name prefix "ddi" using the Direct Device Integration API (http):
|
||||
```
|
||||
http://localhost:8083/start?amount=5&name=ddi?api=ddi
|
||||
```
|
||||
|
||||
22
examples/hawkbit-device-simulator/cf/manifest.yml
Normal file
22
examples/hawkbit-device-simulator/cf/manifest.yml
Normal file
@@ -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
|
||||
#
|
||||
|
||||
---
|
||||
applications:
|
||||
- name: hawkbit-simulator
|
||||
memory: 1024M
|
||||
instances: 1
|
||||
buildpack: https://github.com/cloudfoundry/java-buildpack
|
||||
path: ${project.build.finalName}.jar
|
||||
services:
|
||||
- dmf-rabbit
|
||||
env:
|
||||
SPRING_PROFILES_ACTIVE: cloud,amqp
|
||||
CF_STAGING_TIMEOUT: 15
|
||||
CF_STARTUP_TIMEOUT: 15
|
||||
@@ -42,6 +42,19 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>cf</directory>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>${project.build.directory}</targetPath>
|
||||
<includes>
|
||||
<include>manifest.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||
import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
||||
import org.eclipse.hawkbit.simulator.event.InitUpdate;
|
||||
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
|
||||
@@ -34,6 +35,9 @@ public class DeviceSimulatorUpdater {
|
||||
@Autowired
|
||||
private SpSenderService spSenderService;
|
||||
|
||||
@Autowired
|
||||
private SimulatedDeviceFactory deviceFactory;
|
||||
|
||||
@Autowired
|
||||
private EventBus eventbus;
|
||||
|
||||
@@ -58,7 +62,13 @@ public class DeviceSimulatorUpdater {
|
||||
*/
|
||||
public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
|
||||
final UpdaterCallback callback) {
|
||||
final AbstractSimulatedDevice device = repository.get(tenant, id);
|
||||
AbstractSimulatedDevice device = repository.get(tenant, id);
|
||||
|
||||
// plug and play - non existing device will be auto created
|
||||
if (device == null) {
|
||||
device = repository.add(deviceFactory.createSimulatedDevice(id, tenant, Protocol.DMF_AMQP, -1, null, null));
|
||||
}
|
||||
|
||||
device.setProgress(0.0);
|
||||
device.setSwversion(swVersion);
|
||||
eventbus.post(new InitUpdate(device));
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SimulationController {
|
||||
* number of delay in milliseconds to delay polling of DDI
|
||||
* devices
|
||||
* @param gatewayToken
|
||||
* the hawkbit-update-server gatwaytoken in case authentication
|
||||
* the hawkbit-update-server gatewaytoken in case authentication
|
||||
* is enforced in hawkbit
|
||||
* @return a response string that devices has been created
|
||||
* @throws MalformedURLException
|
||||
@@ -68,7 +68,7 @@ public class SimulationController {
|
||||
@RequestParam(value = "endpoint", defaultValue = "http://localhost:8080") final String endpoint,
|
||||
@RequestParam(value = "polldelay", defaultValue = "30") final int pollDelay,
|
||||
@RequestParam(value = "gatewaytoken", defaultValue = "") final String gatewayToken)
|
||||
throws MalformedURLException {
|
||||
throws MalformedURLException {
|
||||
|
||||
final Protocol protocol;
|
||||
switch (api.toLowerCase()) {
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* General simulator service properties.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.device.simulator")
|
||||
public class SimulationProperties {
|
||||
|
||||
/**
|
||||
* List of tenants where the simulator should auto start simulations after
|
||||
* startup.
|
||||
*/
|
||||
private final List<Autostart> autostarts = new ArrayList<>();
|
||||
|
||||
public List<Autostart> getAutostarts() {
|
||||
return this.autostarts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto start configuration for simulation setups that the simulator begins
|
||||
* after startup.
|
||||
*
|
||||
*/
|
||||
public static class Autostart {
|
||||
/**
|
||||
* Name prefix of simulated devices, followed by counter, e.g.
|
||||
* simulated0, simulated1, simulated2....
|
||||
*/
|
||||
private String name = "simulated";
|
||||
|
||||
/**
|
||||
* Amount of simulated devices.
|
||||
*/
|
||||
private int amount = 20;
|
||||
|
||||
/**
|
||||
* Tenant name for the simulation.
|
||||
*/
|
||||
@NotEmpty
|
||||
private String tenant;
|
||||
|
||||
/**
|
||||
* API for simulation.
|
||||
*/
|
||||
private Protocol api = Protocol.DMF_AMQP;
|
||||
|
||||
/**
|
||||
* Endpoint in case of DDI API based simulation.
|
||||
*/
|
||||
private String endpoint = "http://localhost:8080";
|
||||
|
||||
/**
|
||||
* Poll time in case of DDI API based simulation.
|
||||
*/
|
||||
private int pollDelay = 30;
|
||||
|
||||
/**
|
||||
* Optional gateway token for DDI API based simulation.
|
||||
*/
|
||||
private String gatewayToken = "";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(final int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public void setTenant(final String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public Protocol getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
public void setApi(final Protocol api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public void setEndpoint(final String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public int getPollDelay() {
|
||||
return pollDelay;
|
||||
}
|
||||
|
||||
public void setPollDelay(final int pollDelay) {
|
||||
this.pollDelay = pollDelay;
|
||||
}
|
||||
|
||||
public String getGatewayToken() {
|
||||
return gatewayToken;
|
||||
}
|
||||
|
||||
public void setGatewayToken(final String gatewayToken) {
|
||||
this.gatewayToken = gatewayToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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.net.URL;
|
||||
|
||||
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.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Execution of operations after startup. Set up of simulations.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SimulatorStartup implements ApplicationListener<ContextRefreshedEvent> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class);
|
||||
|
||||
@Autowired
|
||||
private SimulationProperties simulationProperties;
|
||||
|
||||
@Autowired
|
||||
private SpSenderService spSenderService;
|
||||
|
||||
@Autowired
|
||||
private DeviceSimulatorRepository repository;
|
||||
|
||||
@Autowired
|
||||
private SimulatedDeviceFactory deviceFactory;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(final ContextRefreshedEvent event) {
|
||||
simulationProperties.getAutostarts().forEach(autostart -> {
|
||||
for (int i = 0; i < autostart.getAmount(); i++) {
|
||||
final String deviceId = autostart.getName() + i;
|
||||
try {
|
||||
repository.add(deviceFactory.createSimulatedDevice(deviceId, autostart.getTenant(),
|
||||
autostart.getApi(), autostart.getPollDelay(), new URL(autostart.getEndpoint()),
|
||||
autostart.getGatewayToken()));
|
||||
} catch (final Exception e) {
|
||||
LOGGER.error("Creation of simulated device at startup failed.", e);
|
||||
}
|
||||
|
||||
spSenderService.createOrUpdateThing(autostart.getTenant(), deviceId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,7 +59,8 @@ public class AmqpConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the receiver queue from sp. Receive messages from sp.
|
||||
* Creates the receiver queue from update server for receiving message from
|
||||
* update server.
|
||||
*
|
||||
* @return the queue
|
||||
*/
|
||||
@@ -70,7 +71,7 @@ public class AmqpConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the recevier exchange. Sp send messages to this exchange.
|
||||
* Creates the receiver exchange for sending messages to update server.
|
||||
*
|
||||
* @return the exchange
|
||||
*/
|
||||
|
||||
@@ -19,26 +19,25 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.device.simulator.amqp")
|
||||
public class AmqpProperties {
|
||||
|
||||
/**
|
||||
* Queue for receiving DMF messages from update server.
|
||||
*/
|
||||
private String receiverConnectorQueueFromSp;
|
||||
private String receiverConnectorQueueFromSp = "simulator_receiver";
|
||||
|
||||
/**
|
||||
* Exchange for sending DMF messages to update server.
|
||||
*/
|
||||
private String senderForSpExchange;
|
||||
private String senderForSpExchange = "simulator.replyTo";
|
||||
|
||||
/**
|
||||
* Simulator dead letter queue.
|
||||
*/
|
||||
private String deadLetterQueue;
|
||||
private String deadLetterQueue = "simulator_deadletter";
|
||||
|
||||
/**
|
||||
* Simulator dead letter exchange.
|
||||
*/
|
||||
private String deadLetterExchange;
|
||||
private String deadLetterExchange = "simulator.deadletter";
|
||||
|
||||
public String getReceiverConnectorQueueFromSp() {
|
||||
return receiverConnectorQueueFromSp;
|
||||
|
||||
@@ -26,14 +26,11 @@ import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Handle all incoming Messages from SP.
|
||||
*
|
||||
*
|
||||
* Handle all incoming Messages from hawkBit update server.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SpReceiverService extends ReceiverService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiverService.class);
|
||||
|
||||
public static final String SOFTWARE_MODULE_FIRMWARE = "firmware";
|
||||
@@ -44,17 +41,6 @@ public class SpReceiverService extends ReceiverService {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param rabbitTemplate
|
||||
* the rabbit template
|
||||
* @param amqpProperties
|
||||
* the amqp properties
|
||||
* @param lwm2mSenderService
|
||||
* the lwm2mSenderService
|
||||
* @param spSenderService
|
||||
* the spSenderService
|
||||
* @param deviceUpdater
|
||||
* the updater service to simulate update process
|
||||
*/
|
||||
@Autowired
|
||||
public SpReceiverService(final RabbitTemplate rabbitTemplate, final AmqpProperties amqpProperties,
|
||||
@@ -62,12 +48,11 @@ public class SpReceiverService extends ReceiverService {
|
||||
super(rabbitTemplate, amqpProperties);
|
||||
this.spSenderService = spSenderService;
|
||||
this.deviceUpdater = deviceUpdater;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming Message from Queue with the property
|
||||
* (com.bosch.sp.lwm2m.connector.amqp.receiverConnectorQueueFromSp).
|
||||
* (hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp).
|
||||
*
|
||||
* @param message
|
||||
* the incoming message
|
||||
|
||||
@@ -154,6 +154,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
public void pollCounterUpdate(final NextPollCounterUpdate update) {
|
||||
final List<AbstractSimulatedDevice> devices = update.getDevices();
|
||||
this.getUI().access(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
devices.forEach(device -> {
|
||||
@@ -176,6 +177,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
||||
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());
|
||||
|
||||
@@ -7,18 +7,17 @@
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
||||
#########################################################################################
|
||||
## Configuration for RabbitMQ communication
|
||||
## Configuration for DMF communication
|
||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
||||
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
||||
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
||||
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
||||
|
||||
## Configuration for simulations
|
||||
hawkbit.device.simulator.autostarts.[0].tenant=DEFAULT
|
||||
|
||||
## Configuration for RabbitMQ integration
|
||||
|
||||
## Configuration for local RabbitMQ integration
|
||||
spring.rabbitmq.username=guest
|
||||
spring.rabbitmq.password=guest
|
||||
spring.rabbitmq.virtualHost=/
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
# hawkBit Example Application
|
||||
The hawkBit example application is a standalone spring-boot application with an embedded servlet container to start the hawkBit.
|
||||
The hawkBit example application is a standalone spring-boot application with an embedded servlet container to host the hawkBit Update Server.
|
||||
|
||||
## Run
|
||||
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
|
||||
|
||||
## On your own workstation
|
||||
### Run
|
||||
```
|
||||
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar
|
||||
```
|
||||
@@ -10,6 +18,14 @@ Or:
|
||||
run org eclipse.hawkbit.app.Start
|
||||
```
|
||||
|
||||
## Usage
|
||||
The UI can be accessed via _http://localhost:8080/UI_.
|
||||
The REST API can be accessed via _http://localhost:8080/rest/v1_.
|
||||
### Usage
|
||||
The Management UI can be accessed via http://localhost:8080/UI
|
||||
The Management API can be accessed via http://localhost:8080/rest/v1
|
||||
|
||||
## Deploy example app to Cloud Foundry
|
||||
|
||||
- Go to ```target``` subfolder.
|
||||
- Select one of the two manifests
|
||||
- **manifest-simple.yml** for a standalone hawkBit installation with embedded H2.
|
||||
- **manifest.yml** for a standalone hawkBit installation with embedded H2 and RabbitMQ service binding for DMF integration (note: this manifest is used for the sandbox above).
|
||||
- Run ```cf push``` against you cloud foundry environment.
|
||||
|
||||
20
examples/hawkbit-example-app/cf/manifest-simple.yml
Normal file
20
examples/hawkbit-example-app/cf/manifest-simple.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
---
|
||||
applications:
|
||||
- name: hawkbit-simple
|
||||
memory: 1024M
|
||||
instances: 1
|
||||
buildpack: https://github.com/cloudfoundry/java-buildpack
|
||||
path: ${project.build.finalName}.jar
|
||||
env:
|
||||
SPRING_PROFILES_ACTIVE: cloudsandbox
|
||||
CF_STAGING_TIMEOUT: 15
|
||||
CF_STARTUP_TIMEOUT: 15
|
||||
22
examples/hawkbit-example-app/cf/manifest.yml
Normal file
22
examples/hawkbit-example-app/cf/manifest.yml
Normal file
@@ -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
|
||||
#
|
||||
|
||||
---
|
||||
applications:
|
||||
- name: hawkbit
|
||||
memory: 1024M
|
||||
instances: 1
|
||||
buildpack: https://github.com/cloudfoundry/java-buildpack
|
||||
path: ${project.build.finalName}.jar
|
||||
services:
|
||||
- dmf-rabbit
|
||||
env:
|
||||
SPRING_PROFILES_ACTIVE: cloudsandbox,amqp
|
||||
CF_STAGING_TIMEOUT: 15
|
||||
CF_STARTUP_TIMEOUT: 15
|
||||
@@ -39,6 +39,20 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>cf</directory>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>${project.build.directory}</targetPath>
|
||||
<includes>
|
||||
<include>manifest.yml</include>
|
||||
<include>manifest-simple.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -33,7 +34,8 @@ public class MyUI extends HawkbitUI {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus) {
|
||||
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus));
|
||||
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus,
|
||||
final UIEventProvider provider) {
|
||||
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus, provider));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
vaadin.servlet.productionMode=true
|
||||
@@ -1,4 +1,4 @@
|
||||
# HawkBit management API example
|
||||
# hawkBit Management API example client
|
||||
|
||||
Example client that shows how to efficiently use the hawkBit management API.
|
||||
|
||||
@@ -36,4 +36,3 @@ In rollout mode:
|
||||
* assigning software modules to distribution sets
|
||||
* creating a rollout
|
||||
* starting a rollout
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the DistributionSet resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/distributionsets")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsets")
|
||||
public interface DistributionSetResourceClient extends DistributionSetRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the DistributionSetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/distributionsettags")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettags")
|
||||
public interface DistributionSetTagResourceClient extends DistributionSetTagRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
* Client binding for the DistributionSetType resource of the management API.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/distributionsettypes")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettypes")
|
||||
public interface DistributionSetTypeResourceClient extends DistributionSetTypeRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the Rollout resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/rollouts")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/rollouts")
|
||||
public interface RolloutResourceClient extends RolloutRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the SoftwareModule resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/softwaremodules")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremodules")
|
||||
public interface SoftwareModuleResourceClient extends SoftwareModuleRestAPI {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the oftwareModuleType resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/softwaremoduletypes")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremoduletypes")
|
||||
public interface SoftwareModuleTypeResourceClient extends SoftwareModuleTypeRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the Target resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/targets")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targets")
|
||||
public interface TargetResourceClient extends TargetRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the TargetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.endpoint.url:localhost:8080}/rest/v1/targettags")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targettags")
|
||||
public interface TargetTagResourceClient extends TargetTagRestApi {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,7 @@ import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRe
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link DistributionSetRequestBodyPost}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class DistributionSetBuilder {
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link DistributionSetTypeRequestBodyPost}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTypeBuilder {
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody;
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link RolloutRestRequestBody}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class RolloutBuilder {
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssi
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleAssigmentRest}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleAssigmentBuilder {
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleBuilder {
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleTypeBuilder {
|
||||
|
||||
@@ -17,8 +17,6 @@ import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Builder pattern for building {@link TagRequestBodyPut}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class TagBuilder {
|
||||
|
||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
||||
/**
|
||||
*
|
||||
* Builder pattern for building {@link TargetRequestBody}.
|
||||
*
|
||||
* @author Jonathan Knoblauch
|
||||
*
|
||||
*/
|
||||
public class TargetBuilder {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
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;
|
||||
@@ -21,10 +23,10 @@ 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.DistributionSetsRest;
|
||||
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.SoftwareModulesRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypesRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -39,7 +41,7 @@ public class CreateStartedRolloutExample {
|
||||
private static final String SM_MODULE_TYPE = "firmware";
|
||||
|
||||
/* known distribution set type name and key */
|
||||
private static final String DS_MODULE_TYPE = "firmware";
|
||||
private static final String DS_MODULE_TYPE = SM_MODULE_TYPE;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
@@ -65,8 +67,9 @@ public class CreateStartedRolloutExample {
|
||||
public void run() {
|
||||
|
||||
// create three SoftwareModuleTypes
|
||||
final SoftwareModuleTypesRest createdSoftwareModuleTypes = softwareModuleTypeResource.createSoftwareModuleTypes(
|
||||
new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE).maxAssignments(1).build())
|
||||
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||
.maxAssignments(1).build())
|
||||
.getBody();
|
||||
|
||||
// create one DistributionSetType
|
||||
@@ -75,12 +78,12 @@ public class CreateStartedRolloutExample {
|
||||
.getBody();
|
||||
|
||||
// create one DistributionSet
|
||||
final DistributionSetsRest distributionSetsRest = distributionSetResource.createDistributionSets(
|
||||
final List<DistributionSetRest> distributionSetsRest = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name("rollout-example").version("1.0.0").type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
// create three SoftwareModules
|
||||
final SoftwareModulesRest softwareModulesRest = softwareModuleResource
|
||||
final List<SoftwareModuleRest> softwareModulesRest = softwareModuleResource
|
||||
.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name("firmware").version("1.0.0").type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
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;
|
||||
@@ -17,9 +19,9 @@ import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuild
|
||||
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.DistributionSetsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModulesRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypesRest;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -39,13 +41,13 @@ public class GettingStartedDefaultScenario {
|
||||
private static final String SM_MODULE_TYPE = "gettingstarted";
|
||||
|
||||
/* known distribution set type name and key */
|
||||
private static final String DS_MODULE_TYPE = "gettingstarted";
|
||||
private static final String DS_MODULE_TYPE = SM_MODULE_TYPE;
|
||||
|
||||
/* known distribution name of this getting started example */
|
||||
private static final String SM_EXAMPLE_NAME = "gettingstarted-example";
|
||||
|
||||
/* known distribution name of this getting started example */
|
||||
private static final String DS_EXAMPLE_NAME = "gettingstarted-example";
|
||||
private static final String DS_EXAMPLE_NAME = SM_EXAMPLE_NAME;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
@@ -68,8 +70,9 @@ public class GettingStartedDefaultScenario {
|
||||
|
||||
// create one SoftwareModuleTypes
|
||||
LOGGER.info("Creating software module type {}", SM_MODULE_TYPE);
|
||||
final SoftwareModuleTypesRest createdSoftwareModuleTypes = softwareModuleTypeResource.createSoftwareModuleTypes(
|
||||
new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE).maxAssignments(1).build())
|
||||
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||
.maxAssignments(1).build())
|
||||
.getBody();
|
||||
|
||||
// create one DistributionSetType
|
||||
@@ -83,17 +86,17 @@ public class GettingStartedDefaultScenario {
|
||||
final String dsVersion3 = "2.1.0";
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion1);
|
||||
final DistributionSetsRest distributionSetsRest1 = distributionSetResource.createDistributionSets(
|
||||
final List<DistributionSetRest> 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 DistributionSetsRest distributionSetsRest2 = distributionSetResource.createDistributionSets(
|
||||
final List<DistributionSetRest> 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 DistributionSetsRest distributionSetsRest3 = distributionSetResource.createDistributionSets(
|
||||
final List<DistributionSetRest> distributionSetsRest3 = distributionSetResource.createDistributionSets(
|
||||
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion3).type(DS_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
@@ -103,15 +106,15 @@ public class GettingStartedDefaultScenario {
|
||||
final String swVersion3 = "3";
|
||||
|
||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion1);
|
||||
final SoftwareModulesRest softwareModulesRest1 = softwareModuleResource.createSoftwareModules(
|
||||
final List<SoftwareModuleRest> 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 SoftwareModulesRest softwareModulesRest2 = softwareModuleResource.createSoftwareModules(
|
||||
final List<SoftwareModuleRest> 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 SoftwareModulesRest softwareModulesRest3 = softwareModuleResource.createSoftwareModules(
|
||||
final List<SoftwareModuleRest> softwareModulesRest3 = softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion3).type(SM_MODULE_TYPE).build())
|
||||
.getBody();
|
||||
|
||||
|
||||
@@ -38,10 +38,7 @@ import com.mongodb.gridfs.GridFSDBFile;
|
||||
import com.mongodb.gridfs.GridFSFile;
|
||||
|
||||
/**
|
||||
* The file management which looks up all the file in the filestore.
|
||||
*
|
||||
*
|
||||
*
|
||||
* The file management which looks up all the file in the file tore.
|
||||
*
|
||||
*/
|
||||
public class ArtifactStore implements ArtifactRepository {
|
||||
@@ -60,7 +57,7 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
private static final String MD5 = "md5";
|
||||
|
||||
/**
|
||||
* The mongoDB field which holds the SHA1 hash, stored in the metadata
|
||||
* The mongoDB field which holds the SHA1 hash, stored in the meta data
|
||||
* object.
|
||||
*/
|
||||
private static final String SHA1 = "sha1";
|
||||
@@ -75,11 +72,10 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
/**
|
||||
* Retrieves a {@link GridFSDBFile} from the store by it's SHA1 hash.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant to retrieve the artifacts from, ignore case.
|
||||
* @param sha1Hash
|
||||
* the sha1-hash of the file to lookup.
|
||||
* @return The gridfs file object or {@code null} if no file exists.
|
||||
*
|
||||
* @return The DbArtifact object or {@code null} if no file exists.
|
||||
*/
|
||||
@Override
|
||||
public DbArtifact getArtifactBySha1(final String sha1Hash) {
|
||||
@@ -226,8 +222,7 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
* @return a paged list of artifacts mapped from the given dbFiles
|
||||
*/
|
||||
private List<DbArtifact> map(final List<GridFSDBFile> dbFiles) {
|
||||
final List<DbArtifact> collect = dbFiles.stream().map(dbFile -> map(dbFile)).collect(Collectors.toList());
|
||||
return collect;
|
||||
return dbFiles.stream().map(dbFile -> map(dbFile)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +233,7 @@ public class ArtifactStore implements ArtifactRepository {
|
||||
* the tenant to retrieve the artifacts from, ignore case.
|
||||
* @param sha1Hashes
|
||||
* the sha1-hashes of the files to lookup.
|
||||
* @return list of artfiacts
|
||||
* @return list of artifacts
|
||||
*/
|
||||
@Override
|
||||
public List<DbArtifact> getArtifactsBySha1(final List<String> sha1Hashes) {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
package org.eclipse.hawkbit.autoconfigure.ui;
|
||||
|
||||
import org.eclipse.hawkbit.DistributedResourceBundleMessageSource;
|
||||
import org.eclipse.hawkbit.ui.HawkbitEventProvider;
|
||||
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.vaadin.spring.annotation.EnableVaadinExtensions;
|
||||
@@ -17,9 +20,6 @@ import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
|
||||
|
||||
/**
|
||||
* The hawkbit-ui autoconfiguration.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@EnableVaadinSecurity
|
||||
@@ -37,4 +37,15 @@ public class UIAutoConfiguration {
|
||||
return new DistributedResourceBundleMessageSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* A event provider bean which hold the supported events for the UI.
|
||||
*
|
||||
* @return the provider bean
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public UIEventProvider eventProvider() {
|
||||
return new HawkbitEventProvider();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ControllerPollProperties {
|
||||
* Maximum polling time that can be configured by a tenant in HH:MM:SS
|
||||
* notation.
|
||||
*/
|
||||
private String maxPollingTime = "23:59:00";
|
||||
private String maxPollingTime = "23:59:59";
|
||||
|
||||
/**
|
||||
* Minimum polling time that can be configured by a tenant in HH:MM:SS
|
||||
|
||||
@@ -14,9 +14,6 @@ import java.io.OutputStream;
|
||||
/**
|
||||
* Database representation of artifact.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DbArtifact {
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@ package org.eclipse.hawkbit.artifact.repository.model;
|
||||
/**
|
||||
* Database representation of artifact hash.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DbArtifactHash {
|
||||
|
||||
|
||||
@@ -36,8 +36,15 @@ public final class DurationHelper {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the requested duration is in the defined min/max range.
|
||||
*
|
||||
* @param duration
|
||||
* to checked
|
||||
* @return <code>true</code> if in time range
|
||||
*/
|
||||
public boolean isWithinRange(final Duration duration) {
|
||||
return duration.compareTo(min) > 0 && duration.compareTo(max) < 0;
|
||||
return duration.compareTo(min) >= 0 && duration.compareTo(max) <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,45 +30,60 @@ 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("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", 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("pollingTime", "hawkbit.controller.pollingTime", 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;
|
||||
|
||||
@@ -24,10 +24,10 @@ public interface AmqpSenderService {
|
||||
*
|
||||
* @param message
|
||||
* the amqp message
|
||||
* @param uri
|
||||
* @param replyTo
|
||||
* the reply to uri
|
||||
*/
|
||||
void sendMessage(Message message, URI uri);
|
||||
void sendMessage(Message message, URI replyTo);
|
||||
|
||||
/**
|
||||
* Extract the exchange from the uri. Default implementation removes the
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BaseAmqpService {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T convertMessage(final Message message, final Class<T> clazz) {
|
||||
if (message == null || message.getBody() == null) {
|
||||
if (isMessageBodyEmpty(message)) {
|
||||
return null;
|
||||
}
|
||||
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
||||
@@ -67,6 +67,10 @@ public class BaseAmqpService {
|
||||
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
||||
}
|
||||
|
||||
private boolean isMessageBodyEmpty(final Message message) {
|
||||
return message == null || message.getBody() == null || message.getBody().length == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is needed to convert a incoming message to is originally list object
|
||||
* type.
|
||||
@@ -79,7 +83,7 @@ public class BaseAmqpService {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> convertMessageList(final Message message, final Class<T> clazz) {
|
||||
if (message == null || message.getBody() == null) {
|
||||
if (isMessageBodyEmpty(message)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
||||
@@ -105,7 +109,7 @@ public class BaseAmqpService {
|
||||
}
|
||||
|
||||
protected final void logAndThrowMessageError(final Message message, final String error) {
|
||||
LOGGER.error("Error \"{}\" reported by message {}", error, message.getMessageProperties().getMessageId());
|
||||
LOGGER.warn("Error \"{}\" reported by message: {}", error, message);
|
||||
throw new IllegalArgumentException(error);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.hawkbit.util.IpUtil;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
|
||||
@@ -33,8 +34,12 @@ public class DefaultAmqpSenderService implements AmqpSenderService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final Message message, final URI uri) {
|
||||
internalAmqpTemplate.send(extractExchange(uri), null, message);
|
||||
public void sendMessage(final Message message, final URI replyTo) {
|
||||
if (!IpUtil.isAmqpUri(replyTo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
internalAmqpTemplate.send(extractExchange(replyTo), null, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package org.eclipse.hawkbit.security;
|
||||
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.security.authentication.InsufficientAuthenticationExc
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@@ -38,11 +40,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
@Mock
|
||||
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
|
||||
|
||||
/**
|
||||
* Testing in case the containing controllerId in the URI request path does
|
||||
* not accord with the controllerId in the request header.
|
||||
*/
|
||||
@Test(expected = BadCredentialsException.class)
|
||||
@Test
|
||||
@Description("Testing in case the containing controllerId in the URI request path does not accord with the controllerId in the request header.")
|
||||
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
|
||||
final String principal = "controllerIdURL";
|
||||
final String credentials = "controllerIdHeader";
|
||||
@@ -51,15 +50,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
token.setDetails(webAuthenticationDetailsMock);
|
||||
|
||||
// test, should throw authentication exception
|
||||
underTestWithoutSourceIpCheck.authenticate(token);
|
||||
try {
|
||||
underTestWithoutSourceIpCheck.authenticate(token);
|
||||
fail("Should not work with wrong credentials");
|
||||
} catch (final BadCredentialsException e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing that the controllerId within the URI request path is the same
|
||||
* with the controllerId within the request header and no source IP check is
|
||||
* in place.
|
||||
*/
|
||||
@Test
|
||||
@Description("Testing that the controllerId within the URI request path is the same with the controllerId within the request header and no source IP check is in place.")
|
||||
public void principalAndCredentialsAreTheSameWithNoSourceIpCheckIsSuccessful() {
|
||||
final String principal = "controllerId";
|
||||
final String credentials = "controllerId";
|
||||
@@ -71,12 +72,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing that the controllerId in the URI request match with the
|
||||
* controllerId in the request header but the request are not coming from a
|
||||
* trustful source.
|
||||
*/
|
||||
@Test(expected = InsufficientAuthenticationException.class)
|
||||
@Test
|
||||
@Description("Testing that the controllerId in the URI request match with the controllerId in the request header but the request are not coming from a trustful source.")
|
||||
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
|
||||
final String remoteAddress = "192.168.1.1";
|
||||
final String principal = "controllerId";
|
||||
@@ -88,16 +85,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
|
||||
|
||||
// test, should throw authentication exception
|
||||
final Authentication authenticate = underTestWithSourceIpCheck.authenticate(token);
|
||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||
|
||||
try {
|
||||
underTestWithSourceIpCheck.authenticate(token);
|
||||
fail("as source is not trusted.");
|
||||
} catch (final InsufficientAuthenticationException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing that the controllerId in the URI request match with the
|
||||
* controllerId in the request header and the source Ip is matching the
|
||||
* allowed remote IP address.
|
||||
*/
|
||||
@Test()
|
||||
@Test
|
||||
@Description("Testing that the controllerId in the URI request match with the controllerId in the request header and the source Ip is matching the allowed remote IP address.")
|
||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
|
||||
final String principal = "controllerId";
|
||||
final String credentials = "controllerId";
|
||||
@@ -112,7 +110,7 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||
}
|
||||
|
||||
@Test()
|
||||
@Test
|
||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
|
||||
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
|
||||
"192.168.1.3" };
|
||||
@@ -148,6 +146,11 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
||||
|
||||
// test, should throw authentication exception
|
||||
final Authentication authenticate = underTestWithList.authenticate(token);
|
||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||
try {
|
||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||
fail("as source is not trusted.");
|
||||
} catch (final InsufficientAuthenticationException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
||||
@@ -11,9 +11,6 @@ package org.eclipse.hawkbit;
|
||||
/**
|
||||
* A constant class which holds only static constants used within the SP server.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class Constants {
|
||||
|
||||
@@ -27,7 +24,7 @@ public final class Constants {
|
||||
public static final int MAX_ENTRIES_IN_STATEMENT = 999;
|
||||
|
||||
/**
|
||||
* constant class only private constructor.
|
||||
* Constant class only private constructor.
|
||||
*/
|
||||
private Constants() {
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||
@@ -127,23 +127,11 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
return new ExceptionMappingAspectHandler();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
||||
* createJpaVendorAdapter()
|
||||
*/
|
||||
@Override
|
||||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
|
||||
return new EclipseLinkJpaVendorAdapter();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
||||
* getVendorProperties()
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> getVendorProperties() {
|
||||
|
||||
|
||||
@@ -167,11 +167,6 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
||||
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
||||
import org.eclipse.hawkbit.repository.TargetRepository;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
@@ -31,7 +31,7 @@ import com.google.common.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* An aspect implementation which wraps the necessary repository services for
|
||||
* saving {@link BaseEntity}s to publish create or update events.
|
||||
* saving {@link TenantAwareBaseEntity}s to publish create or update events.
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
@@ -18,9 +18,9 @@ import org.eclipse.hawkbit.eventbus.event.RolloutGroupPropertyChangeEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.RolloutPropertyChangeEvent;
|
||||
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
@@ -36,13 +36,7 @@ import com.google.common.eventbus.EventBus;
|
||||
*
|
||||
*/
|
||||
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.persistence.descriptors.DescriptorEventAdapter#postInsert
|
||||
* (org.eclipse.persistence.descriptors.DescriptorEvent)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void postInsert(final DescriptorEvent event) {
|
||||
if (event.getObject().getClass().equals(Action.class)) {
|
||||
@@ -56,45 +50,30 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.persistence.descriptors.DescriptorEventAdapter#postUpdate
|
||||
* (org.eclipse.persistence.descriptors.DescriptorEvent)
|
||||
*/
|
||||
@Override
|
||||
public void postUpdate(final DescriptorEvent event) {
|
||||
if (event.getObject().getClass().equals(Action.class)) {
|
||||
getAfterTransactionCommmitExecutor().afterCommit(
|
||||
() -> getEventBus()
|
||||
.post(new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class,
|
||||
event))));
|
||||
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||
new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class, event))));
|
||||
} else if (event.getObject().getClass().equals(Rollout.class)) {
|
||||
getAfterTransactionCommmitExecutor().afterCommit(
|
||||
() -> getEventBus().post(
|
||||
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class,
|
||||
event))));
|
||||
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class, event))));
|
||||
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
|
||||
getAfterTransactionCommmitExecutor().afterCommit(
|
||||
() -> getEventBus().post(
|
||||
new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(), getChangeSet(
|
||||
RolloutGroup.class, event))));
|
||||
() -> getEventBus().post(new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(),
|
||||
getChangeSet(RolloutGroup.class, event))));
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends BaseEntity> Map<String, AbstractPropertyChangeEvent<T>.Values> getChangeSet(
|
||||
private <T extends TenantAwareBaseEntity> Map<String, AbstractPropertyChangeEvent<T>.Values> getChangeSet(
|
||||
final Class<T> clazz, final DescriptorEvent event) {
|
||||
final T rolloutGroup = clazz.cast(event.getObject());
|
||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||
return changeSet
|
||||
.getChanges()
|
||||
.stream()
|
||||
.filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||
.map(record -> (DirectToFieldChangeRecord) record)
|
||||
.collect(
|
||||
Collectors.toMap(record -> record.getAttribute(), record -> new AbstractPropertyChangeEvent<T>(
|
||||
rolloutGroup, null).new Values(record.getOldValue(), record.getNewValue())));
|
||||
.collect(Collectors.toMap(record -> record.getAttribute(),
|
||||
record -> new AbstractPropertyChangeEvent<T>(rolloutGroup, null).new Values(
|
||||
record.getOldValue(), record.getNewValue())));
|
||||
}
|
||||
|
||||
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
|
||||
|
||||
@@ -8,18 +8,19 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* An abstract definition class for {@link EntityEvent} for {@link BaseEntity}s,
|
||||
* which holds the {@link BaseEntity}.
|
||||
* An abstract definition class for {@link EntityEvent} for
|
||||
* {@link TenantAwareBaseEntity}s, which holds the {@link TenantAwareBaseEntity}
|
||||
* .
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <E>
|
||||
* the type of the {@link BaseEntity}
|
||||
* the type of the {@link TenantAwareBaseEntity}
|
||||
*/
|
||||
public abstract class AbstractBaseEntityEvent<E extends BaseEntity> extends AbstractDistributedEvent
|
||||
public abstract class AbstractBaseEntityEvent<E extends TenantAwareBaseEntity> extends AbstractDistributedEvent
|
||||
implements EntityEvent {
|
||||
|
||||
/**
|
||||
@@ -37,33 +38,16 @@ public abstract class AbstractBaseEntityEvent<E extends BaseEntity> extends Abst
|
||||
this.entity = baseEntity;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity()
|
||||
*/
|
||||
@Override
|
||||
public E getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity(java.lang
|
||||
* .Class)
|
||||
*/
|
||||
@Override
|
||||
public <T> T getEntity(final Class<T> entityClass) {
|
||||
return entityClass.cast(entity);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getTenant()
|
||||
*/
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return entity.getTenant();
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.eventbus.event;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public abstract class AbstractEntityBulkEvent<E extends BaseEntity> implements EntityBulkEvent<E> {
|
||||
public abstract class AbstractEntityBulkEvent<E extends TenantAwareBaseEntity> implements EntityBulkEvent<E> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ package org.eclipse.hawkbit.eventbus.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* Property change event.
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public class AbstractPropertyChangeEvent<E extends BaseEntity> extends AbstractBaseEntityEvent<E> {
|
||||
public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extends AbstractBaseEntityEvent<E> {
|
||||
|
||||
private static final long serialVersionUID = -3671601415138242311L;
|
||||
private final transient Map<String, Values> changeSet;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class DistributionSetTagAssigmentResultEvent {
|
||||
|
||||
private final DistributionSetTagAssigmentResult assigmentResult;
|
||||
private final DistributionSetTagAssignmentResult assigmentResult;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -23,11 +23,11 @@ public class DistributionSetTagAssigmentResultEvent {
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
*/
|
||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) {
|
||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
|
||||
this.assigmentResult = assigmentResult;
|
||||
}
|
||||
|
||||
public DistributionSetTagAssigmentResult getAssigmentResult() {
|
||||
public DistributionSetTagAssignmentResult getAssigmentResult() {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.eventbus.event;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* An event interface which declares event types that an entities has been
|
||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
* @param <E>
|
||||
* the entity type
|
||||
*/
|
||||
public interface EntityBulkEvent<E extends BaseEntity> extends Serializable, Event {
|
||||
public interface EntityBulkEvent<E extends TenantAwareBaseEntity> extends Serializable, Event {
|
||||
|
||||
/**
|
||||
* A typesafe way to retrieve the the entities from the event, which might
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class TargetTagAssigmentResultEvent {
|
||||
|
||||
private final TargetTagAssigmentResult assigmentResult;
|
||||
private final TargetTagAssignmentResult assigmentResult;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -23,11 +23,11 @@ public class TargetTagAssigmentResultEvent {
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
*/
|
||||
public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) {
|
||||
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
|
||||
this.assigmentResult = assigmentResult;
|
||||
}
|
||||
|
||||
public TargetTagAssigmentResult getAssigmentResult() {
|
||||
public TargetTagAssignmentResult getAssigmentResult() {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ package org.eclipse.hawkbit.repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Command repository operations for all {@link BaseEntity}s.
|
||||
* Command repository operations for all {@link TenantAwareBaseEntity}s.
|
||||
*
|
||||
*
|
||||
*
|
||||
@@ -29,11 +29,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@NoRepositoryBean
|
||||
@Transactional(readOnly = true)
|
||||
public interface BaseEntityRepository<T extends BaseEntity, I extends Serializable>
|
||||
public interface BaseEntityRepository<T extends TenantAwareBaseEntity, I extends Serializable>
|
||||
extends PagingAndSortingRepository<T, I> {
|
||||
|
||||
/**
|
||||
* Deletes all {@link BaseEntity} of a given tenant.
|
||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant.
|
||||
*
|
||||
* @param tenant
|
||||
* to delete data from
|
||||
|
||||
@@ -376,16 +376,9 @@ public class ControllerManagement {
|
||||
switch (actionStatus.getStatus()) {
|
||||
case ERROR:
|
||||
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
|
||||
// set action inactive
|
||||
mergedAction.setActive(false);
|
||||
mergedAction.setStatus(Status.ERROR);
|
||||
mergedTarget.setAssignedDistributionSet(null);
|
||||
targetManagement.updateTarget(mergedTarget);
|
||||
handleErrorOnAction(mergedAction, mergedTarget);
|
||||
break;
|
||||
case FINISHED:
|
||||
// set action inactive
|
||||
mergedAction.setActive(false);
|
||||
mergedAction.setStatus(Status.FINISHED);
|
||||
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
|
||||
break;
|
||||
case CANCELED:
|
||||
@@ -404,6 +397,13 @@ public class ControllerManagement {
|
||||
return actionRepository.save(mergedAction);
|
||||
}
|
||||
|
||||
private void handleErrorOnAction(final Action mergedAction, final Target mergedTarget) {
|
||||
mergedAction.setActive(false);
|
||||
mergedAction.setStatus(Status.ERROR);
|
||||
mergedTarget.setAssignedDistributionSet(null);
|
||||
targetManagement.updateTarget(mergedTarget);
|
||||
}
|
||||
|
||||
private void checkForToManyStatusEntries(final Action action) {
|
||||
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
|
||||
|
||||
@@ -420,6 +420,8 @@ public class ControllerManagement {
|
||||
}
|
||||
|
||||
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
|
||||
action.setActive(false);
|
||||
action.setStatus(Status.FINISHED);
|
||||
final TargetInfo targetInfo = target.getTargetInfo();
|
||||
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
|
||||
targetInfo.setInstalledDistributionSet(ds);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult {
|
||||
* @return the assignedTargets
|
||||
*/
|
||||
public List<Target> getAssignedTargets() {
|
||||
return targetManagement.findTargetsByControllerID(assignedTargets);
|
||||
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet_;
|
||||
@@ -68,9 +68,6 @@ import com.google.common.eventbus.EventBus;
|
||||
/**
|
||||
* Business facade for managing the {@link DistributionSet}s.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Validated
|
||||
@@ -140,15 +137,15 @@ public class DistributionSetManagement {
|
||||
* @param sets
|
||||
* to toggle for
|
||||
* @param tag
|
||||
* to toogle
|
||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
||||
* to toggle
|
||||
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||
* the assignment outcome.
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
|
||||
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final List<DistributionSet> sets,
|
||||
@NotNull final DistributionSetTag tag) {
|
||||
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
@@ -163,44 +160,44 @@ public class DistributionSetManagement {
|
||||
* to toggle for
|
||||
* @param tagName
|
||||
* to toggle
|
||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
||||
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||
* the assignment outcome.
|
||||
*/
|
||||
@Modifying
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
public DistributionSetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
|
||||
public DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection<Long> dsIds,
|
||||
@NotNull final String tagName) {
|
||||
|
||||
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
|
||||
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
|
||||
|
||||
DistributionSetTagAssigmentResult result = null;
|
||||
final List<DistributionSet> allDSs = new ArrayList<>();
|
||||
DistributionSetTagAssignmentResult result;
|
||||
final List<DistributionSet> toBeChangedDSs = new ArrayList<>();
|
||||
for (final DistributionSet set : sets) {
|
||||
if (set.getTags().add(myTag)) {
|
||||
allDSs.add(set);
|
||||
toBeChangedDSs.add(set);
|
||||
}
|
||||
}
|
||||
|
||||
// unassigment case
|
||||
if (allDSs.isEmpty()) {
|
||||
// un-assignment case
|
||||
if (toBeChangedDSs.isEmpty()) {
|
||||
for (final DistributionSet set : sets) {
|
||||
if (set.getTags().remove(myTag)) {
|
||||
allDSs.add(set);
|
||||
toBeChangedDSs.add(set);
|
||||
}
|
||||
}
|
||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
|
||||
Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
|
||||
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0,
|
||||
toBeChangedDSs.size(), Collections.emptyList(), distributionSetRepository.save(toBeChangedDSs),
|
||||
myTag);
|
||||
} else {
|
||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
|
||||
distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
|
||||
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(),
|
||||
0, distributionSetRepository.save(toBeChangedDSs), Collections.emptyList(), myTag);
|
||||
}
|
||||
|
||||
final DistributionSetTagAssigmentResult resultAssignment = result;
|
||||
afterCommit
|
||||
.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||
final DistributionSetTagAssignmentResult resultAssignment = result;
|
||||
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||
|
||||
// no reason to persist the tag
|
||||
entityManager.detach(myTag);
|
||||
@@ -352,6 +349,9 @@ public class DistributionSetManagement {
|
||||
public List<DistributionSet> createDistributionSets(@NotNull final Iterable<DistributionSet> distributionSets) {
|
||||
for (final DistributionSet ds : distributionSets) {
|
||||
prepareDsSave(ds);
|
||||
if (ds.getType() == null) {
|
||||
ds.setType(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||
}
|
||||
}
|
||||
return distributionSetRepository.save(distributionSets);
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public class DistributionSetManagement {
|
||||
* @param spec
|
||||
* of the search
|
||||
* @param pageable
|
||||
* parametsr for paging
|
||||
* parameter for paging
|
||||
*
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*/
|
||||
@@ -762,7 +762,7 @@ public class DistributionSetManagement {
|
||||
if (distributionSetMetadataRepository.exists(metadata.getId())) {
|
||||
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
|
||||
}
|
||||
// merge base software module so optLockRevision gets updated and audit
|
||||
// merge base distribution set so optLockRevision gets updated and audit
|
||||
// log written because
|
||||
// modifying metadata is modifying the base distribution set itself for
|
||||
// auditing purposes.
|
||||
@@ -870,7 +870,7 @@ public class DistributionSetManagement {
|
||||
cb) -> cb.and(
|
||||
cb.equal(root.get(DistributionSetMetadata_.distributionSet)
|
||||
.get(DistributionSet_.id), distributionSetId),
|
||||
spec.toPredicate(root, query, cb)),
|
||||
spec.toPredicate(root, query, cb)),
|
||||
pageable);
|
||||
}
|
||||
|
||||
@@ -916,7 +916,7 @@ public class DistributionSetManagement {
|
||||
@Transactional
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
public List<DistributionSetType> createDistributionSetTypes(@NotNull final Collection<DistributionSetType> types) {
|
||||
return types.stream().map(type -> createDistributionSetType(type)).collect(Collectors.toList());
|
||||
return types.stream().map(this::createDistributionSetType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1060,7 +1060,7 @@ public class DistributionSetManagement {
|
||||
|
||||
afterCommit.afterCommit(() -> {
|
||||
|
||||
final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
|
||||
final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
|
||||
save, Collections.emptyList(), tag);
|
||||
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
|
||||
});
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.springframework.stereotype.Repository;
|
||||
* Workaround as spring data does not provide a {@link Slice} based
|
||||
* {@link JpaRepository#findAll()}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Repository
|
||||
public class NoCountPagingRepository {
|
||||
@@ -104,15 +101,6 @@ public class NoCountPagingRepository {
|
||||
super(domainClass, em);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.data.jpa.repository.support.SimpleJpaRepository#
|
||||
* readPage(javax.persistence .TypedQuery,
|
||||
* org.springframework.data.domain.Pageable,
|
||||
* org.springframework.data.jpa.domain.Specification)
|
||||
*/
|
||||
@Override
|
||||
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
|
||||
query.setFirstResult(pageable.getOffset());
|
||||
|
||||
@@ -458,11 +458,6 @@ public class ReportManagement {
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -471,11 +466,6 @@ public class ReportManagement {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is
|
||||
// generated
|
||||
@@ -499,11 +489,6 @@ public class ReportManagement {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DSName [name=" + name + "]";
|
||||
@@ -523,9 +508,6 @@ public class ReportManagement {
|
||||
|
||||
/**
|
||||
* Return DateTypes.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static final class DateTypes implements Serializable {
|
||||
/**
|
||||
@@ -585,12 +567,6 @@ public class ReportManagement {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String DATE_PATTERN = "yyyy-MM";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
||||
* format(java. lang.String)
|
||||
*/
|
||||
@Override
|
||||
public LocalDate format(final String s) {
|
||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
||||
@@ -598,23 +574,11 @@ public class ReportManagement {
|
||||
return ym.atDay(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
||||
* h2Format()
|
||||
*/
|
||||
@Override
|
||||
public String h2Format() {
|
||||
return DATE_PATTERN;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
||||
* mySqlFormat( )
|
||||
*/
|
||||
@Override
|
||||
public String mySqlFormat() {
|
||||
return "%Y-%m";
|
||||
|
||||
@@ -59,11 +59,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Business facade for managing the deployable {@link SoftwareModule}s.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Business facade for managing {@link SoftwareModule}s.
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@@ -99,7 +95,7 @@ public class SoftwareManagement {
|
||||
private ArtifactManagement artifactManagement;
|
||||
|
||||
/**
|
||||
* Updates existing {@link SoftwareModule}. Updateable values are
|
||||
* Updates existing {@link SoftwareModule}. Update-able values are
|
||||
* {@link SoftwareModule#getDescription()}
|
||||
* {@link SoftwareModule#getVendor()}.
|
||||
*
|
||||
@@ -119,17 +115,21 @@ public class SoftwareManagement {
|
||||
|
||||
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
|
||||
|
||||
boolean updated = false;
|
||||
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
|
||||
module.setDescription(sm.getDescription());
|
||||
updated = true;
|
||||
}
|
||||
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
|
||||
module.setVendor(sm.getVendor());
|
||||
updated = true;
|
||||
}
|
||||
return softwareModuleRepository.save(module);
|
||||
|
||||
return updated ? softwareModuleRepository.save(module) : module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates existing {@link SoftwareModuleType}. Updatable value is
|
||||
* Updates existing {@link SoftwareModuleType}. Update-able value is
|
||||
* {@link SoftwareModuleType#getDescription()} and
|
||||
* {@link SoftwareModuleType#getColour()}.
|
||||
*
|
||||
@@ -145,13 +145,16 @@ public class SoftwareManagement {
|
||||
|
||||
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
||||
|
||||
boolean updated = false;
|
||||
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
||||
type.setDescription(sm.getDescription());
|
||||
updated = true;
|
||||
}
|
||||
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
|
||||
type.setColour(sm.getColour());
|
||||
updated = true;
|
||||
}
|
||||
return softwareModuleTypeRepository.save(type);
|
||||
return updated ? softwareModuleTypeRepository.save(type) : type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,19 +259,21 @@ public class SoftwareManagement {
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves {@link SoftwareModule}s by their name AND version.
|
||||
* retrieves {@link SoftwareModule} by their name AND version AND type..
|
||||
*
|
||||
* @param name
|
||||
* of the {@link SoftwareModule}
|
||||
* @param version
|
||||
* of the {@link SoftwareModule}
|
||||
* @return the found {@link SoftwareModule}s
|
||||
* @param type
|
||||
* of the {@link SoftwareModule}
|
||||
* @return the found {@link SoftwareModule} or <code>null</code>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public List<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
||||
@NotEmpty final String version) {
|
||||
public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
||||
@NotEmpty final String version, @NotNull final SoftwareModuleType type) {
|
||||
|
||||
return softwareModuleRepository.findByNameAndVersion(name, version);
|
||||
return softwareModuleRepository.findOneByNameAndVersionAndType(name, version, type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,21 +496,27 @@ public class SoftwareManagement {
|
||||
/**
|
||||
* Filter {@link SoftwareModule}s with given
|
||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
||||
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
||||
* search text and {@link SoftwareModule#getType()} that are not marked as
|
||||
* deleted and sort them by means of given distribution set related modules
|
||||
* on top of the list.
|
||||
*
|
||||
* After that the modules are sorted by {@link SoftwareModule#getName()} and
|
||||
* {@link SoftwareModule#getVersion()} in ascending order.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param orderByDistributionId
|
||||
* the ID of distribution set to be order by
|
||||
* the ID of distribution set to be ordered on top
|
||||
* @param searchText
|
||||
* to be filtered as "like" on {@link SoftwareModule#getName()}
|
||||
* filtered as "like" on {@link SoftwareModule#getName()}
|
||||
* @param type
|
||||
* to be filtered as "like" on {@link SoftwareModule#getType()}
|
||||
* filtered as "equal" on {@link SoftwareModule#getType()}
|
||||
* @return the page of found {@link SoftwareModule}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public Slice<CustomSoftwareModule> findSoftwareModuleOrderByDistribution(@NotNull final Pageable pageable,
|
||||
@NotNull final Long orderByDistributionId, final String searchText, final SoftwareModuleType type) {
|
||||
public Slice<CustomSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
@NotNull final Pageable pageable, @NotNull final Long orderByDistributionId, final String searchText,
|
||||
final SoftwareModuleType type) {
|
||||
|
||||
final List<CustomSoftwareModule> resultList = new ArrayList<>();
|
||||
final int pageSize = pageable.getPageSize();
|
||||
@@ -522,7 +533,7 @@ public class SoftwareManagement {
|
||||
assignedRoot, assignedQuery, cb,
|
||||
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
|
||||
// if we have some predicates then add it to the where clause of the
|
||||
// multiselect
|
||||
// multi select
|
||||
assignedQuery.where(specPredicate);
|
||||
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
|
||||
cb.asc(assignedRoot.get(SoftwareModule_.version)));
|
||||
@@ -546,7 +557,7 @@ public class SoftwareManagement {
|
||||
unassignedQuery.distinct(true);
|
||||
final Root<SoftwareModule> unassignedRoot = unassignedQuery.from(SoftwareModule.class);
|
||||
|
||||
Predicate[] unassignedSpec = null;
|
||||
Predicate[] unassignedSpec;
|
||||
if (!assignedSoftwareModules.isEmpty()) {
|
||||
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
|
||||
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
|
||||
@@ -709,8 +720,8 @@ public class SoftwareManagement {
|
||||
@Modifying
|
||||
@Transactional
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
public List<SoftwareModuleType> createSoftwareModuleTypes(@NotNull final Collection<SoftwareModuleType> types) {
|
||||
return types.stream().map(type -> createSoftwareModuleType(type)).collect(Collectors.toList());
|
||||
public List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types) {
|
||||
return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -826,7 +837,7 @@ public class SoftwareManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
|
||||
// check if exists otherwise throw entity not found exception
|
||||
findOne(metadata.getId());
|
||||
findSoftwareModuleMetadata(metadata.getId());
|
||||
// touch it to update the lock revision because we are modifying the
|
||||
// software module
|
||||
// indirectly
|
||||
@@ -884,7 +895,7 @@ public class SoftwareManagement {
|
||||
cb) -> cb.and(
|
||||
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
||||
.get(SoftwareModule_.id), softwareModuleId),
|
||||
spec.toPredicate(root, query, cb)),
|
||||
spec.toPredicate(root, query, cb)),
|
||||
pageable);
|
||||
}
|
||||
|
||||
@@ -899,7 +910,7 @@ public class SoftwareManagement {
|
||||
* in case the meta data does not exists for the given key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
public SoftwareModuleMetadata findOne(@NotNull final SwMetadataCompositeKey id) {
|
||||
public SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull final SwMetadataCompositeKey id) {
|
||||
final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id);
|
||||
if (findOne == null) {
|
||||
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
|
||||
|
||||
@@ -43,15 +43,19 @@ public interface SoftwareModuleRepository
|
||||
Long countByType(SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* Retrieves {@link SoftwareModule}s by filtering on name AND version.
|
||||
* Retrieves {@link SoftwareModule} by filtering on name AND version AND
|
||||
* type (which is unique per tenant.
|
||||
*
|
||||
* @param name
|
||||
* to be filtered on
|
||||
* @param version
|
||||
* to be filtered on
|
||||
* @return the found {@link SoftwareModule}s with the given name AND verion
|
||||
* @param type
|
||||
* to be filtered on
|
||||
* @return the found {@link SoftwareModule} with the given name AND version
|
||||
* AND type
|
||||
*/
|
||||
List<SoftwareModule> findByNameAndVersion(String name, String version);
|
||||
SoftwareModule findOneByNameAndVersionAndType(String name, String version, SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* deletes the {@link SoftwareModule}s with the given IDs.
|
||||
@@ -81,6 +85,8 @@ public interface SoftwareModuleRepository
|
||||
Page<SoftwareModule> findByAssignedTo(Pageable pageable, DistributionSet set);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param set
|
||||
* to search for
|
||||
* @return all {@link SoftwareModule}s that are assigned to given
|
||||
|
||||
@@ -310,8 +310,6 @@ public class SystemManagement {
|
||||
}
|
||||
|
||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||
|
||||
// Edge Controller Linux standard setup
|
||||
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
|
||||
"ECL Application", "Edge Controller Linux base application type", 1));
|
||||
final SoftwareModuleType eclOs = softwareModuleTypeRepository
|
||||
@@ -327,13 +325,11 @@ public class SystemManagement {
|
||||
"Standard Edge Controller Linux distribution set type. OS only.").addMandatoryModuleType(eclOs)
|
||||
.addOptionalModuleType(eclApp));
|
||||
|
||||
final DistributionSetType defaultType = distributionSetTypeRepository
|
||||
return distributionSetTypeRepository
|
||||
.save(new DistributionSetType("ecl_os_app_jvm", "OS with optional app and jvm",
|
||||
"Standard Edge Controller Linux distribution set type. OS with optional application.")
|
||||
.addMandatoryModuleType(eclOs).addOptionalModuleType(eclApp)
|
||||
.addOptionalModuleType(eclJvm));
|
||||
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,18 +339,8 @@ public class SystemManagement {
|
||||
* default types we need to use the tenant the current tenant which is
|
||||
* currently created and not the one currently in the {@link TenantAware}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
private class CurrentTenantKeyGenerator implements KeyGenerator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.cache.interceptor.KeyGenerator#generate(java.lang
|
||||
* .Object, java.lang.reflect.Method, java.lang.Object[])
|
||||
*/
|
||||
@Override
|
||||
public Object generate(final Object target, final Method method, final Object... params) {
|
||||
final String initialTenantCreation = createInitialTenant.get();
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo_;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Target_;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
@@ -53,7 +53,6 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.SliceImpl;
|
||||
@@ -74,8 +73,6 @@ import com.google.common.eventbus.EventBus;
|
||||
/**
|
||||
* Business service facade for managing {@link Target}s.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Validated
|
||||
@@ -157,7 +154,7 @@ public class TargetManagement {
|
||||
* @return List of found{@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
public List<Target> findTargetsByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
||||
public List<Target> findTargetByControllerID(@NotEmpty final Collection<String> controllerIDs) {
|
||||
return targetRepository.findAll(TargetSpecifications.byControllerIdWithStatusAndAssignedInJoin(controllerIDs));
|
||||
}
|
||||
|
||||
@@ -333,10 +330,10 @@ public class TargetManagement {
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and
|
||||
* {@link Target#getActiveActions()} possible including the filtering based
|
||||
* on the given {@code spec}.
|
||||
* {@link Target#getActiveActions()} possible including additional filtering
|
||||
* based on the given {@code spec}.
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
@@ -376,7 +373,8 @@ public class TargetManagement {
|
||||
/**
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||
* details, i.e. NO {@link Target#getTags()} and
|
||||
* {@link Target#getActiveActions()} possible.
|
||||
* {@link Target#getActiveActions()} possible including additional filtering
|
||||
* based on the given {@code spec}.
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the ID of the {@link DistributionSet}
|
||||
@@ -492,7 +490,7 @@ public class TargetManagement {
|
||||
if (!Strings.isNullOrEmpty(searchText)) {
|
||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText));
|
||||
}
|
||||
if (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0)) {
|
||||
if (selectTargetWithNoTag != null && (selectTargetWithNoTag || (tagNames != null && tagNames.length > 0))) {
|
||||
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
||||
}
|
||||
return specList;
|
||||
@@ -536,7 +534,7 @@ public class TargetManagement {
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List<Target> targets,
|
||||
public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final List<Target> targets,
|
||||
@NotNull final TargetTag tag) {
|
||||
return toggleTagAssignment(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||
@@ -558,7 +556,7 @@ public class TargetManagement {
|
||||
@Transactional
|
||||
@NotNull
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final Collection<String> targetIds,
|
||||
public TargetTagAssignmentResult toggleTagAssignment(@NotEmpty final Collection<String> targetIds,
|
||||
@NotNull final String tagName) {
|
||||
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
||||
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
||||
@@ -568,7 +566,7 @@ public class TargetManagement {
|
||||
// all are already assigned -> unassign
|
||||
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
||||
alreadyAssignedTargets.forEach(target -> target.getTags().remove(tag));
|
||||
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(0, 0, alreadyAssignedTargets.size(),
|
||||
final TargetTagAssignmentResult result = new TargetTagAssignmentResult(0, 0, alreadyAssignedTargets.size(),
|
||||
Collections.emptyList(), alreadyAssignedTargets, tag);
|
||||
|
||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||
@@ -578,7 +576,7 @@ public class TargetManagement {
|
||||
allTargets.removeAll(alreadyAssignedTargets);
|
||||
// some or none are assigned -> assign
|
||||
allTargets.forEach(target -> target.getTags().add(tag));
|
||||
final TargetTagAssigmentResult result = new TargetTagAssigmentResult(alreadyAssignedTargets.size(),
|
||||
final TargetTagAssignmentResult result = new TargetTagAssignmentResult(alreadyAssignedTargets.size(),
|
||||
allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag);
|
||||
|
||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||
@@ -609,7 +607,7 @@ public class TargetManagement {
|
||||
final List<Target> save = targetRepository.save(allTargets);
|
||||
|
||||
afterCommit.afterCommit(() -> {
|
||||
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, save.size(), 0, save,
|
||||
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, save.size(), 0, save,
|
||||
Collections.emptyList(), tag);
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||
});
|
||||
@@ -622,7 +620,7 @@ public class TargetManagement {
|
||||
|
||||
final List<Target> save = targetRepository.save(targets);
|
||||
afterCommit.afterCommit(() -> {
|
||||
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(),
|
||||
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, 0, save.size(),
|
||||
Collections.emptyList(), save, tag);
|
||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||
});
|
||||
@@ -812,14 +810,12 @@ public class TargetManagement {
|
||||
}
|
||||
|
||||
/**
|
||||
* finds all {@link Target#getControllerId()} for all the given parameters.
|
||||
* Finds all targets for all the given parameters but returns not the full
|
||||
* target but {@link TargetIdName}.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param filterByDistributionId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
*
|
||||
* @param filterByStatus
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
@@ -827,28 +823,38 @@ public class TargetManagement {
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param filterByTagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
*
|
||||
* @return the found {@link Target}s
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
public List<TargetIdName> findAllTargetIdsByFilters(final PageRequest pageRequest,
|
||||
final Long filterByDistributionId, final Collection<TargetUpdateStatus> filterByStatus,
|
||||
final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
||||
public List<TargetIdName> findAllTargetIdsByFilters(@NotNull final Pageable pageRequest,
|
||||
final Collection<TargetUpdateStatus> filterByStatus, final String filterBySearchText,
|
||||
final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag,
|
||||
final String... filterByTagNames) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||
final Root<Target> targetRoot = query.from(Target.class);
|
||||
List<Object[]> resultList;
|
||||
|
||||
String sortProperty = Target_.id.getName();
|
||||
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
||||
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
||||
}
|
||||
|
||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
||||
buildSpecificationList(filterByStatus, filterBySearchText, installedOrAssignedDistributionSetId,
|
||||
selectTargetWithNoTag, false, filterByTagNames),
|
||||
targetRoot, multiselect, cb);
|
||||
|
||||
@@ -864,24 +870,29 @@ public class TargetManagement {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all {@link Target#getControllerId()} for all the given parameter
|
||||
* {@link TargetFilterQuery}.
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
* and returns not the full target but {@link TargetIdName}.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @return the found {@link Target}s
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest,
|
||||
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
|
||||
@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||
final Root<Target> targetRoot = query.from(Target.class);
|
||||
|
||||
String sortProperty = Target_.id.getName();
|
||||
if (pageRequest.getSort() != null && pageRequest.getSort().iterator().hasNext()) {
|
||||
sortProperty = pageRequest.getSort().iterator().next().getProperty();
|
||||
}
|
||||
|
||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||
|
||||
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
||||
final List<Specification<Target>> specList = new ArrayList<>();
|
||||
@@ -1074,7 +1085,7 @@ public class TargetManagement {
|
||||
return targetRepository.count(specs);
|
||||
}
|
||||
|
||||
private List<Object[]> getTargetIdNameResultSet(final PageRequest pageRequest, final CriteriaBuilder cb,
|
||||
private List<Object[]> getTargetIdNameResultSet(final Pageable pageRequest, final CriteriaBuilder cb,
|
||||
final Root<Target> targetRoot, final CriteriaQuery<Object[]> multiselect) {
|
||||
List<Object[]> resultList;
|
||||
if (pageRequest.getSort() != null) {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
||||
* @param configurationKey
|
||||
* the key of the configuration
|
||||
* @return the converted configuration value either from the tenant specific
|
||||
* configuration stored or from the fallback default values or
|
||||
* configuration stored or from the fall back default values or
|
||||
* {@code null} in case key has not been configured and not default
|
||||
* value exists
|
||||
* @throws TenantConfigurationValidatorException
|
||||
|
||||
@@ -16,9 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
* The spring-data repository for the entity {@link TenantConfiguration}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public interface TenantConfigurationRepository extends BaseEntityRepository<TenantConfiguration, Long> {
|
||||
@@ -32,11 +29,6 @@ public interface TenantConfigurationRepository extends BaseEntityRepository<Tena
|
||||
*/
|
||||
TenantConfiguration findByKey(String configurationKey);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.data.repository.CrudRepository#findAll()
|
||||
*/
|
||||
@Override
|
||||
List<TenantConfiguration> findAll();
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@ import org.springframework.stereotype.Service;
|
||||
/**
|
||||
* {@link KeyGenerator} for tenant related caches.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class TenantKeyGenerator implements KeyGenerator {
|
||||
@@ -28,13 +25,6 @@ public class TenantKeyGenerator implements KeyGenerator {
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.cache.interceptor.KeyGenerator#generate(java.lang.
|
||||
* Object, java.lang.reflect.Method, java.lang.Object[])
|
||||
*/
|
||||
@Override
|
||||
public Object generate(final Object target, final Method method, final Object... params) {
|
||||
return tenantAware.getCurrentTenant().toUpperCase();
|
||||
|
||||
@@ -50,9 +50,9 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
||||
@NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"),
|
||||
@NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet") ) ) })
|
||||
@NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet"))) })
|
||||
@Entity
|
||||
public class Action extends BaseEntity implements Comparable<Action> {
|
||||
public class Action extends TenantAwareBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@@ -64,11 +64,11 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
* the {@link DistributionSet} which should be installed by this action.
|
||||
*/
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds") )
|
||||
@JoinColumn(name = "distribution_set", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_ds"))
|
||||
private DistributionSet distributionSet;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target") )
|
||||
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_target"))
|
||||
private Target target;
|
||||
|
||||
@Column(name = "active")
|
||||
@@ -90,11 +90,11 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
private List<ActionStatus> actionStatus;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "rolloutgroup", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup") )
|
||||
@JoinColumn(name = "rolloutgroup", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rolloutgroup"))
|
||||
private RolloutGroup rolloutGroup;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout") )
|
||||
@JoinColumn(name = "rollout", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_action_rollout"))
|
||||
private Rollout rollout;
|
||||
|
||||
/**
|
||||
@@ -127,55 +127,30 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
return status == Status.CANCELING || status == Status.CANCELED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param active
|
||||
* the active to set
|
||||
*/
|
||||
public void setActive(final boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* the status to set
|
||||
*/
|
||||
public void setStatus(final Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the downloadProgressPercent
|
||||
*/
|
||||
public int getDownloadProgressPercent() {
|
||||
return downloadProgressPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param downloadProgressPercent
|
||||
* the downloadProgressPercent to set
|
||||
*/
|
||||
public void setDownloadProgressPercent(final int downloadProgressPercent) {
|
||||
this.downloadProgressPercent = downloadProgressPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actionType
|
||||
* the actionType to set
|
||||
*/
|
||||
public void setActionType(final ActionType actionType) {
|
||||
this.actionType = actionType;
|
||||
}
|
||||
@@ -187,81 +162,42 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
return actionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionStatus
|
||||
*/
|
||||
public List<ActionStatus> getActionStatus() {
|
||||
return actionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target
|
||||
* the target to set
|
||||
*/
|
||||
public void setTarget(final Target target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the target
|
||||
*/
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forcedTime
|
||||
*/
|
||||
public long getForcedTime() {
|
||||
return forcedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forcedTime
|
||||
* the forcedTime to set
|
||||
*/
|
||||
public void setForcedTime(final long forcedTime) {
|
||||
this.forcedTime = forcedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rolloutGroup
|
||||
*/
|
||||
public RolloutGroup getRolloutGroup() {
|
||||
return rolloutGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rolloutGroup
|
||||
* the rolloutGroup to set
|
||||
*/
|
||||
public void setRolloutGroup(final RolloutGroup rolloutGroup) {
|
||||
this.rolloutGroup = rolloutGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rollout
|
||||
*/
|
||||
public Rollout getRollout() {
|
||||
return rollout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rollout
|
||||
* the rollout to set
|
||||
*/
|
||||
public void setRollout(final Rollout rollout) {
|
||||
this.rollout = rollout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final Action o) {
|
||||
if (super.getId() == null || o == null || o.getId() == null) {
|
||||
return 0;
|
||||
}
|
||||
return super.getId().compareTo(o.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the {@link #forcedTime} is hit by the given
|
||||
* {@code hitTimeMillis}, by means if the given milliseconds are greater
|
||||
@@ -305,66 +241,11 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
return actionType == ActionType.FORCED;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() { // NOSONAR - as this is generated
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((actionType == null) ? 0 : actionType.hashCode());
|
||||
result = prime * result + (active ? 1231 : 1237);
|
||||
result = prime * result + (int) (forcedTime ^ (forcedTime >>> 32));
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
result = prime * result + (isHitAutoForceTime(System.currentTimeMillis()) ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Action other = (Action) obj;
|
||||
if (actionType != other.actionType) {
|
||||
return false;
|
||||
}
|
||||
if (active != other.active) {
|
||||
return false;
|
||||
}
|
||||
if (forcedTime != other.forcedTime) {
|
||||
return false;
|
||||
}
|
||||
if (status != other.status) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action status as reported by the controller.
|
||||
*
|
||||
@@ -424,9 +305,6 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
||||
/**
|
||||
* The action type for this action relation.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum ActionType {
|
||||
FORCED, SOFT, TIMEFORCED;
|
||||
|
||||
@@ -32,27 +32,20 @@ import com.google.common.base.Splitter;
|
||||
|
||||
/**
|
||||
* Entity to store the status for a specific action.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Table(name = "sp_action_status", indexes = { @Index(name = "sp_idx_action_status_01", columnList = "tenant,action"),
|
||||
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
||||
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
||||
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
||||
@Entity
|
||||
public class ActionStatus extends BaseEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ActionStatus extends TenantAwareBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "target_occurred_at")
|
||||
private Long occurredAt;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "action", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action") )
|
||||
@JoinColumn(name = "action", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_act_stat_action"))
|
||||
private Action action;
|
||||
|
||||
@Column(name = "status")
|
||||
@@ -60,14 +53,14 @@ public class ActionStatus extends BaseEntity {
|
||||
|
||||
@CascadeOnDelete
|
||||
@ElementCollection(fetch = FetchType.LAZY, targetClass = String.class)
|
||||
@CollectionTable(name = "sp_action_status_messages", joinColumns = @JoinColumn(name = "action_status_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat") ) , indexes = {
|
||||
@CollectionTable(name = "sp_action_status_messages", joinColumns = @JoinColumn(name = "action_status_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_stat_msg_act_stat")), indexes = {
|
||||
@Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") })
|
||||
@Column(name = "detail_message", length = 512)
|
||||
private final List<String> messages = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new {@link ActionStatus} object.
|
||||
*
|
||||
*
|
||||
* @param action
|
||||
* the action for this action status
|
||||
* @param status
|
||||
@@ -83,7 +76,7 @@ public class ActionStatus extends BaseEntity {
|
||||
|
||||
/**
|
||||
* Creates a new {@link ActionStatus} object.
|
||||
*
|
||||
*
|
||||
* @param action
|
||||
* the action for this action status
|
||||
* @param status
|
||||
@@ -103,67 +96,48 @@ public class ActionStatus extends BaseEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
* JPA default constructor.
|
||||
*/
|
||||
public ActionStatus() {
|
||||
// JPA default constructor.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the occurredAt
|
||||
*/
|
||||
public Long getOccurredAt() {
|
||||
return occurredAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param occurredAt
|
||||
* the occurredAt to set
|
||||
*/
|
||||
public void setOccurredAt(final Long occurredAt) {
|
||||
this.occurredAt = occurredAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds message.
|
||||
* Adds message including splitting in case it exceeds 512 length.
|
||||
*
|
||||
* @param message
|
||||
* to add
|
||||
*/
|
||||
public final void addMessage(final String message) {
|
||||
Splitter.fixedLength(512).split(message).forEach(chunk -> messages.add(chunk));
|
||||
Splitter.fixedLength(512).split(message).forEach(messages::add);
|
||||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action
|
||||
*/
|
||||
public Action getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* the action to set
|
||||
*/
|
||||
public void setAction(final Action action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* the status to set
|
||||
*/
|
||||
public void setStatus(final Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
* Custom JPA Model for querying {@link Action} include the count of the
|
||||
* action's {@link ActionStatus}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ActionWithStatusCount {
|
||||
private final Long actionStatusCount;
|
||||
@@ -37,7 +34,7 @@ public class ActionWithStatusCount {
|
||||
/**
|
||||
* JPA constructor, the parameter are the result set columns of the custom
|
||||
* query.
|
||||
*
|
||||
*
|
||||
* @param actionId
|
||||
* the ID of the action
|
||||
* @param actionType
|
||||
@@ -70,9 +67,9 @@ public class ActionWithStatusCount {
|
||||
final String rolloutName) {
|
||||
this.actionId = actionId;
|
||||
this.actionType = actionType;
|
||||
this.actionActive = active;
|
||||
this.actionForceTime = forcedTime;
|
||||
this.actionStatus = status;
|
||||
actionActive = active;
|
||||
actionForceTime = forcedTime;
|
||||
actionStatus = status;
|
||||
this.actionCreatedAt = actionCreatedAt;
|
||||
this.actionLastModifiedAt = actionLastModifiedAt;
|
||||
this.dsId = dsId;
|
||||
@@ -81,101 +78,62 @@ public class ActionWithStatusCount {
|
||||
this.actionStatusCount = actionStatusCount;
|
||||
this.rolloutName = rolloutName;
|
||||
|
||||
this.action = new Action();
|
||||
this.action.setActionType(actionType);
|
||||
this.action.setActive(actionActive);
|
||||
this.action.setForcedTime(actionForceTime);
|
||||
this.action.setStatus(actionStatus);
|
||||
this.action.setId(actionId);
|
||||
action = new Action();
|
||||
action.setActionType(actionType);
|
||||
action.setActive(actionActive);
|
||||
action.setForcedTime(actionForceTime);
|
||||
action.setStatus(actionStatus);
|
||||
action.setId(actionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action
|
||||
*/
|
||||
public Action getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionId
|
||||
*/
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionType
|
||||
*/
|
||||
public ActionType getActionType() {
|
||||
return actionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionActive
|
||||
*/
|
||||
public boolean isActionActive() {
|
||||
return actionActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionForceTime
|
||||
*/
|
||||
public long getActionForceTime() {
|
||||
return actionForceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionStatus
|
||||
*/
|
||||
public Status getActionStatus() {
|
||||
return actionStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionCreatedAt
|
||||
*/
|
||||
public Long getActionCreatedAt() {
|
||||
return actionCreatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionLastModifiedAt
|
||||
*/
|
||||
public Long getActionLastModifiedAt() {
|
||||
return actionLastModifiedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dsId
|
||||
*/
|
||||
public Long getDsId() {
|
||||
return dsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dsName
|
||||
*/
|
||||
public String getDsName() {
|
||||
return dsName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dsVersion
|
||||
*/
|
||||
public String getDsVersion() {
|
||||
return dsVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionStatusCount
|
||||
*/
|
||||
public Long getActionStatusCount() {
|
||||
return actionStatusCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rolloutName
|
||||
*/
|
||||
public String getRolloutName() {
|
||||
return rolloutName;
|
||||
}
|
||||
|
||||
@@ -13,14 +13,10 @@ import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
* Tenant specific locally stored artifact representation that is used by
|
||||
* {@link SoftwareModule} .
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* {@link SoftwareModule}.
|
||||
*/
|
||||
@MappedSuperclass
|
||||
public abstract class Artifact extends BaseEntity {
|
||||
public abstract class Artifact extends TenantAwareBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "sha1_hash", length = 40, nullable = true)
|
||||
@@ -34,49 +30,27 @@ public abstract class Artifact extends BaseEntity {
|
||||
|
||||
public abstract SoftwareModule getSoftwareModule();
|
||||
|
||||
/**
|
||||
* @return the md5Hash
|
||||
*/
|
||||
public String getMd5Hash() {
|
||||
return md5Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sha1Hash
|
||||
*/
|
||||
public String getSha1Hash() {
|
||||
return sha1Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param md5Hash
|
||||
* the md5Hash to set
|
||||
*/
|
||||
public void setMd5Hash(final String md5Hash) {
|
||||
this.md5Hash = md5Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sha1Hash
|
||||
* the sha1Hash to set
|
||||
*/
|
||||
public void setSha1Hash(final String sha1Hash) {
|
||||
this.sha1Hash = sha1Hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size
|
||||
*/
|
||||
public Long getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size
|
||||
* the size to set
|
||||
*/
|
||||
public void setSize(final Long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
/**
|
||||
* Generic assigment result bean.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Generic assignment result bean.
|
||||
*
|
||||
*/
|
||||
public class AssignmentResult {
|
||||
@@ -36,23 +33,14 @@ public class AssignmentResult {
|
||||
total = assigned + alreadyAssigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the assignedTargets
|
||||
*/
|
||||
public int getAssigned() {
|
||||
return assigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the total
|
||||
*/
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alreadyAssigned
|
||||
*/
|
||||
public int getAlreadyAssigned() {
|
||||
return alreadyAssigned;
|
||||
}
|
||||
|
||||
@@ -18,17 +18,10 @@ import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.CacheFieldEntityListener;
|
||||
import org.eclipse.hawkbit.eventbus.EntityPropertyChangeListener;
|
||||
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.TenantAwareHolder;
|
||||
import org.eclipse.persistence.annotations.Multitenant;
|
||||
import org.eclipse.persistence.annotations.MultitenantType;
|
||||
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
@@ -37,18 +30,12 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
import org.springframework.hateoas.Identifiable;
|
||||
|
||||
/**
|
||||
* Holder of all base attributes common to all entities.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Holder of the base attributes common to all entities.
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
@Access(AccessType.FIELD)
|
||||
@EntityListeners({ AuditingEntityListener.class, CacheFieldEntityListener.class, EntityPropertyChangeListener.class })
|
||||
@TenantDiscriminatorColumn(name = "tenant", length = 40)
|
||||
@Multitenant(MultitenantType.SINGLE_TABLE)
|
||||
public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -66,44 +53,11 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
@Column(name = "optlock_revision")
|
||||
private long optLockRevision;
|
||||
|
||||
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
|
||||
private String tenant;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
* Default constructor needed for JPA entities.
|
||||
*/
|
||||
public BaseEntity() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* the entity to copy
|
||||
*/
|
||||
public BaseEntity(final BaseEntity entity) {
|
||||
id = entity.id;
|
||||
createdAt = entity.createdAt;
|
||||
createdBy = entity.createdBy;
|
||||
lastModifiedAt = entity.lastModifiedAt;
|
||||
lastModifiedBy = entity.lastModifiedBy;
|
||||
optLockRevision = entity.optLockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* PrePersist listener method for all {@link BaseEntity} entities.
|
||||
*/
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
// before persisting the entity check the current ID of the tenant by
|
||||
// using the TenantAware
|
||||
// service
|
||||
final String currentTenant = SystemManagementHolder.getInstance().currentTenant();
|
||||
if (currentTenant == null) {
|
||||
throw new TenantNotExistException("Tenant "
|
||||
+ TenantAwareHolder.getInstance().getTenantAware().getCurrentTenant()
|
||||
+ " does not exists, cannot create entity " + this.getClass() + " with id " + id);
|
||||
}
|
||||
setTenant(currentTenant.toUpperCase());
|
||||
// Default constructor needed for JPA entities.
|
||||
}
|
||||
|
||||
@Access(AccessType.PROPERTY)
|
||||
@@ -130,37 +84,21 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
return lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdBy
|
||||
* the createdBy to set
|
||||
*/
|
||||
@CreatedBy
|
||||
public void setCreatedBy(final String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastModifiedBy
|
||||
* the lastModifiedBy to set
|
||||
*/
|
||||
@LastModifiedBy
|
||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||
this.lastModifiedBy = lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createdAt
|
||||
* the createdAt to set
|
||||
*/
|
||||
@CreatedDate
|
||||
public void setCreatedAt(final Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastModifiedAt
|
||||
* the lastModifiedAt to set
|
||||
*/
|
||||
@LastModifiedDate
|
||||
public void setLastModifiedAt(final Long lastModifiedAt) {
|
||||
this.lastModifiedAt = lastModifiedAt;
|
||||
@@ -170,49 +108,29 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
return optLockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tenant
|
||||
*/
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
// for test purposes only
|
||||
void setOptLockRevision(final long optLockRevision) {
|
||||
this.optLockRevision = optLockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenant
|
||||
* the tenant to set
|
||||
*/
|
||||
public void setTenant(final String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseEntity [id=" + id + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
/**
|
||||
* Defined equals/hashcode strategy for the repository in general is that an
|
||||
* entity is equal if it has the same {@link #getId()} and
|
||||
* {@link #getOptLockRevision()} and class.
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@@ -222,11 +140,14 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
result = prime * result + (int) (optLockRevision ^ optLockRevision >>> 32);
|
||||
result = prime * result + this.getClass().getName().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
/**
|
||||
* Defined equals/hashcode strategy for the repository in general is that an
|
||||
* entity is equal if it has the same {@link #getId()} and
|
||||
* {@link #getOptLockRevision()} and class.
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@@ -239,7 +160,7 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if (!(this.getClass().isInstance(obj))) {
|
||||
return false;
|
||||
}
|
||||
final BaseEntity other = (BaseEntity) obj;
|
||||
|
||||
@@ -13,9 +13,6 @@ import java.io.Serializable;
|
||||
/**
|
||||
* Use to display software modules for the selected distribution.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CustomSoftwareModule implements Serializable {
|
||||
|
||||
@@ -39,17 +36,51 @@ public class CustomSoftwareModule implements Serializable {
|
||||
this.assigned = assigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the softwareModule
|
||||
*/
|
||||
public SoftwareModule getSoftwareModule() {
|
||||
return softwareModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the assigned
|
||||
*/
|
||||
public boolean isAssigned() {
|
||||
return assigned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CustomSoftwareModule [softwareModule=" + softwareModule + ", assigned=" + assigned + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (assigned ? 1231 : 1237);
|
||||
result = prime * result + (softwareModule == null ? 0 : softwareModule.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof CustomSoftwareModule)) {
|
||||
return false;
|
||||
}
|
||||
final CustomSoftwareModule other = (CustomSoftwareModule) obj;
|
||||
if (assigned != other.assigned) {
|
||||
return false;
|
||||
}
|
||||
if (softwareModule == null) {
|
||||
if (other.softwareModule != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!softwareModule.equals(other.softwareModule)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,10 +46,6 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||
@@ -67,14 +63,14 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
|
||||
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "sp_ds_module", joinColumns = {
|
||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds") ) }, inverseJoinColumns = {
|
||||
@JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module") ) })
|
||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds")) }, inverseJoinColumns = {
|
||||
@JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||
private final Set<SoftwareModule> modules = new HashSet<>();
|
||||
|
||||
@ManyToMany(targetEntity = DistributionSetTag.class)
|
||||
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
||||
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds") ) }, inverseJoinColumns = {
|
||||
@JoinColumn(name = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag") ) })
|
||||
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds")) }, inverseJoinColumns = {
|
||||
@JoinColumn(name = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||
|
||||
@Column(name = "deleted")
|
||||
@@ -95,7 +91,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
private final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds") )
|
||||
@JoinColumn(name = "ds_id", nullable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstype_ds"))
|
||||
private DistributionSetType type;
|
||||
|
||||
@Column(name = "complete")
|
||||
@@ -130,75 +126,34 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
if (moduleList != null) {
|
||||
moduleList.forEach(this::addModule);
|
||||
}
|
||||
complete = type.checkComplete(this);
|
||||
if (this.type != null) {
|
||||
complete = this.type.checkComplete(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<DistributionSetTag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deleted
|
||||
*/
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the metadata
|
||||
* @return immutable list of meta data elements.
|
||||
*/
|
||||
public List<DistributionSetMetadata> getMetadata() {
|
||||
return metadata;
|
||||
return Collections.unmodifiableList(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actions
|
||||
*/
|
||||
public List<Action> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + this.getClass().getName().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DistributionSet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isRequiredMigrationStep() {
|
||||
return requiredMigrationStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param deleted
|
||||
* the deleted to set
|
||||
*/
|
||||
public DistributionSet setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
@@ -209,10 +164,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tags
|
||||
* the tags to set
|
||||
*/
|
||||
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
@@ -232,11 +183,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
return installedAtTargets;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
||||
@@ -322,7 +268,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
* Searches through modules for the given type.
|
||||
*
|
||||
* @param type
|
||||
* to seach for
|
||||
* to search for
|
||||
* @return SoftwareModule of given type or <code>null</code> if not in the
|
||||
* list.
|
||||
*/
|
||||
@@ -337,26 +283,15 @@ public class DistributionSet extends NamedVersionedEntity {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public DistributionSetType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(final DistributionSetType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the complete
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.io.Serializable;
|
||||
*
|
||||
*/
|
||||
public class DistributionSetIdName implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
@@ -39,9 +36,6 @@ public class DistributionSetIdName implements Serializable {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -50,40 +44,27 @@ public class DistributionSetIdName implements Serializable {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() { // NOSONAR - as this is generated
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
if (!(obj instanceof DistributionSetIdName)) {
|
||||
return false;
|
||||
}
|
||||
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
||||
@@ -97,11 +78,6 @@ public class DistributionSetIdName implements Serializable {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
// only return the ID because it's used in vaadin for setting the item
|
||||
|
||||
@@ -23,20 +23,13 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Metadata for {@link DistributionSet}.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Meta data for {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
@IdClass(DsMetadataCompositeKey.class)
|
||||
@Entity
|
||||
@Table(name = "sp_ds_metadata")
|
||||
public class DistributionSetMetadata implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@@ -49,11 +42,11 @@ public class DistributionSetMetadata implements Serializable {
|
||||
|
||||
@Id
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds") )
|
||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_ds"))
|
||||
private DistributionSet distributionSet;
|
||||
|
||||
public DistributionSetMetadata() {
|
||||
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,49 +66,66 @@ public class DistributionSetMetadata implements Serializable {
|
||||
return new DsMetadataCompositeKey(distributionSet, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param distributionSet
|
||||
* the distributionSet to set
|
||||
*/
|
||||
public void setDistributionSet(final DistributionSet distributionSet) {
|
||||
this.distributionSet = distributionSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* the value to set
|
||||
*/
|
||||
public void setValue(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the distributionSet
|
||||
*/
|
||||
public DistributionSet getDistributionSet() {
|
||||
return distributionSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (distributionSet == null ? 0 : distributionSet.hashCode());
|
||||
result = prime * result + (key == null ? 0 : key.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DistributionSetMetadata)) {
|
||||
return false;
|
||||
}
|
||||
final DistributionSetMetadata other = (DistributionSetMetadata) obj;
|
||||
if (distributionSet == null) {
|
||||
if (other.distributionSet != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!distributionSet.equals(other.distributionSet)) {
|
||||
return false;
|
||||
}
|
||||
if (key == null) {
|
||||
if (other.key != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!key.equals(other.key)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,16 +21,11 @@ import javax.persistence.UniqueConstraint;
|
||||
* A {@link DistributionSetTag} is used to describe DistributionSet attributes
|
||||
* and use them also for filtering the DistributionSet list.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_distributionset_tag", indexes = {
|
||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||
"name", "tenant" }, name = "uk_ds_tag") )
|
||||
"name", "tenant" }, name = "uk_ds_tag"))
|
||||
public class DistributionSetTag extends Tag {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -69,11 +64,6 @@ public class DistributionSetTag extends Tag {
|
||||
return assignedToDistributionSet;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -82,16 +72,8 @@ public class DistributionSetTag extends Tag {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ package org.eclipse.hawkbit.repository.model;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Result object for {@link DistributionSetTag} assigments.
|
||||
* Result object for {@link DistributionSetTag} assignments.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
||||
public class DistributionSetTagAssignmentResult extends AssignmentResult {
|
||||
|
||||
private final int unassigned;
|
||||
private final List<DistributionSet> assignedDs;
|
||||
@@ -37,7 +37,7 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
||||
* @param distributionSetTag
|
||||
* the assigned or unassigned tag
|
||||
*/
|
||||
public DistributionSetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
||||
final DistributionSetTag distributionSetTag) {
|
||||
super(assigned, alreadyAssigned);
|
||||
@@ -47,30 +47,18 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
||||
this.distributionSetTag = distributionSetTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unassigned
|
||||
*/
|
||||
public int getUnassigned() {
|
||||
return unassigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the distributionSetTag
|
||||
*/
|
||||
public DistributionSetTag getDistributionSetTag() {
|
||||
return distributionSetTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the assignedDs
|
||||
*/
|
||||
public List<DistributionSet> getAssignedDs() {
|
||||
return assignedDs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unassignedDs
|
||||
*/
|
||||
public List<DistributionSet> getUnassignedDs() {
|
||||
return unassignedDs;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user