Merge branch 'master' into Methods_only_called_by_inner_classes_should_move_to_those_classes
Conflicts: hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgroup/RolloutGroupListGrid.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rolloutgrouptargets/RolloutGroupTargetsListGrid.java Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@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.support has changed to hawkbit.server.ui.links.support
|
||||||
- hawkbit.server.email.request.account has changed to hawkbit.server.ui.links.requestAccount
|
- 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
|
- 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).
|
* 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.
|
* 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
|
# 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
|
# 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.
|
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
|
java -jar examples/hawkbit-device-simulator/target/hawkbit-device-simulator-*-SNAPSHOT.jar
|
||||||
```
|
```
|
||||||
@@ -11,6 +11,11 @@ Or:
|
|||||||
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Deploy to cloud foundry environment
|
||||||
|
|
||||||
|
- Go to ```target``` subfolder.
|
||||||
|
- Run ```cf push```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
The simulator has user authentication enabled in **cloud profile**. Default credentials:
|
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
|
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
|
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
|
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>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</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>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice.Protocol;
|
||||||
import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
|
||||||
import org.eclipse.hawkbit.simulator.event.InitUpdate;
|
import org.eclipse.hawkbit.simulator.event.InitUpdate;
|
||||||
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
|
import org.eclipse.hawkbit.simulator.event.ProgressUpdate;
|
||||||
@@ -34,6 +35,9 @@ public class DeviceSimulatorUpdater {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SpSenderService spSenderService;
|
private SpSenderService spSenderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimulatedDeviceFactory deviceFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EventBus eventbus;
|
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,
|
public void startUpdate(final String tenant, final String id, final long actionId, final String swVersion,
|
||||||
final UpdaterCallback callback) {
|
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.setProgress(0.0);
|
||||||
device.setSwversion(swVersion);
|
device.setSwversion(swVersion);
|
||||||
eventbus.post(new InitUpdate(device));
|
eventbus.post(new InitUpdate(device));
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class SimulationController {
|
|||||||
* number of delay in milliseconds to delay polling of DDI
|
* number of delay in milliseconds to delay polling of DDI
|
||||||
* devices
|
* devices
|
||||||
* @param gatewayToken
|
* @param gatewayToken
|
||||||
* the hawkbit-update-server gatwaytoken in case authentication
|
* the hawkbit-update-server gatewaytoken in case authentication
|
||||||
* is enforced in hawkbit
|
* is enforced in hawkbit
|
||||||
* @return a response string that devices has been created
|
* @return a response string that devices has been created
|
||||||
* @throws MalformedURLException
|
* @throws MalformedURLException
|
||||||
@@ -68,7 +68,7 @@ public class SimulationController {
|
|||||||
@RequestParam(value = "endpoint", defaultValue = "http://localhost:8080") final String endpoint,
|
@RequestParam(value = "endpoint", defaultValue = "http://localhost:8080") final String endpoint,
|
||||||
@RequestParam(value = "polldelay", defaultValue = "30") final int pollDelay,
|
@RequestParam(value = "polldelay", defaultValue = "30") final int pollDelay,
|
||||||
@RequestParam(value = "gatewaytoken", defaultValue = "") final String gatewayToken)
|
@RequestParam(value = "gatewaytoken", defaultValue = "") final String gatewayToken)
|
||||||
throws MalformedURLException {
|
throws MalformedURLException {
|
||||||
|
|
||||||
final Protocol protocol;
|
final Protocol protocol;
|
||||||
switch (api.toLowerCase()) {
|
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
|
* @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
|
* @return the exchange
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,26 +19,25 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties("hawkbit.device.simulator.amqp")
|
@ConfigurationProperties("hawkbit.device.simulator.amqp")
|
||||||
public class AmqpProperties {
|
public class AmqpProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue for receiving DMF messages from update server.
|
* Queue for receiving DMF messages from update server.
|
||||||
*/
|
*/
|
||||||
private String receiverConnectorQueueFromSp;
|
private String receiverConnectorQueueFromSp = "simulator_receiver";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange for sending DMF messages to update server.
|
* Exchange for sending DMF messages to update server.
|
||||||
*/
|
*/
|
||||||
private String senderForSpExchange;
|
private String senderForSpExchange = "simulator.replyTo";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulator dead letter queue.
|
* Simulator dead letter queue.
|
||||||
*/
|
*/
|
||||||
private String deadLetterQueue;
|
private String deadLetterQueue = "simulator_deadletter";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulator dead letter exchange.
|
* Simulator dead letter exchange.
|
||||||
*/
|
*/
|
||||||
private String deadLetterExchange;
|
private String deadLetterExchange = "simulator.deadletter";
|
||||||
|
|
||||||
public String getReceiverConnectorQueueFromSp() {
|
public String getReceiverConnectorQueueFromSp() {
|
||||||
return receiverConnectorQueueFromSp;
|
return receiverConnectorQueueFromSp;
|
||||||
|
|||||||
@@ -26,14 +26,11 @@ import org.springframework.messaging.handler.annotation.Header;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle all incoming Messages from SP.
|
* Handle all incoming Messages from hawkBit update server.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SpReceiverService extends ReceiverService {
|
public class SpReceiverService extends ReceiverService {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiverService.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiverService.class);
|
||||||
|
|
||||||
public static final String SOFTWARE_MODULE_FIRMWARE = "firmware";
|
public static final String SOFTWARE_MODULE_FIRMWARE = "firmware";
|
||||||
@@ -44,17 +41,6 @@ public class SpReceiverService extends ReceiverService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* 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
|
@Autowired
|
||||||
public SpReceiverService(final RabbitTemplate rabbitTemplate, final AmqpProperties amqpProperties,
|
public SpReceiverService(final RabbitTemplate rabbitTemplate, final AmqpProperties amqpProperties,
|
||||||
@@ -62,12 +48,11 @@ public class SpReceiverService extends ReceiverService {
|
|||||||
super(rabbitTemplate, amqpProperties);
|
super(rabbitTemplate, amqpProperties);
|
||||||
this.spSenderService = spSenderService;
|
this.spSenderService = spSenderService;
|
||||||
this.deviceUpdater = deviceUpdater;
|
this.deviceUpdater = deviceUpdater;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the incoming Message from Queue with the property
|
* Handle the incoming Message from Queue with the property
|
||||||
* (com.bosch.sp.lwm2m.connector.amqp.receiverConnectorQueueFromSp).
|
* (hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp).
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* the incoming message
|
* the incoming message
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
|||||||
public void pollCounterUpdate(final NextPollCounterUpdate update) {
|
public void pollCounterUpdate(final NextPollCounterUpdate update) {
|
||||||
final List<AbstractSimulatedDevice> devices = update.getDevices();
|
final List<AbstractSimulatedDevice> devices = update.getDevices();
|
||||||
this.getUI().access(new Runnable() {
|
this.getUI().access(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
devices.forEach(device -> {
|
devices.forEach(device -> {
|
||||||
@@ -176,6 +177,7 @@ public class SimulatorView extends VerticalLayout implements View {
|
|||||||
public void initUpdate(final InitUpdate update) {
|
public void initUpdate(final InitUpdate update) {
|
||||||
final AbstractSimulatedDevice device = update.getDevice();
|
final AbstractSimulatedDevice device = update.getDevice();
|
||||||
this.getUI().access(new Runnable() {
|
this.getUI().access(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
final BeanItem<AbstractSimulatedDevice> item = beanContainer.getItem(device.getId());
|
||||||
|
|||||||
@@ -7,18 +7,17 @@
|
|||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
#
|
#
|
||||||
|
|
||||||
|
## Configuration for DMF communication
|
||||||
#########################################################################################
|
|
||||||
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
|
||||||
#########################################################################################
|
|
||||||
## Configuration for RabbitMQ communication
|
|
||||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
||||||
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
||||||
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
||||||
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
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.username=guest
|
||||||
spring.rabbitmq.password=guest
|
spring.rabbitmq.password=guest
|
||||||
spring.rabbitmq.virtualHost=/
|
spring.rabbitmq.virtualHost=/
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
# hawkBit Example Application
|
# 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
|
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar
|
||||||
```
|
```
|
||||||
@@ -10,6 +18,14 @@ Or:
|
|||||||
run org eclipse.hawkbit.app.Start
|
run org eclipse.hawkbit.app.Start
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
### Usage
|
||||||
The UI can be accessed via _http://localhost:8080/UI_.
|
The Management UI can be accessed via http://localhost:8080/UI
|
||||||
The REST API can be accessed via _http://localhost:8080/rest/v1_.
|
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>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</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>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.app;
|
package org.eclipse.hawkbit.app;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||||
|
import org.eclipse.hawkbit.ui.UIEventProvider;
|
||||||
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ public class MyUI extends HawkbitUI {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus) {
|
public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus,
|
||||||
super(new DelayedEventBusPushStrategy(eventBus, systemEventBus));
|
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.
|
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
|
* assigning software modules to distribution sets
|
||||||
* creating a rollout
|
* creating a rollout
|
||||||
* starting 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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
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.
|
* 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 {
|
public interface TargetTagResourceClient extends TargetTagRestApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,7 @@ import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRe
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Builder pattern for building {@link DistributionSetRequestBodyPost}.
|
* Builder pattern for building {@link DistributionSetRequestBodyPost}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DistributionSetBuilder {
|
public class DistributionSetBuilder {
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link DistributionSetTypeRequestBodyPost}.
|
* Builder pattern for building {@link DistributionSetTypeRequestBodyPost}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetTypeBuilder {
|
public class DistributionSetTypeBuilder {
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import org.eclipse.hawkbit.rest.resource.model.rollout.RolloutRestRequestBody;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link RolloutRestRequestBody}.
|
* Builder pattern for building {@link RolloutRestRequestBody}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RolloutBuilder {
|
public class RolloutBuilder {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssi
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link SoftwareModuleAssigmentRest}.
|
* Builder pattern for building {@link SoftwareModuleAssigmentRest}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SoftwareModuleAssigmentBuilder {
|
public class SoftwareModuleAssigmentBuilder {
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SoftwareModuleBuilder {
|
public class SoftwareModuleBuilder {
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
* Builder pattern for building {@link SoftwareModuleRequestBodyPost}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SoftwareModuleTypeBuilder {
|
public class SoftwareModuleTypeBuilder {
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder pattern for building {@link TagRequestBodyPut}.
|
* Builder pattern for building {@link TagRequestBodyPut}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TagBuilder {
|
public class TagBuilder {
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import com.google.common.collect.Lists;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Builder pattern for building {@link TargetRequestBody}.
|
* Builder pattern for building {@link TargetRequestBody}.
|
||||||
*
|
|
||||||
* @author Jonathan Knoblauch
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TargetBuilder {
|
public class TargetBuilder {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.mgmt.client.scenarios;
|
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.DistributionSetResourceClient;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.RolloutResourceClient;
|
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.SoftwareModuleBuilder;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder;
|
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleTypeBuilder;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.TargetBuilder;
|
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.rollout.RolloutResponseBody;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModulesRest;
|
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypesRest;
|
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ public class CreateStartedRolloutExample {
|
|||||||
private static final String SM_MODULE_TYPE = "firmware";
|
private static final String SM_MODULE_TYPE = "firmware";
|
||||||
|
|
||||||
/* known distribution set type name and key */
|
/* 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
|
@Autowired
|
||||||
private DistributionSetResourceClient distributionSetResource;
|
private DistributionSetResourceClient distributionSetResource;
|
||||||
@@ -65,8 +67,9 @@ public class CreateStartedRolloutExample {
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// create three SoftwareModuleTypes
|
// create three SoftwareModuleTypes
|
||||||
final SoftwareModuleTypesRest createdSoftwareModuleTypes = softwareModuleTypeResource.createSoftwareModuleTypes(
|
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||||
new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE).maxAssignments(1).build())
|
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||||
|
.maxAssignments(1).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
// create one DistributionSetType
|
// create one DistributionSetType
|
||||||
@@ -75,12 +78,12 @@ public class CreateStartedRolloutExample {
|
|||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
// create one DistributionSet
|
// 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())
|
new DistributionSetBuilder().name("rollout-example").version("1.0.0").type(DS_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
// create three SoftwareModules
|
// create three SoftwareModules
|
||||||
final SoftwareModulesRest softwareModulesRest = softwareModuleResource
|
final List<SoftwareModuleRest> softwareModulesRest = softwareModuleResource
|
||||||
.createSoftwareModules(
|
.createSoftwareModules(
|
||||||
new SoftwareModuleBuilder().name("firmware").version("1.0.0").type(SM_MODULE_TYPE).build())
|
new SoftwareModuleBuilder().name("firmware").version("1.0.0").type(SM_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.mgmt.client.scenarios;
|
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.DistributionSetResourceClient;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleResourceClient;
|
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.SoftwareModuleAssigmentBuilder;
|
||||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleBuilder;
|
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.SoftwareModuleTypeBuilder;
|
||||||
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.softwaremodule.SoftwareModulesRest;
|
import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest;
|
||||||
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypesRest;
|
import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -39,13 +41,13 @@ public class GettingStartedDefaultScenario {
|
|||||||
private static final String SM_MODULE_TYPE = "gettingstarted";
|
private static final String SM_MODULE_TYPE = "gettingstarted";
|
||||||
|
|
||||||
/* known distribution set type name and key */
|
/* 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 */
|
/* known distribution name of this getting started example */
|
||||||
private static final String SM_EXAMPLE_NAME = "gettingstarted-example";
|
private static final String SM_EXAMPLE_NAME = "gettingstarted-example";
|
||||||
|
|
||||||
/* known distribution name of this getting started 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
|
@Autowired
|
||||||
private DistributionSetResourceClient distributionSetResource;
|
private DistributionSetResourceClient distributionSetResource;
|
||||||
@@ -68,8 +70,9 @@ public class GettingStartedDefaultScenario {
|
|||||||
|
|
||||||
// create one SoftwareModuleTypes
|
// create one SoftwareModuleTypes
|
||||||
LOGGER.info("Creating software module type {}", SM_MODULE_TYPE);
|
LOGGER.info("Creating software module type {}", SM_MODULE_TYPE);
|
||||||
final SoftwareModuleTypesRest createdSoftwareModuleTypes = softwareModuleTypeResource.createSoftwareModuleTypes(
|
final List<SoftwareModuleTypeRest> createdSoftwareModuleTypes = softwareModuleTypeResource
|
||||||
new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE).maxAssignments(1).build())
|
.createSoftwareModuleTypes(new SoftwareModuleTypeBuilder().key(SM_MODULE_TYPE).name(SM_MODULE_TYPE)
|
||||||
|
.maxAssignments(1).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
// create one DistributionSetType
|
// create one DistributionSetType
|
||||||
@@ -83,17 +86,17 @@ public class GettingStartedDefaultScenario {
|
|||||||
final String dsVersion3 = "2.1.0";
|
final String dsVersion3 = "2.1.0";
|
||||||
|
|
||||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion1);
|
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())
|
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion1).type(DS_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion2);
|
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())
|
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion2).type(DS_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
LOGGER.info("Creating distribution set {}:{}", DS_EXAMPLE_NAME, dsVersion3);
|
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())
|
new DistributionSetBuilder().name(DS_EXAMPLE_NAME).version(dsVersion3).type(DS_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
@@ -103,15 +106,15 @@ public class GettingStartedDefaultScenario {
|
|||||||
final String swVersion3 = "3";
|
final String swVersion3 = "3";
|
||||||
|
|
||||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion1);
|
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())
|
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion1).type(SM_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion2);
|
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())
|
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion2).type(SM_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
LOGGER.info("Creating distribution set {}:{}", SM_EXAMPLE_NAME, swVersion3);
|
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())
|
new SoftwareModuleBuilder().name(SM_EXAMPLE_NAME).version(swVersion3).type(SM_MODULE_TYPE).build())
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ import com.mongodb.gridfs.GridFSDBFile;
|
|||||||
import com.mongodb.gridfs.GridFSFile;
|
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 {
|
public class ArtifactStore implements ArtifactRepository {
|
||||||
@@ -60,7 +57,7 @@ public class ArtifactStore implements ArtifactRepository {
|
|||||||
private static final String MD5 = "md5";
|
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.
|
* object.
|
||||||
*/
|
*/
|
||||||
private static final String SHA1 = "sha1";
|
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.
|
* 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
|
* @param sha1Hash
|
||||||
* the sha1-hash of the file to lookup.
|
* 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
|
@Override
|
||||||
public DbArtifact getArtifactBySha1(final String sha1Hash) {
|
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
|
* @return a paged list of artifacts mapped from the given dbFiles
|
||||||
*/
|
*/
|
||||||
private List<DbArtifact> map(final List<GridFSDBFile> dbFiles) {
|
private List<DbArtifact> map(final List<GridFSDBFile> dbFiles) {
|
||||||
final List<DbArtifact> collect = dbFiles.stream().map(dbFile -> map(dbFile)).collect(Collectors.toList());
|
return dbFiles.stream().map(dbFile -> map(dbFile)).collect(Collectors.toList());
|
||||||
return collect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,7 +233,7 @@ public class ArtifactStore implements ArtifactRepository {
|
|||||||
* the tenant to retrieve the artifacts from, ignore case.
|
* the tenant to retrieve the artifacts from, ignore case.
|
||||||
* @param sha1Hashes
|
* @param sha1Hashes
|
||||||
* the sha1-hashes of the files to lookup.
|
* the sha1-hashes of the files to lookup.
|
||||||
* @return list of artfiacts
|
* @return list of artifacts
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DbArtifact> getArtifactsBySha1(final List<String> sha1Hashes) {
|
public List<DbArtifact> getArtifactsBySha1(final List<String> sha1Hashes) {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
package org.eclipse.hawkbit.autoconfigure.ui;
|
package org.eclipse.hawkbit.autoconfigure.ui;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.DistributedResourceBundleMessageSource;
|
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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.vaadin.spring.annotation.EnableVaadinExtensions;
|
import org.vaadin.spring.annotation.EnableVaadinExtensions;
|
||||||
@@ -17,9 +20,6 @@ import org.vaadin.spring.security.annotation.EnableVaadinSecurity;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The hawkbit-ui autoconfiguration.
|
* The hawkbit-ui autoconfiguration.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableVaadinSecurity
|
@EnableVaadinSecurity
|
||||||
@@ -37,4 +37,15 @@ public class UIAutoConfiguration {
|
|||||||
return new DistributedResourceBundleMessageSource();
|
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
|
* Maximum polling time that can be configured by a tenant in HH:MM:SS
|
||||||
* notation.
|
* 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
|
* 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.
|
* Database representation of artifact.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DbArtifact {
|
public class DbArtifact {
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ package org.eclipse.hawkbit.artifact.repository.model;
|
|||||||
/**
|
/**
|
||||||
* Database representation of artifact hash.
|
* Database representation of artifact hash.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DbArtifactHash {
|
public class DbArtifactHash {
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,15 @@ public final class DurationHelper {
|
|||||||
this.max = max;
|
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) {
|
public boolean isWithinRange(final Duration duration) {
|
||||||
return duration.compareTo(min) > 0 && duration.compareTo(max) < 0;
|
return duration.compareTo(min) >= 0 && duration.compareTo(max) <= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ public enum TenantConfigurationKey {
|
|||||||
/**
|
/**
|
||||||
* string value which holds the polling time interval in the format HH:mm:ss
|
* 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
|
* 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);
|
||||||
|
|
||||||
private final String keyName;
|
private final String keyName;
|
||||||
private final String defaultKeyName;
|
private final String defaultKeyName;
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ public interface AmqpSenderService {
|
|||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* the amqp message
|
* the amqp message
|
||||||
* @param uri
|
* @param replyTo
|
||||||
* the reply to uri
|
* 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
|
* Extract the exchange from the uri. Default implementation removes the
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class BaseAmqpService {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T convertMessage(final Message message, final Class<T> clazz) {
|
public <T> T convertMessage(final Message message, final Class<T> clazz) {
|
||||||
if (message == null || message.getBody() == null) {
|
if (isMessageBodyEmpty(message)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
||||||
@@ -67,6 +67,10 @@ public class BaseAmqpService {
|
|||||||
return (T) rabbitTemplate.getMessageConverter().fromMessage(message);
|
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
|
* Is needed to convert a incoming message to is originally list object
|
||||||
* type.
|
* type.
|
||||||
@@ -79,7 +83,7 @@ public class BaseAmqpService {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> List<T> convertMessageList(final Message message, final Class<T> clazz) {
|
public <T> List<T> convertMessageList(final Message message, final Class<T> clazz) {
|
||||||
if (message == null || message.getBody() == null) {
|
if (isMessageBodyEmpty(message)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
|
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) {
|
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);
|
throw new IllegalArgumentException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
|
||||||
@@ -33,8 +34,12 @@ public class DefaultAmqpSenderService implements AmqpSenderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(final Message message, final URI uri) {
|
public void sendMessage(final Message message, final URI replyTo) {
|
||||||
internalAmqpTemplate.send(extractExchange(uri), null, message);
|
if (!IpUtil.isAmqpUri(replyTo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
internalAmqpTemplate.send(extractExchange(replyTo), null, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.security;
|
package org.eclipse.hawkbit.security;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -20,6 +21,7 @@ import org.springframework.security.authentication.InsufficientAuthenticationExc
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
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.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
@@ -38,11 +40,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
|
private TenantAwareWebAuthenticationDetails webAuthenticationDetailsMock;
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing in case the containing controllerId in the URI request path does
|
@Description("Testing in case the containing controllerId in the URI request path does not accord with the controllerId in the request header.")
|
||||||
* not accord with the controllerId in the request header.
|
|
||||||
*/
|
|
||||||
@Test(expected = BadCredentialsException.class)
|
|
||||||
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
|
public void principalAndCredentialsNotTheSameThrowsAuthenticationException() {
|
||||||
final String principal = "controllerIdURL";
|
final String principal = "controllerIdURL";
|
||||||
final String credentials = "controllerIdHeader";
|
final String credentials = "controllerIdHeader";
|
||||||
@@ -51,15 +50,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
token.setDetails(webAuthenticationDetailsMock);
|
token.setDetails(webAuthenticationDetailsMock);
|
||||||
|
|
||||||
// test, should throw authentication exception
|
// 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
|
@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() {
|
public void principalAndCredentialsAreTheSameWithNoSourceIpCheckIsSuccessful() {
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
final String credentials = "controllerId";
|
final String credentials = "controllerId";
|
||||||
@@ -71,12 +72,8 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing that the controllerId in the URI request match with the
|
@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.")
|
||||||
* controllerId in the request header but the request are not coming from a
|
|
||||||
* trustful source.
|
|
||||||
*/
|
|
||||||
@Test(expected = InsufficientAuthenticationException.class)
|
|
||||||
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
|
public void priniciapAndCredentialsAreTheSameButSourceIpRequestNotMatching() {
|
||||||
final String remoteAddress = "192.168.1.1";
|
final String remoteAddress = "192.168.1.1";
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
@@ -88,16 +85,17 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
|
when(webAuthenticationDetailsMock.getRemoteAddress()).thenReturn(remoteAddress);
|
||||||
|
|
||||||
// test, should throw authentication exception
|
// 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) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Testing that the controllerId in the URI request match with the
|
@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.")
|
||||||
* controllerId in the request header and the source Ip is matching the
|
|
||||||
* allowed remote IP address.
|
|
||||||
*/
|
|
||||||
@Test()
|
|
||||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
|
public void priniciapAndCredentialsAreTheSameAndSourceIpIsTrusted() {
|
||||||
final String principal = "controllerId";
|
final String principal = "controllerId";
|
||||||
final String credentials = "controllerId";
|
final String credentials = "controllerId";
|
||||||
@@ -112,7 +110,7 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
assertThat(authenticate.isAuthenticated()).isTrue();
|
assertThat(authenticate.isAuthenticated()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test
|
||||||
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
|
public void priniciapAndCredentialsAreTheSameAndSourceIpIsWithinList() {
|
||||||
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
|
final String[] trustedIPAddresses = new String[] { "192.168.1.1", "192.168.1.2", REQUEST_SOURCE_IP,
|
||||||
"192.168.1.3" };
|
"192.168.1.3" };
|
||||||
@@ -148,6 +146,11 @@ public class PreAuthTokenSourceTrustAuthenticationProviderTest {
|
|||||||
|
|
||||||
// test, should throw authentication exception
|
// test, should throw authentication exception
|
||||||
final Authentication authenticate = underTestWithList.authenticate(token);
|
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>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ package org.eclipse.hawkbit;
|
|||||||
/**
|
/**
|
||||||
* A constant class which holds only static constants used within the SP server.
|
* A constant class which holds only static constants used within the SP server.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
@@ -27,7 +24,7 @@ public final class Constants {
|
|||||||
public static final int MAX_ENTRIES_IN_STATEMENT = 999;
|
public static final int MAX_ENTRIES_IN_STATEMENT = 999;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constant class only private constructor.
|
* Constant class only private constructor.
|
||||||
*/
|
*/
|
||||||
private Constants() {
|
private Constants() {
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
|
import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler;
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
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.TenantConfigurationManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.model.helper.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
|
import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||||
@@ -127,23 +127,11 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
return new ExceptionMappingAspectHandler();
|
return new ExceptionMappingAspectHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
|
||||||
* createJpaVendorAdapter()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
|
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
|
||||||
return new EclipseLinkJpaVendorAdapter();
|
return new EclipseLinkJpaVendorAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#
|
|
||||||
* getVendorProperties()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, Object> getVendorProperties() {
|
protected Map<String, Object> getVendorProperties() {
|
||||||
|
|
||||||
|
|||||||
@@ -167,11 +167,6 @@ public class ExceptionMappingAspectHandler implements Ordered {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.core.Ordered#getOrder()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent;
|
|||||||
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
|
||||||
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
||||||
import org.eclipse.hawkbit.repository.TargetRepository;
|
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.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
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
|
* 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.eventbus.event.RolloutPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
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.Rollout;
|
||||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
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.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||||
@@ -36,13 +36,7 @@ import com.google.common.eventbus.EventBus;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.persistence.descriptors.DescriptorEventAdapter#postInsert
|
|
||||||
* (org.eclipse.persistence.descriptors.DescriptorEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void postInsert(final DescriptorEvent event) {
|
public void postInsert(final DescriptorEvent event) {
|
||||||
if (event.getObject().getClass().equals(Action.class)) {
|
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
|
@Override
|
||||||
public void postUpdate(final DescriptorEvent event) {
|
public void postUpdate(final DescriptorEvent event) {
|
||||||
if (event.getObject().getClass().equals(Action.class)) {
|
if (event.getObject().getClass().equals(Action.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||||
() -> getEventBus()
|
new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class, event))));
|
||||||
.post(new ActionPropertyChangeEvent((Action) event.getObject(), getChangeSet(Action.class,
|
|
||||||
event))));
|
|
||||||
} else if (event.getObject().getClass().equals(Rollout.class)) {
|
} else if (event.getObject().getClass().equals(Rollout.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(() -> getEventBus().post(
|
||||||
() -> getEventBus().post(
|
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class, event))));
|
||||||
new RolloutPropertyChangeEvent((Rollout) event.getObject(), getChangeSet(Rollout.class,
|
|
||||||
event))));
|
|
||||||
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
|
} else if (event.getObject().getClass().equals(RolloutGroup.class)) {
|
||||||
getAfterTransactionCommmitExecutor().afterCommit(
|
getAfterTransactionCommmitExecutor().afterCommit(
|
||||||
() -> getEventBus().post(
|
() -> getEventBus().post(new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(),
|
||||||
new RolloutGroupPropertyChangeEvent((RolloutGroup) event.getObject(), getChangeSet(
|
getChangeSet(RolloutGroup.class, event))));
|
||||||
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 Class<T> clazz, final DescriptorEvent event) {
|
||||||
final T rolloutGroup = clazz.cast(event.getObject());
|
final T rolloutGroup = clazz.cast(event.getObject());
|
||||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||||
return changeSet
|
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||||
.getChanges()
|
|
||||||
.stream()
|
|
||||||
.filter(record -> record instanceof DirectToFieldChangeRecord)
|
|
||||||
.map(record -> (DirectToFieldChangeRecord) record)
|
.map(record -> (DirectToFieldChangeRecord) record)
|
||||||
.collect(
|
.collect(Collectors.toMap(record -> record.getAttribute(),
|
||||||
Collectors.toMap(record -> record.getAttribute(), record -> new AbstractPropertyChangeEvent<T>(
|
record -> new AbstractPropertyChangeEvent<T>(rolloutGroup, null).new Values(
|
||||||
rolloutGroup, null).new Values(record.getOldValue(), record.getNewValue())));
|
record.getOldValue(), record.getNewValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
|
private AfterTransactionCommitExecutor getAfterTransactionCommmitExecutor() {
|
||||||
|
|||||||
@@ -8,18 +8,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.eventbus.event;
|
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,
|
* An abstract definition class for {@link EntityEvent} for
|
||||||
* which holds the {@link BaseEntity}.
|
* {@link TenantAwareBaseEntity}s, which holds the {@link TenantAwareBaseEntity}
|
||||||
|
* .
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param <E>
|
* @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 {
|
implements EntityEvent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,33 +38,16 @@ public abstract class AbstractBaseEntityEvent<E extends BaseEntity> extends Abst
|
|||||||
this.entity = baseEntity;
|
this.entity = baseEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public E getEntity() {
|
public E getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getEntity(java.lang
|
|
||||||
* .Class)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T getEntity(final Class<T> entityClass) {
|
public <T> T getEntity(final Class<T> entityClass) {
|
||||||
return entityClass.cast(entity);
|
return entityClass.cast(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.eventbus.event.EntityEvent#getTenant()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getTenant() {
|
public String getTenant() {
|
||||||
return entity.getTenant();
|
return entity.getTenant();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.eventbus.event;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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>
|
* @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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ package org.eclipse.hawkbit.eventbus.event;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property change event.
|
* Property change event.
|
||||||
*
|
*
|
||||||
* @param <E>
|
* @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 static final long serialVersionUID = -3671601415138242311L;
|
||||||
private final transient Map<String, Values> changeSet;
|
private final transient Map<String, Values> changeSet;
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.eventbus.event;
|
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.
|
* A event for assignment target tag.
|
||||||
*/
|
*/
|
||||||
public class DistributionSetTagAssigmentResultEvent {
|
public class DistributionSetTagAssigmentResultEvent {
|
||||||
|
|
||||||
private final DistributionSetTagAssigmentResult assigmentResult;
|
private final DistributionSetTagAssignmentResult assigmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -23,11 +23,11 @@ public class DistributionSetTagAssigmentResultEvent {
|
|||||||
* @param assigmentResult
|
* @param assigmentResult
|
||||||
* the assignment result-
|
* the assignment result-
|
||||||
*/
|
*/
|
||||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) {
|
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
|
||||||
this.assigmentResult = assigmentResult;
|
this.assigmentResult = assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DistributionSetTagAssigmentResult getAssigmentResult() {
|
public DistributionSetTagAssignmentResult getAssigmentResult() {
|
||||||
return assigmentResult;
|
return assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.eventbus.event;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
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
|
* 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>
|
* @param <E>
|
||||||
* the entity type
|
* 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
|
* A typesafe way to retrieve the the entities from the event, which might
|
||||||
|
|||||||
@@ -8,14 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.eventbus.event;
|
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.
|
* A event for assignment target tag.
|
||||||
*/
|
*/
|
||||||
public class TargetTagAssigmentResultEvent {
|
public class TargetTagAssigmentResultEvent {
|
||||||
|
|
||||||
private final TargetTagAssigmentResult assigmentResult;
|
private final TargetTagAssignmentResult assigmentResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -23,11 +23,11 @@ public class TargetTagAssigmentResultEvent {
|
|||||||
* @param assigmentResult
|
* @param assigmentResult
|
||||||
* the assignment result-
|
* the assignment result-
|
||||||
*/
|
*/
|
||||||
public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) {
|
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
|
||||||
this.assigmentResult = assigmentResult;
|
this.assigmentResult = assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetTagAssigmentResult getAssigmentResult() {
|
public TargetTagAssignmentResult getAssigmentResult() {
|
||||||
return assigmentResult;
|
return assigmentResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ package org.eclipse.hawkbit.repository;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
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.jpa.repository.Modifying;
|
||||||
import org.springframework.data.repository.NoRepositoryBean;
|
import org.springframework.data.repository.NoRepositoryBean;
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
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
|
@NoRepositoryBean
|
||||||
@Transactional(readOnly = true)
|
@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> {
|
extends PagingAndSortingRepository<T, I> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all {@link BaseEntity} of a given tenant.
|
* Deletes all {@link TenantAwareBaseEntity} of a given tenant.
|
||||||
*
|
*
|
||||||
* @param tenant
|
* @param tenant
|
||||||
* to delete data from
|
* to delete data from
|
||||||
|
|||||||
@@ -376,16 +376,9 @@ public class ControllerManagement {
|
|||||||
switch (actionStatus.getStatus()) {
|
switch (actionStatus.getStatus()) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
|
mergedTarget = deploymentManagement.updateTargetInfo(mergedTarget, TargetUpdateStatus.ERROR, false);
|
||||||
// set action inactive
|
handleErrorOnAction(mergedAction, mergedTarget);
|
||||||
mergedAction.setActive(false);
|
|
||||||
mergedAction.setStatus(Status.ERROR);
|
|
||||||
mergedTarget.setAssignedDistributionSet(null);
|
|
||||||
targetManagement.updateTarget(mergedTarget);
|
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
// set action inactive
|
|
||||||
mergedAction.setActive(false);
|
|
||||||
mergedAction.setStatus(Status.FINISHED);
|
|
||||||
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
|
handleFinishedAndStoreInTargetStatus(mergedTarget, mergedAction);
|
||||||
break;
|
break;
|
||||||
case CANCELED:
|
case CANCELED:
|
||||||
@@ -404,6 +397,13 @@ public class ControllerManagement {
|
|||||||
return actionRepository.save(mergedAction);
|
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) {
|
private void checkForToManyStatusEntries(final Action action) {
|
||||||
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
|
if (securityProperties.getDos().getMaxStatusEntriesPerAction() > 0) {
|
||||||
|
|
||||||
@@ -420,6 +420,8 @@ public class ControllerManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
|
private void handleFinishedAndStoreInTargetStatus(final Target target, final Action action) {
|
||||||
|
action.setActive(false);
|
||||||
|
action.setStatus(Status.FINISHED);
|
||||||
final TargetInfo targetInfo = target.getTargetInfo();
|
final TargetInfo targetInfo = target.getTargetInfo();
|
||||||
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
|
final DistributionSet ds = entityManager.merge(action.getDistributionSet());
|
||||||
targetInfo.setInstalledDistributionSet(ds);
|
targetInfo.setInstalledDistributionSet(ds);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
||||||
@@ -19,7 +20,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
|||||||
* how much of the assignments had already been existed.
|
* how much of the assignments had already been existed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetAssignmentResult extends AssignmentResult {
|
public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
||||||
|
|
||||||
private final List<String> assignedTargets;
|
private final List<String> assignedTargets;
|
||||||
private final List<Long> actions;
|
private final List<Long> actions;
|
||||||
@@ -45,17 +46,15 @@ public class DistributionSetAssignmentResult extends AssignmentResult {
|
|||||||
*/
|
*/
|
||||||
public DistributionSetAssignmentResult(final List<String> assignedTargets, final int assigned,
|
public DistributionSetAssignmentResult(final List<String> assignedTargets, final int assigned,
|
||||||
final int alreadyAssigned, final List<Long> actions, final TargetManagement targetManagement) {
|
final int alreadyAssigned, final List<Long> actions, final TargetManagement targetManagement) {
|
||||||
super(assigned, alreadyAssigned);
|
super(assigned, alreadyAssigned, 0, Collections.emptyList(), Collections.emptyList());
|
||||||
this.assignedTargets = assignedTargets;
|
this.assignedTargets = assignedTargets;
|
||||||
this.actions = actions;
|
this.actions = actions;
|
||||||
this.targetManagement = targetManagement;
|
this.targetManagement = targetManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return the assignedTargets
|
public List<Target> getAssignedEntity() {
|
||||||
*/
|
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||||
public List<Target> getAssignedTargets() {
|
|
||||||
return targetManagement.findTargetsByControllerID(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.DistributionSetMetadata_;
|
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
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.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet_;
|
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.
|
* Business facade for managing the {@link DistributionSet}s.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Validated
|
@Validated
|
||||||
@@ -140,15 +137,15 @@ public class DistributionSetManagement {
|
|||||||
* @param sets
|
* @param sets
|
||||||
* to toggle for
|
* to toggle for
|
||||||
* @param tag
|
* @param tag
|
||||||
* to toogle
|
* to toggle
|
||||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||||
* the assignment outcome.
|
* the assignment outcome.
|
||||||
*/
|
*/
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@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) {
|
@NotNull final DistributionSetTag tag) {
|
||||||
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
return toggleTagAssignment(sets.stream().map(ds -> ds.getId()).collect(Collectors.toList()), tag.getName());
|
||||||
}
|
}
|
||||||
@@ -163,44 +160,44 @@ public class DistributionSetManagement {
|
|||||||
* to toggle for
|
* to toggle for
|
||||||
* @param tagName
|
* @param tagName
|
||||||
* to toggle
|
* to toggle
|
||||||
* @return {@link DistributionSetTagAssigmentResult} with all metadata of
|
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||||
* the assignment outcome.
|
* the assignment outcome.
|
||||||
*/
|
*/
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@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) {
|
@NotNull final String tagName) {
|
||||||
|
|
||||||
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
|
final Iterable<DistributionSet> sets = findDistributionSetListWithDetails(dsIds);
|
||||||
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
|
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName);
|
||||||
|
|
||||||
DistributionSetTagAssigmentResult result = null;
|
DistributionSetTagAssignmentResult result;
|
||||||
final List<DistributionSet> allDSs = new ArrayList<>();
|
final List<DistributionSet> toBeChangedDSs = new ArrayList<>();
|
||||||
for (final DistributionSet set : sets) {
|
for (final DistributionSet set : sets) {
|
||||||
if (set.getTags().add(myTag)) {
|
if (set.getTags().add(myTag)) {
|
||||||
allDSs.add(set);
|
toBeChangedDSs.add(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unassigment case
|
// un-assignment case
|
||||||
if (allDSs.isEmpty()) {
|
if (toBeChangedDSs.isEmpty()) {
|
||||||
for (final DistributionSet set : sets) {
|
for (final DistributionSet set : sets) {
|
||||||
if (set.getTags().remove(myTag)) {
|
if (set.getTags().remove(myTag)) {
|
||||||
allDSs.add(set);
|
toBeChangedDSs.add(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(),
|
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), 0,
|
||||||
Collections.emptyList(), distributionSetRepository.save(allDSs), myTag);
|
toBeChangedDSs.size(), Collections.emptyList(), distributionSetRepository.save(toBeChangedDSs),
|
||||||
|
myTag);
|
||||||
} else {
|
} else {
|
||||||
result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0,
|
result = new DistributionSetTagAssignmentResult(dsIds.size() - toBeChangedDSs.size(), toBeChangedDSs.size(),
|
||||||
distributionSetRepository.save(allDSs), Collections.emptyList(), myTag);
|
0, distributionSetRepository.save(toBeChangedDSs), Collections.emptyList(), myTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult resultAssignment = result;
|
final DistributionSetTagAssignmentResult resultAssignment = result;
|
||||||
afterCommit
|
afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
||||||
.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment)));
|
|
||||||
|
|
||||||
// no reason to persist the tag
|
// no reason to persist the tag
|
||||||
entityManager.detach(myTag);
|
entityManager.detach(myTag);
|
||||||
@@ -352,6 +349,9 @@ public class DistributionSetManagement {
|
|||||||
public List<DistributionSet> createDistributionSets(@NotNull final Iterable<DistributionSet> distributionSets) {
|
public List<DistributionSet> createDistributionSets(@NotNull final Iterable<DistributionSet> distributionSets) {
|
||||||
for (final DistributionSet ds : distributionSets) {
|
for (final DistributionSet ds : distributionSets) {
|
||||||
prepareDsSave(ds);
|
prepareDsSave(ds);
|
||||||
|
if (ds.getType() == null) {
|
||||||
|
ds.setType(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return distributionSetRepository.save(distributionSets);
|
return distributionSetRepository.save(distributionSets);
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ public class DistributionSetManagement {
|
|||||||
* @param spec
|
* @param spec
|
||||||
* of the search
|
* of the search
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* parametsr for paging
|
* parameter for paging
|
||||||
*
|
*
|
||||||
* @return the found {@link SoftwareModuleType}s
|
* @return the found {@link SoftwareModuleType}s
|
||||||
*/
|
*/
|
||||||
@@ -762,7 +762,7 @@ public class DistributionSetManagement {
|
|||||||
if (distributionSetMetadataRepository.exists(metadata.getId())) {
|
if (distributionSetMetadataRepository.exists(metadata.getId())) {
|
||||||
throwMetadataKeyAlreadyExists(metadata.getId().getKey());
|
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
|
// log written because
|
||||||
// modifying metadata is modifying the base distribution set itself for
|
// modifying metadata is modifying the base distribution set itself for
|
||||||
// auditing purposes.
|
// auditing purposes.
|
||||||
@@ -870,7 +870,7 @@ public class DistributionSetManagement {
|
|||||||
cb) -> cb.and(
|
cb) -> cb.and(
|
||||||
cb.equal(root.get(DistributionSetMetadata_.distributionSet)
|
cb.equal(root.get(DistributionSetMetadata_.distributionSet)
|
||||||
.get(DistributionSet_.id), distributionSetId),
|
.get(DistributionSet_.id), distributionSetId),
|
||||||
spec.toPredicate(root, query, cb)),
|
spec.toPredicate(root, query, cb)),
|
||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,7 +916,7 @@ public class DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<DistributionSetType> createDistributionSetTypes(@NotNull final Collection<DistributionSetType> types) {
|
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(() -> {
|
afterCommit.afterCommit(() -> {
|
||||||
|
|
||||||
final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0,
|
final DistributionSetTagAssignmentResult result = new DistributionSetTagAssignmentResult(0, save.size(), 0,
|
||||||
save, Collections.emptyList(), tag);
|
save, Collections.emptyList(), tag);
|
||||||
eventBus.post(new DistributionSetTagAssigmentResultEvent(result));
|
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
|
* Workaround as spring data does not provide a {@link Slice} based
|
||||||
* {@link JpaRepository#findAll()}.
|
* {@link JpaRepository#findAll()}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public class NoCountPagingRepository {
|
public class NoCountPagingRepository {
|
||||||
@@ -104,15 +101,6 @@ public class NoCountPagingRepository {
|
|||||||
super(domainClass, em);
|
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
|
@Override
|
||||||
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
|
protected Page<T> readPage(final TypedQuery<T> query, final Pageable pageable, final Specification<T> spec) {
|
||||||
query.setFirstResult(pageable.getOffset());
|
query.setFirstResult(pageable.getOffset());
|
||||||
|
|||||||
@@ -458,11 +458,6 @@ public class ReportManagement {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -471,11 +466,6 @@ public class ReportManagement {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is
|
public boolean equals(final Object obj) { // NOSONAR - as this is
|
||||||
// generated
|
// generated
|
||||||
@@ -499,11 +489,6 @@ public class ReportManagement {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DSName [name=" + name + "]";
|
return "DSName [name=" + name + "]";
|
||||||
@@ -523,9 +508,6 @@ public class ReportManagement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return DateTypes.
|
* Return DateTypes.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static final class DateTypes implements Serializable {
|
public static final class DateTypes implements Serializable {
|
||||||
/**
|
/**
|
||||||
@@ -585,12 +567,6 @@ public class ReportManagement {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final String DATE_PATTERN = "yyyy-MM";
|
private static final String DATE_PATTERN = "yyyy-MM";
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* format(java. lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDate format(final String s) {
|
public LocalDate format(final String s) {
|
||||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
||||||
@@ -598,23 +574,11 @@ public class ReportManagement {
|
|||||||
return ym.atDay(1);
|
return ym.atDay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* h2Format()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String h2Format() {
|
public String h2Format() {
|
||||||
return DATE_PATTERN;
|
return DATE_PATTERN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.hawkbit.server.repository.ReportManagement.DateType#
|
|
||||||
* mySqlFormat( )
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String mySqlFormat() {
|
public String mySqlFormat() {
|
||||||
return "%Y-%m";
|
return "%Y-%m";
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ import com.google.common.base.Strings;
|
|||||||
import com.google.common.collect.Sets;
|
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)
|
@Transactional(readOnly = true)
|
||||||
@@ -99,7 +95,7 @@ public class SoftwareManagement {
|
|||||||
private ArtifactManagement artifactManagement;
|
private ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates existing {@link SoftwareModule}. Updateable values are
|
* Updates existing {@link SoftwareModule}. Update-able values are
|
||||||
* {@link SoftwareModule#getDescription()}
|
* {@link SoftwareModule#getDescription()}
|
||||||
* {@link SoftwareModule#getVendor()}.
|
* {@link SoftwareModule#getVendor()}.
|
||||||
*
|
*
|
||||||
@@ -119,17 +115,21 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
|
final SoftwareModule module = softwareModuleRepository.findOne(sm.getId());
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
|
if (null == sm.getDescription() || !sm.getDescription().equals(module.getDescription())) {
|
||||||
module.setDescription(sm.getDescription());
|
module.setDescription(sm.getDescription());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
|
if (null == sm.getVendor() || !sm.getVendor().equals(module.getVendor())) {
|
||||||
module.setVendor(sm.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#getDescription()} and
|
||||||
* {@link SoftwareModuleType#getColour()}.
|
* {@link SoftwareModuleType#getColour()}.
|
||||||
*
|
*
|
||||||
@@ -145,13 +145,16 @@ public class SoftwareManagement {
|
|||||||
|
|
||||||
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
final SoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
||||||
|
|
||||||
|
boolean updated = false;
|
||||||
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
||||||
type.setDescription(sm.getDescription());
|
type.setDescription(sm.getDescription());
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
|
if (sm.getColour() != null && !sm.getColour().equals(type.getColour())) {
|
||||||
type.setColour(sm.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
|
* @param name
|
||||||
* of the {@link SoftwareModule}
|
* of the {@link SoftwareModule}
|
||||||
* @param version
|
* @param version
|
||||||
* of the {@link SoftwareModule}
|
* 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)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
public SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty final String name,
|
||||||
@NotEmpty final String version) {
|
@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
|
* Filter {@link SoftwareModule}s with given
|
||||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
* {@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
|
* @param pageable
|
||||||
* page parameter
|
* page parameter
|
||||||
* @param orderByDistributionId
|
* @param orderByDistributionId
|
||||||
* the ID of distribution set to be order by
|
* the ID of distribution set to be ordered on top
|
||||||
* @param searchText
|
* @param searchText
|
||||||
* to be filtered as "like" on {@link SoftwareModule#getName()}
|
* filtered as "like" on {@link SoftwareModule#getName()}
|
||||||
* @param type
|
* @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}
|
* @return the page of found {@link SoftwareModule}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public Slice<CustomSoftwareModule> findSoftwareModuleOrderByDistribution(@NotNull final Pageable pageable,
|
public Slice<CustomSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||||
@NotNull final Long orderByDistributionId, final String searchText, final SoftwareModuleType type) {
|
@NotNull final Pageable pageable, @NotNull final Long orderByDistributionId, final String searchText,
|
||||||
|
final SoftwareModuleType type) {
|
||||||
|
|
||||||
final List<CustomSoftwareModule> resultList = new ArrayList<>();
|
final List<CustomSoftwareModule> resultList = new ArrayList<>();
|
||||||
final int pageSize = pageable.getPageSize();
|
final int pageSize = pageable.getPageSize();
|
||||||
@@ -522,7 +533,7 @@ public class SoftwareManagement {
|
|||||||
assignedRoot, assignedQuery, cb,
|
assignedRoot, assignedQuery, cb,
|
||||||
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
|
cb.equal(assignedDsJoin.get(DistributionSet_.id), orderByDistributionId));
|
||||||
// if we have some predicates then add it to the where clause of the
|
// if we have some predicates then add it to the where clause of the
|
||||||
// multiselect
|
// multi select
|
||||||
assignedQuery.where(specPredicate);
|
assignedQuery.where(specPredicate);
|
||||||
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
|
assignedQuery.orderBy(cb.asc(assignedRoot.get(SoftwareModule_.name)),
|
||||||
cb.asc(assignedRoot.get(SoftwareModule_.version)));
|
cb.asc(assignedRoot.get(SoftwareModule_.version)));
|
||||||
@@ -546,7 +557,7 @@ public class SoftwareManagement {
|
|||||||
unassignedQuery.distinct(true);
|
unassignedQuery.distinct(true);
|
||||||
final Root<SoftwareModule> unassignedRoot = unassignedQuery.from(SoftwareModule.class);
|
final Root<SoftwareModule> unassignedRoot = unassignedQuery.from(SoftwareModule.class);
|
||||||
|
|
||||||
Predicate[] unassignedSpec = null;
|
Predicate[] unassignedSpec;
|
||||||
if (!assignedSoftwareModules.isEmpty()) {
|
if (!assignedSoftwareModules.isEmpty()) {
|
||||||
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
|
unassignedSpec = specificationsToPredicate(buildSpecificationList(searchText, type), unassignedRoot,
|
||||||
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
|
unassignedQuery, cb, cb.not(unassignedRoot.get(SoftwareModule_.id)
|
||||||
@@ -709,8 +720,8 @@ public class SoftwareManagement {
|
|||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
@Transactional
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public List<SoftwareModuleType> createSoftwareModuleTypes(@NotNull final Collection<SoftwareModuleType> types) {
|
public List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types) {
|
||||||
return types.stream().map(type -> createSoftwareModuleType(type)).collect(Collectors.toList());
|
return types.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -826,7 +837,7 @@ public class SoftwareManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
|
public SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull final SoftwareModuleMetadata metadata) {
|
||||||
// check if exists otherwise throw entity not found exception
|
// 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
|
// touch it to update the lock revision because we are modifying the
|
||||||
// software module
|
// software module
|
||||||
// indirectly
|
// indirectly
|
||||||
@@ -884,7 +895,7 @@ public class SoftwareManagement {
|
|||||||
cb) -> cb.and(
|
cb) -> cb.and(
|
||||||
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
cb.equal(root.get(SoftwareModuleMetadata_.softwareModule)
|
||||||
.get(SoftwareModule_.id), softwareModuleId),
|
.get(SoftwareModule_.id), softwareModuleId),
|
||||||
spec.toPredicate(root, query, cb)),
|
spec.toPredicate(root, query, cb)),
|
||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,7 +910,7 @@ public class SoftwareManagement {
|
|||||||
* in case the meta data does not exists for the given key
|
* in case the meta data does not exists for the given key
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@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);
|
final SoftwareModuleMetadata findOne = softwareModuleMetadataRepository.findOne(id);
|
||||||
if (findOne == null) {
|
if (findOne == null) {
|
||||||
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
|
throw new EntityNotFoundException("Metadata with key '" + id.getKey() + "' does not exist");
|
||||||
|
|||||||
@@ -43,15 +43,19 @@ public interface SoftwareModuleRepository
|
|||||||
Long countByType(SoftwareModuleType type);
|
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
|
* @param name
|
||||||
* to be filtered on
|
* to be filtered on
|
||||||
* @param version
|
* @param version
|
||||||
* to be filtered on
|
* 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.
|
* deletes the {@link SoftwareModule}s with the given IDs.
|
||||||
@@ -81,6 +85,8 @@ public interface SoftwareModuleRepository
|
|||||||
Page<SoftwareModule> findByAssignedTo(Pageable pageable, DistributionSet set);
|
Page<SoftwareModule> findByAssignedTo(Pageable pageable, DistributionSet set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
* @param set
|
* @param set
|
||||||
* to search for
|
* to search for
|
||||||
* @return all {@link SoftwareModule}s that are assigned to given
|
* @return all {@link SoftwareModule}s that are assigned to given
|
||||||
|
|||||||
@@ -310,8 +310,6 @@ public class SystemManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType createStandardSoftwareDataSetup() {
|
private DistributionSetType createStandardSoftwareDataSetup() {
|
||||||
|
|
||||||
// Edge Controller Linux standard setup
|
|
||||||
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
|
final SoftwareModuleType eclApp = softwareModuleTypeRepository.save(new SoftwareModuleType("application",
|
||||||
"ECL Application", "Edge Controller Linux base application type", 1));
|
"ECL Application", "Edge Controller Linux base application type", 1));
|
||||||
final SoftwareModuleType eclOs = softwareModuleTypeRepository
|
final SoftwareModuleType eclOs = softwareModuleTypeRepository
|
||||||
@@ -327,13 +325,11 @@ public class SystemManagement {
|
|||||||
"Standard Edge Controller Linux distribution set type. OS only.").addMandatoryModuleType(eclOs)
|
"Standard Edge Controller Linux distribution set type. OS only.").addMandatoryModuleType(eclOs)
|
||||||
.addOptionalModuleType(eclApp));
|
.addOptionalModuleType(eclApp));
|
||||||
|
|
||||||
final DistributionSetType defaultType = distributionSetTypeRepository
|
return distributionSetTypeRepository
|
||||||
.save(new DistributionSetType("ecl_os_app_jvm", "OS with optional app and jvm",
|
.save(new DistributionSetType("ecl_os_app_jvm", "OS with optional app and jvm",
|
||||||
"Standard Edge Controller Linux distribution set type. OS with optional application.")
|
"Standard Edge Controller Linux distribution set type. OS with optional application.")
|
||||||
.addMandatoryModuleType(eclOs).addOptionalModuleType(eclApp)
|
.addMandatoryModuleType(eclOs).addOptionalModuleType(eclApp)
|
||||||
.addOptionalModuleType(eclJvm));
|
.addOptionalModuleType(eclJvm));
|
||||||
|
|
||||||
return defaultType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -343,18 +339,8 @@ public class SystemManagement {
|
|||||||
* default types we need to use the tenant the current tenant which is
|
* default types we need to use the tenant the current tenant which is
|
||||||
* currently created and not the one currently in the {@link TenantAware}.
|
* currently created and not the one currently in the {@link TenantAware}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class CurrentTenantKeyGenerator implements KeyGenerator {
|
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
|
@Override
|
||||||
public Object generate(final Object target, final Method method, final Object... params) {
|
public Object generate(final Object target, final Method method, final Object... params) {
|
||||||
final String initialTenantCreation = createInitialTenant.get();
|
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.TargetInfo_;
|
import org.eclipse.hawkbit.repository.model.TargetInfo_;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
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.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.repository.model.Target_;
|
import org.eclipse.hawkbit.repository.model.Target_;
|
||||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.SliceImpl;
|
import org.springframework.data.domain.SliceImpl;
|
||||||
@@ -74,8 +73,6 @@ import com.google.common.eventbus.EventBus;
|
|||||||
/**
|
/**
|
||||||
* Business service facade for managing {@link Target}s.
|
* Business service facade for managing {@link Target}s.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Validated
|
@Validated
|
||||||
@@ -157,7 +154,7 @@ public class TargetManagement {
|
|||||||
* @return List of found{@link Target}s
|
* @return List of found{@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@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));
|
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
|
* details, i.e. NO {@link Target#getTags()} and
|
||||||
* {@link Target#getActiveActions()} possible including the filtering based
|
* {@link Target#getActiveActions()} possible including additional filtering
|
||||||
* on the given {@code spec}.
|
* based on the given {@code spec}.
|
||||||
*
|
*
|
||||||
* @param distributionSetID
|
* @param distributionSetID
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
@@ -376,7 +373,8 @@ public class TargetManagement {
|
|||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||||
* details, i.e. NO {@link Target#getTags()} and
|
* 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
|
* @param distributionSetId
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
@@ -492,7 +490,7 @@ public class TargetManagement {
|
|||||||
if (!Strings.isNullOrEmpty(searchText)) {
|
if (!Strings.isNullOrEmpty(searchText)) {
|
||||||
specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(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));
|
specList.add(TargetSpecifications.hasTags(tagNames, selectTargetWithNoTag));
|
||||||
}
|
}
|
||||||
return specList;
|
return specList;
|
||||||
@@ -536,7 +534,7 @@ public class TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@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) {
|
@NotNull final TargetTag tag) {
|
||||||
return toggleTagAssignment(
|
return toggleTagAssignment(
|
||||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||||
@@ -558,7 +556,7 @@ public class TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@NotNull
|
@NotNull
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@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) {
|
@NotNull final String tagName) {
|
||||||
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
final TargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
||||||
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
final List<Target> alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds);
|
||||||
@@ -568,7 +566,7 @@ public class TargetManagement {
|
|||||||
// all are already assigned -> unassign
|
// all are already assigned -> unassign
|
||||||
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
if (alreadyAssignedTargets.size() == allTargets.size()) {
|
||||||
alreadyAssignedTargets.forEach(target -> target.getTags().remove(tag));
|
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);
|
Collections.emptyList(), alreadyAssignedTargets, tag);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||||
@@ -578,7 +576,7 @@ public class TargetManagement {
|
|||||||
allTargets.removeAll(alreadyAssignedTargets);
|
allTargets.removeAll(alreadyAssignedTargets);
|
||||||
// some or none are assigned -> assign
|
// some or none are assigned -> assign
|
||||||
allTargets.forEach(target -> target.getTags().add(tag));
|
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);
|
allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result)));
|
||||||
@@ -609,7 +607,7 @@ public class TargetManagement {
|
|||||||
final List<Target> save = targetRepository.save(allTargets);
|
final List<Target> save = targetRepository.save(allTargets);
|
||||||
|
|
||||||
afterCommit.afterCommit(() -> {
|
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);
|
Collections.emptyList(), tag);
|
||||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
||||||
});
|
});
|
||||||
@@ -622,7 +620,7 @@ public class TargetManagement {
|
|||||||
|
|
||||||
final List<Target> save = targetRepository.save(targets);
|
final List<Target> save = targetRepository.save(targets);
|
||||||
afterCommit.afterCommit(() -> {
|
afterCommit.afterCommit(() -> {
|
||||||
final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(),
|
final TargetTagAssignmentResult assigmentResult = new TargetTagAssignmentResult(0, 0, save.size(),
|
||||||
Collections.emptyList(), save, tag);
|
Collections.emptyList(), save, tag);
|
||||||
eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult));
|
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
|
* @param pageRequest
|
||||||
* the pageRequest to enhance the query for paging and sorting
|
* 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
|
* @param filterByStatus
|
||||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||||
* <code>null</code> in case this is not required.
|
* <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
|
* to find targets having the text anywhere in name or
|
||||||
* description. Set <code>null</code> in case this is not
|
* description. Set <code>null</code> in case this is not
|
||||||
* required.
|
* 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
|
* @param filterByTagNames
|
||||||
* to find targets which are having any one in this tag names.
|
* to find targets which are having any one in this tag names.
|
||||||
* Set <code>null</code> in case this is not required.
|
* Set <code>null</code> in case this is not required.
|
||||||
* @param selectTargetWithNoTag
|
* @param selectTargetWithNoTag
|
||||||
* flag to select targets with no tag assigned
|
* 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)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public List<TargetIdName> findAllTargetIdsByFilters(final PageRequest pageRequest,
|
public List<TargetIdName> findAllTargetIdsByFilters(@NotNull final Pageable pageRequest,
|
||||||
final Long filterByDistributionId, final Collection<TargetUpdateStatus> filterByStatus,
|
final Collection<TargetUpdateStatus> filterByStatus, final String filterBySearchText,
|
||||||
final String filterBySearchText, final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag,
|
||||||
|
final String... filterByTagNames) {
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||||
final Root<Target> targetRoot = query.from(Target.class);
|
final Root<Target> targetRoot = query.from(Target.class);
|
||||||
List<Object[]> resultList;
|
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),
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
||||||
|
|
||||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(
|
||||||
buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId,
|
buildSpecificationList(filterByStatus, filterBySearchText, installedOrAssignedDistributionSetId,
|
||||||
selectTargetWithNoTag, false, filterByTagNames),
|
selectTargetWithNoTag, false, filterByTagNames),
|
||||||
targetRoot, multiselect, cb);
|
targetRoot, multiselect, cb);
|
||||||
|
|
||||||
@@ -864,24 +870,29 @@ public class TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link Target#getControllerId()} for all the given parameter
|
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||||
* {@link TargetFilterQuery}.
|
* and returns not the full target but {@link TargetIdName}.
|
||||||
*
|
*
|
||||||
* @param pageRequest
|
* @param pageRequest
|
||||||
* the pageRequest to enhance the query for paging and sorting
|
* the pageRequest to enhance the query for paging and sorting
|
||||||
* @param targetFilterQuery
|
* @param targetFilterQuery
|
||||||
* {@link TargetFilterQuery}
|
* {@link TargetFilterQuery}
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link TargetIdName}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest,
|
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
|
||||||
@NotNull final TargetFilterQuery targetFilterQuery) {
|
@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||||
final Root<Target> targetRoot = query.from(Target.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),
|
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(Target_.id),
|
||||||
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name),
|
targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(sortProperty));
|
||||||
targetRoot.get(pageRequest.getSort().iterator().next().getProperty()));
|
|
||||||
|
|
||||||
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
final Specification<Target> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
|
||||||
final List<Specification<Target>> specList = new ArrayList<>();
|
final List<Specification<Target>> specList = new ArrayList<>();
|
||||||
@@ -1074,7 +1085,7 @@ public class TargetManagement {
|
|||||||
return targetRepository.count(specs);
|
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) {
|
final Root<Target> targetRoot, final CriteriaQuery<Object[]> multiselect) {
|
||||||
List<Object[]> resultList;
|
List<Object[]> resultList;
|
||||||
if (pageRequest.getSort() != null) {
|
if (pageRequest.getSort() != null) {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class TenantConfigurationManagement implements EnvironmentAware {
|
|||||||
* @param configurationKey
|
* @param configurationKey
|
||||||
* the key of the configuration
|
* the key of the configuration
|
||||||
* @return the converted configuration value either from the tenant specific
|
* @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
|
* {@code null} in case key has not been configured and not default
|
||||||
* value exists
|
* value exists
|
||||||
* @throws TenantConfigurationValidatorException
|
* @throws TenantConfigurationValidatorException
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
/**
|
/**
|
||||||
* The spring-data repository for the entity {@link TenantConfiguration}.
|
* The spring-data repository for the entity {@link TenantConfiguration}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public interface TenantConfigurationRepository extends BaseEntityRepository<TenantConfiguration, Long> {
|
public interface TenantConfigurationRepository extends BaseEntityRepository<TenantConfiguration, Long> {
|
||||||
@@ -32,11 +29,6 @@ public interface TenantConfigurationRepository extends BaseEntityRepository<Tena
|
|||||||
*/
|
*/
|
||||||
TenantConfiguration findByKey(String configurationKey);
|
TenantConfiguration findByKey(String configurationKey);
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.springframework.data.repository.CrudRepository#findAll()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
List<TenantConfiguration> findAll();
|
List<TenantConfiguration> findAll();
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ import org.springframework.stereotype.Service;
|
|||||||
/**
|
/**
|
||||||
* {@link KeyGenerator} for tenant related caches.
|
* {@link KeyGenerator} for tenant related caches.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TenantKeyGenerator implements KeyGenerator {
|
public class TenantKeyGenerator implements KeyGenerator {
|
||||||
@@ -28,13 +25,6 @@ public class TenantKeyGenerator implements KeyGenerator {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.springframework.cache.interceptor.KeyGenerator#generate(java.lang.
|
|
||||||
* Object, java.lang.reflect.Method, java.lang.Object[])
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Object generate(final Object target, final Method method, final Object... params) {
|
public Object generate(final Object target, final Method method, final Object... params) {
|
||||||
return tenantAware.getCurrentTenant().toUpperCase();
|
return tenantAware.getCurrentTenant().toUpperCase();
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||||||
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
|
||||||
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
|
||||||
@NamedEntityGraph(name = "Action.all", 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
|
@Entity
|
||||||
public class Action extends BaseEntity implements Comparable<Action> {
|
public class Action extends TenantAwareBaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
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.
|
* the {@link DistributionSet} which should be installed by this action.
|
||||||
*/
|
*/
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private Target target;
|
||||||
|
|
||||||
@Column(name = "active")
|
@Column(name = "active")
|
||||||
@@ -90,11 +90,11 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
|||||||
private List<ActionStatus> actionStatus;
|
private List<ActionStatus> actionStatus;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private RolloutGroup rolloutGroup;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private Rollout rollout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,55 +127,30 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
|||||||
return status == Status.CANCELING || status == Status.CANCELED;
|
return status == Status.CANCELING || status == Status.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param active
|
|
||||||
* the active to set
|
|
||||||
*/
|
|
||||||
public void setActive(final boolean active) {
|
public void setActive(final boolean active) {
|
||||||
this.active = active;
|
this.active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status
|
|
||||||
* the status to set
|
|
||||||
*/
|
|
||||||
public void setStatus(final Status status) {
|
public void setStatus(final Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the downloadProgressPercent
|
|
||||||
*/
|
|
||||||
public int getDownloadProgressPercent() {
|
public int getDownloadProgressPercent() {
|
||||||
return downloadProgressPercent;
|
return downloadProgressPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param downloadProgressPercent
|
|
||||||
* the downloadProgressPercent to set
|
|
||||||
*/
|
|
||||||
public void setDownloadProgressPercent(final int downloadProgressPercent) {
|
public void setDownloadProgressPercent(final int downloadProgressPercent) {
|
||||||
this.downloadProgressPercent = downloadProgressPercent;
|
this.downloadProgressPercent = downloadProgressPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the active
|
|
||||||
*/
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param actionType
|
|
||||||
* the actionType to set
|
|
||||||
*/
|
|
||||||
public void setActionType(final ActionType actionType) {
|
public void setActionType(final ActionType actionType) {
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
}
|
}
|
||||||
@@ -187,81 +162,42 @@ public class Action extends BaseEntity implements Comparable<Action> {
|
|||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatus
|
|
||||||
*/
|
|
||||||
public List<ActionStatus> getActionStatus() {
|
public List<ActionStatus> getActionStatus() {
|
||||||
return actionStatus;
|
return actionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param target
|
|
||||||
* the target to set
|
|
||||||
*/
|
|
||||||
public void setTarget(final Target target) {
|
public void setTarget(final Target target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the target
|
|
||||||
*/
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the forcedTime
|
|
||||||
*/
|
|
||||||
public long getForcedTime() {
|
public long getForcedTime() {
|
||||||
return forcedTime;
|
return forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param forcedTime
|
|
||||||
* the forcedTime to set
|
|
||||||
*/
|
|
||||||
public void setForcedTime(final long forcedTime) {
|
public void setForcedTime(final long forcedTime) {
|
||||||
this.forcedTime = forcedTime;
|
this.forcedTime = forcedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutGroup
|
|
||||||
*/
|
|
||||||
public RolloutGroup getRolloutGroup() {
|
public RolloutGroup getRolloutGroup() {
|
||||||
return rolloutGroup;
|
return rolloutGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rolloutGroup
|
|
||||||
* the rolloutGroup to set
|
|
||||||
*/
|
|
||||||
public void setRolloutGroup(final RolloutGroup rolloutGroup) {
|
public void setRolloutGroup(final RolloutGroup rolloutGroup) {
|
||||||
this.rolloutGroup = rolloutGroup;
|
this.rolloutGroup = rolloutGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rollout
|
|
||||||
*/
|
|
||||||
public Rollout getRollout() {
|
public Rollout getRollout() {
|
||||||
return rollout;
|
return rollout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param rollout
|
|
||||||
* the rollout to set
|
|
||||||
*/
|
|
||||||
public void setRollout(final Rollout rollout) {
|
public void setRollout(final Rollout rollout) {
|
||||||
this.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
|
* checks if the {@link #forcedTime} is hit by the given
|
||||||
* {@code hitTimeMillis}, by means if the given milliseconds are greater
|
* {@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;
|
return actionType == ActionType.FORCED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]";
|
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.
|
* 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.
|
* The action type for this action relation.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum ActionType {
|
public enum ActionType {
|
||||||
FORCED, SOFT, TIMEFORCED;
|
FORCED, SOFT, TIMEFORCED;
|
||||||
|
|||||||
@@ -32,27 +32,20 @@ import com.google.common.base.Splitter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity to store the status for a specific action.
|
* 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"),
|
@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_02", columnList = "tenant,action,status"),
|
||||||
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
||||||
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
||||||
@Entity
|
@Entity
|
||||||
public class ActionStatus extends BaseEntity {
|
public class ActionStatus extends TenantAwareBaseEntity {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "target_occurred_at")
|
@Column(name = "target_occurred_at")
|
||||||
private Long occurredAt;
|
private Long occurredAt;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
@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;
|
private Action action;
|
||||||
|
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
@@ -60,14 +53,14 @@ public class ActionStatus extends BaseEntity {
|
|||||||
|
|
||||||
@CascadeOnDelete
|
@CascadeOnDelete
|
||||||
@ElementCollection(fetch = FetchType.LAZY, targetClass = String.class)
|
@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") })
|
@Index(name = "sp_idx_action_status_msgs_01", columnList = "action_status_id") })
|
||||||
@Column(name = "detail_message", length = 512)
|
@Column(name = "detail_message", length = 512)
|
||||||
private final List<String> messages = new ArrayList<>();
|
private final List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ActionStatus} object.
|
* Creates a new {@link ActionStatus} object.
|
||||||
*
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* the action for this action status
|
* the action for this action status
|
||||||
* @param status
|
* @param status
|
||||||
@@ -83,7 +76,7 @@ public class ActionStatus extends BaseEntity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ActionStatus} object.
|
* Creates a new {@link ActionStatus} object.
|
||||||
*
|
*
|
||||||
* @param action
|
* @param action
|
||||||
* the action for this action status
|
* the action for this action status
|
||||||
* @param status
|
* @param status
|
||||||
@@ -103,67 +96,48 @@ public class ActionStatus extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* JPA default constructor.
|
||||||
*/
|
*/
|
||||||
public ActionStatus() {
|
public ActionStatus() {
|
||||||
|
// JPA default constructor.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the occurredAt
|
|
||||||
*/
|
|
||||||
public Long getOccurredAt() {
|
public Long getOccurredAt() {
|
||||||
return occurredAt;
|
return occurredAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param occurredAt
|
|
||||||
* the occurredAt to set
|
|
||||||
*/
|
|
||||||
public void setOccurredAt(final Long occurredAt) {
|
public void setOccurredAt(final Long occurredAt) {
|
||||||
this.occurredAt = occurredAt;
|
this.occurredAt = occurredAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds message.
|
* Adds message including splitting in case it exceeds 512 length.
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* to add
|
* to add
|
||||||
*/
|
*/
|
||||||
public final void addMessage(final String message) {
|
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() {
|
public List<String> getMessages() {
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the action
|
|
||||||
*/
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param action
|
|
||||||
* the action to set
|
|
||||||
*/
|
|
||||||
public void setAction(final Action action) {
|
public void setAction(final Action action) {
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the status
|
|
||||||
*/
|
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status
|
|
||||||
* the status to set
|
|
||||||
*/
|
|
||||||
public void setStatus(final Status status) {
|
public void setStatus(final Status status) {
|
||||||
this.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
|
* Custom JPA Model for querying {@link Action} include the count of the
|
||||||
* action's {@link ActionStatus}.
|
* action's {@link ActionStatus}.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ActionWithStatusCount {
|
public class ActionWithStatusCount {
|
||||||
private final Long actionStatusCount;
|
private final Long actionStatusCount;
|
||||||
@@ -37,7 +34,7 @@ public class ActionWithStatusCount {
|
|||||||
/**
|
/**
|
||||||
* JPA constructor, the parameter are the result set columns of the custom
|
* JPA constructor, the parameter are the result set columns of the custom
|
||||||
* query.
|
* query.
|
||||||
*
|
*
|
||||||
* @param actionId
|
* @param actionId
|
||||||
* the ID of the action
|
* the ID of the action
|
||||||
* @param actionType
|
* @param actionType
|
||||||
@@ -70,9 +67,9 @@ public class ActionWithStatusCount {
|
|||||||
final String rolloutName) {
|
final String rolloutName) {
|
||||||
this.actionId = actionId;
|
this.actionId = actionId;
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
this.actionActive = active;
|
actionActive = active;
|
||||||
this.actionForceTime = forcedTime;
|
actionForceTime = forcedTime;
|
||||||
this.actionStatus = status;
|
actionStatus = status;
|
||||||
this.actionCreatedAt = actionCreatedAt;
|
this.actionCreatedAt = actionCreatedAt;
|
||||||
this.actionLastModifiedAt = actionLastModifiedAt;
|
this.actionLastModifiedAt = actionLastModifiedAt;
|
||||||
this.dsId = dsId;
|
this.dsId = dsId;
|
||||||
@@ -81,101 +78,62 @@ public class ActionWithStatusCount {
|
|||||||
this.actionStatusCount = actionStatusCount;
|
this.actionStatusCount = actionStatusCount;
|
||||||
this.rolloutName = rolloutName;
|
this.rolloutName = rolloutName;
|
||||||
|
|
||||||
this.action = new Action();
|
action = new Action();
|
||||||
this.action.setActionType(actionType);
|
action.setActionType(actionType);
|
||||||
this.action.setActive(actionActive);
|
action.setActive(actionActive);
|
||||||
this.action.setForcedTime(actionForceTime);
|
action.setForcedTime(actionForceTime);
|
||||||
this.action.setStatus(actionStatus);
|
action.setStatus(actionStatus);
|
||||||
this.action.setId(actionId);
|
action.setId(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the action
|
|
||||||
*/
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionId
|
|
||||||
*/
|
|
||||||
public Long getActionId() {
|
public Long getActionId() {
|
||||||
return actionId;
|
return actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionType
|
|
||||||
*/
|
|
||||||
public ActionType getActionType() {
|
public ActionType getActionType() {
|
||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionActive
|
|
||||||
*/
|
|
||||||
public boolean isActionActive() {
|
public boolean isActionActive() {
|
||||||
return actionActive;
|
return actionActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionForceTime
|
|
||||||
*/
|
|
||||||
public long getActionForceTime() {
|
public long getActionForceTime() {
|
||||||
return actionForceTime;
|
return actionForceTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatus
|
|
||||||
*/
|
|
||||||
public Status getActionStatus() {
|
public Status getActionStatus() {
|
||||||
return actionStatus;
|
return actionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionCreatedAt
|
|
||||||
*/
|
|
||||||
public Long getActionCreatedAt() {
|
public Long getActionCreatedAt() {
|
||||||
return actionCreatedAt;
|
return actionCreatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionLastModifiedAt
|
|
||||||
*/
|
|
||||||
public Long getActionLastModifiedAt() {
|
public Long getActionLastModifiedAt() {
|
||||||
return actionLastModifiedAt;
|
return actionLastModifiedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsId
|
|
||||||
*/
|
|
||||||
public Long getDsId() {
|
public Long getDsId() {
|
||||||
return dsId;
|
return dsId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsName
|
|
||||||
*/
|
|
||||||
public String getDsName() {
|
public String getDsName() {
|
||||||
return dsName;
|
return dsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the dsVersion
|
|
||||||
*/
|
|
||||||
public String getDsVersion() {
|
public String getDsVersion() {
|
||||||
return dsVersion;
|
return dsVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actionStatusCount
|
|
||||||
*/
|
|
||||||
public Long getActionStatusCount() {
|
public Long getActionStatusCount() {
|
||||||
return actionStatusCount;
|
return actionStatusCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the rolloutName
|
|
||||||
*/
|
|
||||||
public String getRolloutName() {
|
public String getRolloutName() {
|
||||||
return rolloutName;
|
return rolloutName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,10 @@ import javax.persistence.MappedSuperclass;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tenant specific locally stored artifact representation that is used by
|
* Tenant specific locally stored artifact representation that is used by
|
||||||
* {@link SoftwareModule} .
|
* {@link SoftwareModule}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class Artifact extends BaseEntity {
|
public abstract class Artifact extends TenantAwareBaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "sha1_hash", length = 40, nullable = true)
|
@Column(name = "sha1_hash", length = 40, nullable = true)
|
||||||
@@ -34,49 +30,27 @@ public abstract class Artifact extends BaseEntity {
|
|||||||
|
|
||||||
public abstract SoftwareModule getSoftwareModule();
|
public abstract SoftwareModule getSoftwareModule();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the md5Hash
|
|
||||||
*/
|
|
||||||
public String getMd5Hash() {
|
public String getMd5Hash() {
|
||||||
return md5Hash;
|
return md5Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the sha1Hash
|
|
||||||
*/
|
|
||||||
public String getSha1Hash() {
|
public String getSha1Hash() {
|
||||||
return sha1Hash;
|
return sha1Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param md5Hash
|
|
||||||
* the md5Hash to set
|
|
||||||
*/
|
|
||||||
public void setMd5Hash(final String md5Hash) {
|
public void setMd5Hash(final String md5Hash) {
|
||||||
this.md5Hash = md5Hash;
|
this.md5Hash = md5Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sha1Hash
|
|
||||||
* the sha1Hash to set
|
|
||||||
*/
|
|
||||||
public void setSha1Hash(final String sha1Hash) {
|
public void setSha1Hash(final String sha1Hash) {
|
||||||
this.sha1Hash = sha1Hash;
|
this.sha1Hash = sha1Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the size
|
|
||||||
*/
|
|
||||||
public Long getSize() {
|
public Long getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param size
|
|
||||||
* the size to set
|
|
||||||
*/
|
|
||||||
public void setSize(final Long size) {
|
public void setSize(final Long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.model;
|
package org.eclipse.hawkbit.repository.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic assigment result bean.
|
* Generic assignment result bean.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AssignmentResult {
|
public class AssignmentResult<T extends BaseEntity> {
|
||||||
|
|
||||||
private final int total;
|
private final int total;
|
||||||
private final int assigned;
|
private final int assigned;
|
||||||
private final int alreadyAssigned;
|
private final int alreadyAssigned;
|
||||||
|
|
||||||
|
private final int unassigned;
|
||||||
|
private final List<T> assignedEntity;
|
||||||
|
private final List<T> unassignedEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -27,34 +30,47 @@ public class AssignmentResult {
|
|||||||
* @param assigned
|
* @param assigned
|
||||||
* is the number of newly assigned elements.
|
* is the number of newly assigned elements.
|
||||||
* @param alreadyAssigned
|
* @param alreadyAssigned
|
||||||
* is the number of already assigned elements.
|
* number of already assigned/ignored elements
|
||||||
|
* @param unassigned
|
||||||
|
* number of newly assigned elements
|
||||||
|
* @param assignedEntity
|
||||||
|
* {@link List} of assigned entity.
|
||||||
|
* @param unassignedEntity
|
||||||
|
* {@link List} of unassigned entity.
|
||||||
*/
|
*/
|
||||||
public AssignmentResult(final int assigned, final int alreadyAssigned) {
|
public AssignmentResult(final int assigned, final int alreadyAssigned, final int unassigned,
|
||||||
super();
|
final List<T> assignedEntity, final List<T> unassignedEntity) {
|
||||||
this.assigned = assigned;
|
this.assigned = assigned;
|
||||||
this.alreadyAssigned = alreadyAssigned;
|
this.alreadyAssigned = alreadyAssigned;
|
||||||
total = assigned + alreadyAssigned;
|
total = assigned + alreadyAssigned;
|
||||||
|
this.unassigned = unassigned;
|
||||||
|
this.assignedEntity = assignedEntity;
|
||||||
|
this.unassignedEntity = unassignedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assignedTargets
|
|
||||||
*/
|
|
||||||
public int getAssigned() {
|
public int getAssigned() {
|
||||||
return assigned;
|
return assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the total
|
|
||||||
*/
|
|
||||||
public int getTotal() {
|
public int getTotal() {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the alreadyAssigned
|
|
||||||
*/
|
|
||||||
public int getAlreadyAssigned() {
|
public int getAlreadyAssigned() {
|
||||||
return alreadyAssigned;
|
return alreadyAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getUnassigned() {
|
||||||
|
return unassigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getAssignedEntity() {
|
||||||
|
return assignedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getUnassignedEntity() {
|
||||||
|
return unassignedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,10 @@ import javax.persistence.GeneratedValue;
|
|||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.PrePersist;
|
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.eventbus.CacheFieldEntityListener;
|
import org.eclipse.hawkbit.eventbus.CacheFieldEntityListener;
|
||||||
import org.eclipse.hawkbit.eventbus.EntityPropertyChangeListener;
|
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.CreatedBy;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
import org.springframework.data.annotation.LastModifiedBy;
|
||||||
@@ -37,18 +30,12 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|||||||
import org.springframework.hateoas.Identifiable;
|
import org.springframework.hateoas.Identifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder of all base attributes common to all entities.
|
* Holder of the base attributes common to all entities.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@Access(AccessType.FIELD)
|
@Access(AccessType.FIELD)
|
||||||
@EntityListeners({ AuditingEntityListener.class, CacheFieldEntityListener.class, EntityPropertyChangeListener.class })
|
@EntityListeners({ AuditingEntityListener.class, CacheFieldEntityListener.class, EntityPropertyChangeListener.class })
|
||||||
@TenantDiscriminatorColumn(name = "tenant", length = 40)
|
|
||||||
@Multitenant(MultitenantType.SINGLE_TABLE)
|
|
||||||
public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -66,44 +53,11 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
@Column(name = "optlock_revision")
|
@Column(name = "optlock_revision")
|
||||||
private long optLockRevision;
|
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() {
|
public BaseEntity() {
|
||||||
|
// Default constructor needed for JPA entities.
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Access(AccessType.PROPERTY)
|
@Access(AccessType.PROPERTY)
|
||||||
@@ -130,37 +84,21 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
return lastModifiedBy;
|
return lastModifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param createdBy
|
|
||||||
* the createdBy to set
|
|
||||||
*/
|
|
||||||
@CreatedBy
|
@CreatedBy
|
||||||
public void setCreatedBy(final String createdBy) {
|
public void setCreatedBy(final String createdBy) {
|
||||||
this.createdBy = createdBy;
|
this.createdBy = createdBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastModifiedBy
|
|
||||||
* the lastModifiedBy to set
|
|
||||||
*/
|
|
||||||
@LastModifiedBy
|
@LastModifiedBy
|
||||||
public void setLastModifiedBy(final String lastModifiedBy) {
|
public void setLastModifiedBy(final String lastModifiedBy) {
|
||||||
this.lastModifiedBy = lastModifiedBy;
|
this.lastModifiedBy = lastModifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param createdAt
|
|
||||||
* the createdAt to set
|
|
||||||
*/
|
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
public void setCreatedAt(final Long createdAt) {
|
public void setCreatedAt(final Long createdAt) {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param lastModifiedAt
|
|
||||||
* the lastModifiedAt to set
|
|
||||||
*/
|
|
||||||
@LastModifiedDate
|
@LastModifiedDate
|
||||||
public void setLastModifiedAt(final Long lastModifiedAt) {
|
public void setLastModifiedAt(final Long lastModifiedAt) {
|
||||||
this.lastModifiedAt = lastModifiedAt;
|
this.lastModifiedAt = lastModifiedAt;
|
||||||
@@ -170,49 +108,29 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
return optLockRevision;
|
return optLockRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// for test purposes only
|
||||||
* @return the tenant
|
void setOptLockRevision(final long optLockRevision) {
|
||||||
*/
|
this.optLockRevision = optLockRevision;
|
||||||
public String getTenant() {
|
|
||||||
return tenant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tenant
|
|
||||||
* the tenant to set
|
|
||||||
*/
|
|
||||||
public void setTenant(final String tenant) {
|
|
||||||
this.tenant = tenant;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BaseEntity [id=" + id + "]";
|
return "BaseEntity [id=" + id + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id
|
|
||||||
* the id to set
|
|
||||||
*/
|
|
||||||
public void setId(final Long id) {
|
public void setId(final Long id) {
|
||||||
this.id = 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()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
@@ -222,11 +140,14 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||||
result = prime * result + (int) (optLockRevision ^ optLockRevision >>> 32);
|
result = prime * result + (int) (optLockRevision ^ optLockRevision >>> 32);
|
||||||
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
return result;
|
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)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@@ -239,7 +160,7 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(this.getClass().isInstance(obj))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BaseEntity other = (BaseEntity) obj;
|
final BaseEntity other = (BaseEntity) obj;
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import java.io.Serializable;
|
|||||||
/**
|
/**
|
||||||
* Use to display software modules for the selected distribution.
|
* Use to display software modules for the selected distribution.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CustomSoftwareModule implements Serializable {
|
public class CustomSoftwareModule implements Serializable {
|
||||||
|
|
||||||
@@ -39,17 +36,51 @@ public class CustomSoftwareModule implements Serializable {
|
|||||||
this.assigned = assigned;
|
this.assigned = assigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the softwareModule
|
|
||||||
*/
|
|
||||||
public SoftwareModule getSoftwareModule() {
|
public SoftwareModule getSoftwareModule() {
|
||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the assigned
|
|
||||||
*/
|
|
||||||
public boolean isAssigned() {
|
public boolean isAssigned() {
|
||||||
return assigned;
|
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.
|
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||||
@@ -67,14 +63,14 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
|
|
||||||
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
@ManyToMany(targetEntity = SoftwareModule.class, fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "sp_ds_module", joinColumns = {
|
@JoinTable(name = "sp_ds_module", joinColumns = {
|
||||||
@JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds") ) }, inverseJoinColumns = {
|
@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 = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module")) })
|
||||||
private final Set<SoftwareModule> modules = new HashSet<>();
|
private final Set<SoftwareModule> modules = new HashSet<>();
|
||||||
|
|
||||||
@ManyToMany(targetEntity = DistributionSetTag.class)
|
@ManyToMany(targetEntity = DistributionSetTag.class)
|
||||||
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
@JoinTable(name = "sp_ds_dstag", joinColumns = {
|
||||||
@JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds") ) }, inverseJoinColumns = {
|
@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 = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag")) })
|
||||||
private Set<DistributionSetTag> tags = new HashSet<>();
|
private Set<DistributionSetTag> tags = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "deleted")
|
@Column(name = "deleted")
|
||||||
@@ -95,7 +91,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
private final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
private final List<DistributionSetMetadata> metadata = new ArrayList<>();
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private DistributionSetType type;
|
||||||
|
|
||||||
@Column(name = "complete")
|
@Column(name = "complete")
|
||||||
@@ -130,75 +126,34 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
if (moduleList != null) {
|
if (moduleList != null) {
|
||||||
moduleList.forEach(this::addModule);
|
moduleList.forEach(this::addModule);
|
||||||
}
|
}
|
||||||
complete = type.checkComplete(this);
|
if (this.type != null) {
|
||||||
|
complete = this.type.checkComplete(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DistributionSetTag> getTags() {
|
public Set<DistributionSetTag> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the deleted
|
|
||||||
*/
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the metadata
|
* @return immutable list of meta data elements.
|
||||||
*/
|
*/
|
||||||
public List<DistributionSetMetadata> getMetadata() {
|
public List<DistributionSetMetadata> getMetadata() {
|
||||||
return metadata;
|
return Collections.unmodifiableList(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the actions
|
|
||||||
*/
|
|
||||||
public List<Action> getActions() {
|
public List<Action> getActions() {
|
||||||
return actions;
|
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() {
|
public boolean isRequiredMigrationStep() {
|
||||||
return requiredMigrationStep;
|
return requiredMigrationStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param deleted
|
|
||||||
* the deleted to set
|
|
||||||
*/
|
|
||||||
public DistributionSet setDeleted(final boolean deleted) {
|
public DistributionSet setDeleted(final boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
return this;
|
return this;
|
||||||
@@ -209,10 +164,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param tags
|
|
||||||
* the tags to set
|
|
||||||
*/
|
|
||||||
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
public DistributionSet setTags(final Set<DistributionSetTag> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
return this;
|
return this;
|
||||||
@@ -232,11 +183,6 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return installedAtTargets;
|
return installedAtTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
return "DistributionSet [getName()=" + getName() + ", getOptLockRevision()=" + getOptLockRevision()
|
||||||
@@ -322,7 +268,7 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
* Searches through modules for the given type.
|
* Searches through modules for the given type.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* to seach for
|
* to search for
|
||||||
* @return SoftwareModule of given type or <code>null</code> if not in the
|
* @return SoftwareModule of given type or <code>null</code> if not in the
|
||||||
* list.
|
* list.
|
||||||
*/
|
*/
|
||||||
@@ -337,26 +283,15 @@ public class DistributionSet extends NamedVersionedEntity {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the type
|
|
||||||
*/
|
|
||||||
public DistributionSetType getType() {
|
public DistributionSetType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type
|
|
||||||
* the type to set
|
|
||||||
*/
|
|
||||||
public void setType(final DistributionSetType type) {
|
public void setType(final DistributionSetType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the complete
|
|
||||||
*/
|
|
||||||
public boolean isComplete() {
|
public boolean isComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import java.io.Serializable;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetIdName implements Serializable {
|
public class DistributionSetIdName implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
@@ -39,9 +36,6 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -50,40 +44,27 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof DistributionSetIdName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
||||||
@@ -97,11 +78,6 @@ public class DistributionSetIdName implements Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// only return the ID because it's used in vaadin for setting the item
|
// 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;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata for {@link DistributionSet}.
|
* Meta data for {@link DistributionSet}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@IdClass(DsMetadataCompositeKey.class)
|
@IdClass(DsMetadataCompositeKey.class)
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_ds_metadata")
|
@Table(name = "sp_ds_metadata")
|
||||||
public class DistributionSetMetadata implements Serializable {
|
public class DistributionSetMetadata implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@@ -49,11 +42,11 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@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;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
public DistributionSetMetadata() {
|
public DistributionSetMetadata() {
|
||||||
|
// Default constructor for JPA.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,49 +66,66 @@ public class DistributionSetMetadata implements Serializable {
|
|||||||
return new DsMetadataCompositeKey(distributionSet, key);
|
return new DsMetadataCompositeKey(distributionSet, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the key
|
|
||||||
*/
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key
|
|
||||||
* the key to set
|
|
||||||
*/
|
|
||||||
public void setKey(final String key) {
|
public void setKey(final String key) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param distributionSet
|
|
||||||
* the distributionSet to set
|
|
||||||
*/
|
|
||||||
public void setDistributionSet(final DistributionSet distributionSet) {
|
public void setDistributionSet(final DistributionSet distributionSet) {
|
||||||
this.distributionSet = distributionSet;
|
this.distributionSet = distributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the value
|
|
||||||
*/
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param value
|
|
||||||
* the value to set
|
|
||||||
*/
|
|
||||||
public void setValue(final String value) {
|
public void setValue(final String value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSet
|
|
||||||
*/
|
|
||||||
public DistributionSet getDistributionSet() {
|
public DistributionSet getDistributionSet() {
|
||||||
return distributionSet;
|
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
|
* A {@link DistributionSetTag} is used to describe DistributionSet attributes
|
||||||
* and use them also for filtering the DistributionSet list.
|
* and use them also for filtering the DistributionSet list.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distributionset_tag", indexes = {
|
@Table(name = "sp_distributionset_tag", indexes = {
|
||||||
@Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@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 {
|
public class DistributionSetTag extends Tag {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -69,11 +64,6 @@ public class DistributionSetTag extends Tag {
|
|||||||
return assignedToDistributionSet;
|
return assignedToDistributionSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#hashCode()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -82,16 +72,8 @@ public class DistributionSetTag extends Tag {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!super.equals(obj)) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,11 @@ package org.eclipse.hawkbit.repository.model;
|
|||||||
import java.util.List;
|
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<DistributionSet> {
|
||||||
|
|
||||||
private final int unassigned;
|
|
||||||
private final List<DistributionSet> assignedDs;
|
|
||||||
private final List<DistributionSet> unassignedDs;
|
|
||||||
private final DistributionSetTag distributionSetTag;
|
private final DistributionSetTag distributionSetTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,42 +34,16 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult {
|
|||||||
* @param distributionSetTag
|
* @param distributionSetTag
|
||||||
* the assigned or unassigned tag
|
* 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 List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
||||||
final DistributionSetTag distributionSetTag) {
|
final DistributionSetTag distributionSetTag) {
|
||||||
super(assigned, alreadyAssigned);
|
super(assigned, alreadyAssigned,unassigned, assignedDs, unassignedDs);
|
||||||
this.unassigned = unassigned;
|
|
||||||
this.assignedDs = assignedDs;
|
|
||||||
this.unassignedDs = unassignedDs;
|
|
||||||
this.distributionSetTag = distributionSetTag;
|
this.distributionSetTag = distributionSetTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the unassigned
|
|
||||||
*/
|
|
||||||
public int getUnassigned() {
|
|
||||||
return unassigned;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the distributionSetTag
|
|
||||||
*/
|
|
||||||
public DistributionSetTag getDistributionSetTag() {
|
public DistributionSetTag getDistributionSetTag() {
|
||||||
return distributionSetTag;
|
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