Spring Boot 2.0 (#721)

* Migration to Boot 2.0.

Signed-off-by: Kai Zimmermann <kai.zimmermann@microsoft.com>
This commit is contained in:
Kai Zimmermann
2019-01-31 07:29:27 +01:00
committed by GitHub
parent b42b009f9e
commit d52a720480
263 changed files with 2874 additions and 2692 deletions

View File

@@ -54,7 +54,7 @@
|org.apache.tomcat|tomcat-juli|8.0.28| [CQ10618](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10618) | |org.apache.tomcat|tomcat-juli|8.0.28| [CQ10618](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10618) |
|org.flywaydb|flyway-core|4.0.3| [CQ12947](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12947) | |org.flywaydb|flyway-core|4.0.3| [CQ12947](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12947) |
|org.glassfish|javax.json|1.0.4| [CQ10619](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10619) | |org.glassfish|javax.json|1.0.4| [CQ10619](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10619) |
|org.hibernate|hibernate-validator|6.0.7.Final| [CQ15540](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15540) | |org.hibernate.validator|hibernate-validator|6.0.7.Final| [CQ15540](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15540) |
|org.jboss.logging|jboss-logging|3.2.1.Final| [CQ10621](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10621) | |org.jboss.logging|jboss-logging|3.2.1.Final| [CQ10621](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10621) |
|org.jsoup|jsoup|1.8.3| [CQ12936](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12936) | |org.jsoup|jsoup|1.8.3| [CQ12936](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12936) |
|org.ow2.asm|asm-commons|5.0.1| [CQ12945](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12945) | |org.ow2.asm|asm-commons|5.0.1| [CQ12945](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12945) |

198
.3rd-party/Release_0_3_0.md vendored Normal file
View File

@@ -0,0 +1,198 @@
# 3rd party dependencies for Release 0.3.0
## Eclipse CQs - Provided/compile
| Group ID | Artifact ID | Version | CQ |
| ------------------------------------ | ------------------------------ | -------------- | ---------------------------------------------------------------- |
| ch.qos.logback | logback-classic | 1.2.3 | [CQ17369](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17369) |
| ch.qos.logback | logback-core | 1.2.3 | [CQ17370](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17370) |
| com.cronutils | cron-utils | 5.0.5 | [CQ15762](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15762) |
| com.esotericsoftware | kryo-shaded | 3.0.3 | [CQ17372](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17372) |
| com.esotericsoftware | minlog | 1.3.0 | [CQ17371](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17371) |
| com.fasterxml | classmate | 1.3.4 | [CQ10239](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10239) |
| com.fasterxml.jackson.core | jackson-annotations | 2.9.0 | [CQ18146](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18146) |
| com.fasterxml.jackson.core | jackson-core | 2.9.7 | [CQ18147](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18147) |
| com.fasterxml.jackson.core | jackson-databind | 2.9.7 | [CQ18145](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18145) |
| com.github.ben-manes.caffeine | caffeine | 2.6.2 | [CQ17377](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17377) |
| com.github.gwtd3 | gwt-d3-api | 1.2.0 | [CQ13029](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13029) |
| com.github.gwtd3 | gwt-d3-js | 3.5.11 | [CQ13030](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13030) |
| com.google.guava | guava | 25.0-jre | [CQ16201](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=16201) |
| com.h2database | h2 | 1.4.197 | [CQ10365](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10365) |
| com.microsoft.sqlserver | mssql-jdbc | 6.4.0 | [CQ15896](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15896) |
| commons-io | commons-io | 2.5 | [CQ17374](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17374) |
| com.rabbitmq | amqp-client | 5.4.3 | [CQ18173](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18173) |
| com.vaadin.external.atmosphere | atmosphere-runtime | 2.2.9.vaadin2 | [CQ10714](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10714) |
| com.vaadin.external.flute | flute | 1.3.0.gg2 | [CQ11039](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11039) |
| com.vaadin.external.gwt | gwt-elemental | 2.7.0.vaadin4 | [CQ13031](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13031) |
| com.vaadin.external.gwt | gwt-user | 2.7.0.vaadin4 | [CQ13033](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13033) |
| com.vaadin.external.slf4j | vaadin-slf4j-jdk14 | 1.6.1 | [CQ10715](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10715) |
| com.vaadin | vaadin-client | 7.7.7 | [CQ12956](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12956) |
| com.vaadin | vaadin-push | 7.7.7 | [CQ12957](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12957) |
| com.vaadin | vaadin-sass-compiler | 0.9.12 | [CQ12958](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12958) |
| com.vaadin | vaadin-server | 7.7.7 | [CQ12959](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12959) |
| com.vaadin | vaadin-shared | 7.7.7 | [CQ12960](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12960) |
| com.vaadin | vaadin-spring-boot | 1.2.0 | [CQ18180](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18180) |
| com.vaadin | vaadin-spring | 1.2.0 | [CQ18181](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18181) |
| com.vaadin | vaadin-themes | 7.7.7 | [CQ12961](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12961) |
| com.zaxxer | HikariCP | 3.2.0 | [CQ18175](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18175) |
| cz.jirutka.rsql | rsql-parser | 2.1.0 | [CQ12964](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12964) |
| io.projectreactor | reactor-core | 3.2.2.RELEASE | [CQ18176](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18176) |
| io.protostuff | protostuff-api | 1.5.6 | [CQ12965](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12965) |
| io.protostuff | protostuff-collectionschema | 1.5.6 | [CQ12966](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12966) |
| io.protostuff | protostuff-core | 1.5.6 | [CQ12967](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12967) |
| io.protostuff | protostuff-runtime | 1.5.6 | [CQ12968](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12968) |
| javax.annotation | javax.annotation-api | 1.3.2 | [CQ17375](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=17375) |
| org.glassfish | javax.json | 1.0.4 | [CQ10619](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10619) |
| javax.servlet | javax.servlet-api | 4.0.1 | [CQ18011](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18011) |
| javax.transaction | javax.transaction-api | 1.3 | [CQ18178](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18178) |
| javax.validation | validation-api | 2.0.1.Final | [CQ18177](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18177) |
| javax.websocket | javax.websocket-api | 1.1 | [CQ16449](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=16449) |
| org.apache.commons | commons-lang3 | 3.7 | [CQ18140](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18140) |
| org.flywaydb | flyway-core | 5.2.1 | [CQ18182](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18182) |
| org.hibernate.validator | hibernate-validator | 6.0.13.Final | [CQ15540](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=15540) |
| org.jboss.logging | jboss-logging | 3.3.2.Final | [CQ10621](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=10621) |
| org.jsoup | jsoup | 1.8.3 | [CQ12936](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12936) |
| org.mortbay.jasper | apache-el | 8.5.33 | [CQ18233](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18233) |
| org.ow2.asm | asm-analysis | 6.2 | [CQ18183](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18183) |
| org.ow2.asm | asm-commons | 6.2 | [CQ18183](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18183) |
| org.ow2.asm | asm | 6.2 | [CQ18183](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18183) |
| org.ow2.asm | asm-tree | 6.2 | [CQ18183](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18183) |
| org.reactivestreams | reactive-streams | 1.0.2 | [CQ18184](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18184) |
| org.slf4j | jul-to-slf4j | 1.7.25 | [CQ12937](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12937) |
| org.slf4j | slf4j-api | 1.7.25 | [CQ12940](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12940) |
| org.springframework.amqp | spring-amqp | 2.1.0.RELEASE | [CQ18141](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18141) |
| org.springframework.amqp | spring-rabbit | 2.1.0.RELEASE | [CQ18142](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18142) |
| org.springframework.boot | spring-boot-autoconfigure | 2.1.0.RELEASE | [CQ18143](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18143) |
| org.springframework.boot | spring-boot | 2.1.0.RELEASE | [CQ18192](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18192) |
| org.springframework.boot | spring-boot-starter-aop | 2.1.0.RELEASE | [CQ18198](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18198) |
| org.springframework.boot | spring-boot-starter-data-jpa | 2.1.0.RELEASE | [CQ18200](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18200) |
| org.springframework.boot | spring-boot-starter | 2.1.0.RELEASE | [CQ18204](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18204) |
| org.springframework.boot | spring-boot-starter-jdbc | 2.1.0.RELEASE | [CQ18205](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18205) |
| org.springframework.boot | spring-boot-starter-jetty | 2.1.0.RELEASE | [CQ18206](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18206) |
| org.springframework.boot | spring-boot-starter-json | 2.1.0.RELEASE | [CQ18209](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18209) |
| org.springframework.boot | spring-boot-starter-logging | 2.1.0.RELEASE | [CQ18210](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18210) |
| org.springframework.boot | spring-boot-starter-validation | 2.1.0.RELEASE | [CQ18211](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18211) |
| org.springframework.boot | spring-boot-starter-web | 2.1.0.RELEASE | [CQ18212](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18212) |
| org.springframework.cloud | spring-cloud-bus | 2.1.0.RELEASE | [CQ18799](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18799) |
| org.springframework.cloud | spring-cloud-commons | 2.1.0.RELEASE | [CQ18800](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18800) |
| org.springframework.cloud | spring-cloud-context | 2.1.0.RELEASE | [CQ18801](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18801) |
| org.springframework.cloud | spring-cloud-stream | 2.1.0.RELEASE | [CQ18802](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18802) |
| org.springframework.data | spring-data-commons | 2.1.2.RELEASE | [CQ18213](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18213) |
| org.springframework.data | spring-data-jpa | 2.1.2.RELEASE | [CQ18214](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18214) |
| org.springframework.hateoas | spring-hateoas | 0.25.0.RELEASE | [CQ18228](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18228) |
| org.springframework.integration | spring-integration-core | 5.1.0.RELEASE | [CQ18229](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18229) |
| org.springframework.integration | spring-integration-jmx | 5.1.0.RELEASE | [CQ18230](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18230) |
| org.springframework.integration | spring-integration-tuple | 1.0.0.RELEASE | [CQ12996](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12996) |
| org.springframework.plugin | spring-plugin-core | 1.2.0.RELEASE | [CQ12997](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12997) |
| org.springframework.retry | spring-retry | 1.2.2.RELEASE | [CQ18231](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18231) |
| org.springframework.security | spring-security-aspects | 5.1.1.RELEASE | [CQ18350](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18350) |
| org.springframework.security | spring-security-config | 5.1.1.RELEASE | [CQ18351](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18351) |
| org.springframework.security | spring-security-core | 5.1.1.RELEASE | [CQ18352](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18352) |
| org.springframework.security | spring-security-crypto | 5.1.1.RELEASE | [CQ18353](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18353) |
| org.springframework.security | spring-security-web | 5.1.1.RELEASE | [CQ18354](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18354) |
| org.springframework | spring-aop | 5.1.2.RELEASE | [CQ18355](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18355) |
| org.springframework | spring-aspects | 5.1.2.RELEASE | [CQ18356](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18356) |
| org.springframework | spring-beans | 5.1.2.RELEASE | [CQ18357](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18357) |
| org.springframework | spring-context | 5.1.2.RELEASE | [CQ18358](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18358) |
| org.springframework | spring-context-support | 5.1.2.RELEASE | [CQ18359](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18359) |
| org.springframework | spring-core | 5.1.2.RELEASE | [CQ18360](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18360) |
| org.springframework | spring-expression | 5.1.2.RELEASE | [CQ18361](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18361) |
| org.springframework | spring-jcl | 5.1.2.RELEASE | [CQ18362](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18362) |
| org.springframework | spring-jdbc | 5.1.2.RELEASE | [CQ18363](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18363) |
| org.springframework | spring-messaging | 5.1.2.RELEASE | [CQ18364](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18364) |
| org.springframework | spring-orm | 5.1.2.RELEASE | [CQ18365](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18365) |
| org.springframework | spring-tuple | 1.0.0.RELEASE | [CQ12998](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=12998) |
| org.springframework | spring-tx | 5.1.2.RELEASE | [CQ18366](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18366) |
| org.springframework | spring-web | 5.1.2.RELEASE | [CQ18367](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18367) |
| org.springframework | spring-webmvc | 5.1.2.RELEASE | [CQ18368](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18368) |
| org.vaadin.addons.lazyquerycontainer | vaadin-lazyquerycontainer | 7.6.1.3 | [CQ13025](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13025) |
| org.vaadin.addons | flexibleoptiongroup | 2.2.0 | [CQ11050](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11050) |
| org.vaadin.addons | tokenfield | 7.0.1 | [CQ11051](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11051) |
| org.vaadin.alump.distributionbar | dbar-addon | 2.0.0 | [CQ13026](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=13026) |
| org.vaadin.spring.addons | vaadin-spring-addon-eventbus | 0.0.6.RELEASE | [CQ11047](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11047) |
| org.vaadin.spring.extensions | vaadin-spring-ext-core | 0.0.6.RELEASE | [CQ11048](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11048) |
| org.vaadin.spring.extensions | vaadin-spring-ext-security | 0.0.6.RELEASE | [CQ11049](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11049) |
| org.w3c.css | sac | 1.3 | [CQ11052](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=11052) |
## Test and build dependencies
CQ: [CQ18804](https://dev.eclipse.org/ipzilla/show_bug.cgi?id=18804)
| Group ID | Artifact ID | Version |
| ------------------------------- | -------------------------------- | -------------------- |
| ant | ant | 1.6.5 |
| colt | colt | 1.2.0 |
| com.fasterxml.jackson.module | jackson-module-jaxb-annotations | 2.9.8 |
| com.google.code.gson | gson | 2.8.5 |
| com.google.gwt.gwtmockito | gwtmockito | 1.1.8 |
| com.google.gwt | gwt-dev | 2.8.0 |
| com.google.gwt | gwt-user | 2.8.0 |
| com.google.jsinterop | jsinterop-annotations | 1.0.1 |
| com.google.jsinterop | jsinterop-annotations | sources |
| com.ibm.icu | icu4j | 50.1.1 |
| com.jayway.jsonpath | json-path | 2.4.0 |
| com.rabbitmq | http-client | 2.1.0.RELEASE |
| com.vaadin.external.google | android-json | 0.0.20131108.vaadin1 |
| commons-codec | commons-codec | 1.11 |
| commons-collections | commons-collections | 3.2.2 |
| commons-net | commons-net | 3.6 |
| io.qameta.allure | allure-java-commons | 2.7.0 |
| io.qameta.allure | allure-junit4 | 2.7.0 |
| io.qameta.allure | allure2-model-api | 1.0.0 |
| io.qameta.allure | allure2-model-jackson | 1.0.0 |
| io.qameta.allure | allure2-model-pojo | 1.0.0 |
| javax.el | javax.el-api | 2.2.4 |
| junit | junit | 4.12 |
| net.\_01001111 | jlorem | 1.1 |
| net.bytebuddy | byte-buddy-agent | 1.9.7 |
| net.bytebuddy | byte-buddy | 1.9.7 |
| net.minidev | accessors-smart | 1.2 |
| net.minidev | json-smart | 2.3 |
| net.sourceforge.htmlunit | htmlunit-core-js | 2.33 |
| net.sourceforge.htmlunit | htmlunit-cssparser | 1.2.0 |
| net.sourceforge.htmlunit | htmlunit | 2.33 |
| net.sourceforge.htmlunit | neko-htmlunit | 2.33 |
| org.apache.commons | commons-text | 1.4 |
| org.apache.httpcomponents | httpclient | 4.5.6 |
| org.apache.httpcomponents | httpcore | 4.4.10 |
| org.apache.httpcomponents | httpmime | 4.5.6 |
| org.apache.tika | tika-core | 1.14 |
| org.apache.tomcat.embed | tomcat-embed-el | 9.0.14 |
| org.aspectj | aspectjrt | 1.9.2 |
| org.aspectj | aspectjweaver | 1.9.2 |
| org.assertj | assertj-core | 3.11.1 |
| org.awaitility | awaitility | 3.1.2 |
| org.hamcrest | hamcrest-all | 1.3 |
| org.hamcrest | hamcrest-core | 1.3 |
| org.hamcrest | hamcrest-library | 1.3 |
| org.javassist | javassist | 3.22.0-GA |
| org.jooq | joor-java-8 | 0.9.9 |
| org.mariadb.jdbc | mariadb-java-client | 2.3.0 |
| org.mockito | mockito-core | 2.23.4 |
| org.mortbay.jasper | apache-jsp | 8.5.33.1 |
| org.objenesis | objenesis | 2.6 |
| org.ow2.asm | asm-commons | 5.0.3 |
| org.ow2.asm | asm-tree | 5.0.3 |
| org.ow2.asm | asm-util | 5.0.3 |
| org.ow2.asm | asm | 5.0.3 |
| org.ow2.asm | asm | 5.0.4 |
| org.skyscreamer | jsonassert | 1.5.0 |
| org.springframework.amqp | spring-rabbit-junit | 2.1.3.RELEASE |
| org.springframework.amqp | spring-rabbit-test | 2.1.3.RELEASE |
| org.springframework.boot | spring-boot-starter-test | 2.1.2.RELEASE |
| org.springframework.boot | spring-boot-test-autoconfigure | 2.1.2.RELEASE |
| org.springframework.boot | spring-boot-test | 2.1.2.RELEASE |
| org.springframework.cloud | spring-cloud-stream-binder-test | 2.1.0.RELEASE |
| org.springframework.cloud | spring-cloud-stream-test-support | 2.1.0.RELEASE |
| org.springframework.integration | spring-integration-test-support | 5.1.2.RELEASE |
| org.springframework.integration | spring-integration-test | 5.1.2.RELEASE |
| org.springframework.restdocs | spring-restdocs-core | 2.0.3.RELEASE |
| org.springframework.restdocs | spring-restdocs-mockmvc | 2.0.3.RELEASE |
| org.springframework | spring-test | 5.1.4.RELEASE |
| org.xmlunit | xmlunit-core | 2.6.2 |
| org.yaml | snakeyaml | 1.23 |
| tapestry | tapestry | 4.0.2 |
| xalan | serializer | 2.7.2 |
| xalan | xalan | 2.7.2 |
| xerces | xercesImpl | 2.12.0 |
| xml-apis | xml-apis | 1.4.01 |

232
.3rd-party/compile.txt vendored
View File

@@ -1,115 +1,117 @@
aopalliance:aopalliance:jar:1.0:compile ch.qos.logback:logback-classic:jar:1.2.3:compile
ch.qos.logback:logback-classic:jar:1.1.11:compile ch.qos.logback:logback-core:jar:1.2.3:compile
ch.qos.logback:logback-core:jar:1.1.11:compile com.cronutils:cron-utils:jar:5.0.5:compile
com.cronutils:cron-utils:jar:5.0.5:compile com.esotericsoftware:kryo-shaded:jar:3.0.3:compile
com.fasterxml.jackson.core:jackson-annotations:jar:2.8.9:compile com.esotericsoftware:minlog:jar:1.3.0:compile
com.fasterxml.jackson.core:jackson-core:jar:2.8.9:compile com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
com.fasterxml.jackson.core:jackson-databind:jar:2.8.9:compile com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile
com.fasterxml:classmate:jar:1.3.3:compile com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile
com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile
com.github.gwtd3:gwt-d3-api:jar:1.2.0:compile com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile
com.github.gwtd3:gwt-d3-js:jar:3.5.11:compile com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile
com.github.gwtd3:gwt-d3-js:jar:sources:3.5.11:compile com.fasterxml:classmate:jar:1.3.4:compile
com.google.guava:guava:jar:25.0-jre:compile com.github.ben-manes.caffeine:caffeine:jar:2.6.2:compile
com.h2database:h2:jar:1.4.195:compile com.github.gwtd3:gwt-d3-api:jar:1.2.0:compile
com.microsoft.sqlserver:mssql-jdbc:jar:6.4.0.jre8:compile com.github.gwtd3:gwt-d3-js:jar:3.5.11:compile
com.rabbitmq:amqp-client:jar:4.0.3:compile com.github.gwtd3:gwt-d3-js:jar:sources:3.5.11:compile
com.rabbitmq:http-client:jar:1.3.1.RELEASE:compile com.google.guava:guava:jar:25.0-jre:compile
com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.9.vaadin2:compile com.h2database:h2:jar:1.4.197:compile
com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile com.microsoft.sqlserver:mssql-jdbc:jar:6.4.0.jre8:compile
com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin6:compile com.rabbitmq:amqp-client:jar:5.4.3:compile
com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin6:compile com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.9.vaadin2:compile
com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile
com.vaadin:vaadin-client:jar:7.7.13:compile com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin6:compile
com.vaadin:vaadin-push:jar:7.7.13:compile com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin6:compile
com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile
com.vaadin:vaadin-server:jar:7.7.13:compile com.vaadin:vaadin-client:jar:7.7.13:compile
com.vaadin:vaadin-shared:jar:7.7.13:compile com.vaadin:vaadin-push:jar:7.7.13:compile
com.vaadin:vaadin-spring-boot:jar:1.1.1:compile com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile
com.vaadin:vaadin-spring:jar:1.1.1:compile com.vaadin:vaadin-server:jar:7.7.13:compile
com.vaadin:vaadin-themes:jar:7.7.13:compile com.vaadin:vaadin-shared:jar:7.7.13:compile
commons-codec:commons-codec:jar:1.10:compile com.vaadin:vaadin-spring-boot:jar:1.2.0:compile
commons-io:commons-io:jar:2.4:compile com.vaadin:vaadin-spring:jar:1.2.0:compile
cz.jirutka.rsql:rsql-parser:jar:2.1.0:compile com.vaadin:vaadin-themes:jar:7.7.13:compile
io.protostuff:protostuff-api:jar:1.5.6:compile com.zaxxer:HikariCP:jar:3.2.0:compile
io.protostuff:protostuff-collectionschema:jar:1.5.6:compile commons-io:commons-io:jar:2.5:compile
io.protostuff:protostuff-core:jar:1.5.6:compile cz.jirutka.rsql:rsql-parser:jar:2.1.0:compile
io.protostuff:protostuff-runtime:jar:1.5.6:compile io.projectreactor:reactor-core:jar:3.2.5.RELEASE:compile
javax.annotation:javax.annotation-api:jar:1.2:compile io.protostuff:protostuff-api:jar:1.5.6:compile
javax.servlet:javax.servlet-api:jar:3.1.0:compile io.protostuff:protostuff-collectionschema:jar:1.5.6:compile
javax.transaction:javax.transaction-api:jar:1.2:compile io.protostuff:protostuff-core:jar:1.5.6:compile
javax.validation:validation-api:jar:2.0.1.Final:compile io.protostuff:protostuff-runtime:jar:1.5.6:compile
javax.validation:validation-api:jar:sources:1.0.0.GA:compile javax.annotation:javax.annotation-api:jar:1.3.2:compile
javax.websocket:javax.websocket-api:jar:1.0:compile javax.json:javax.json-api:jar:1.1.4:compile
org.apache.commons:commons-lang3:jar:3.4:compile javax.servlet:javax.servlet-api:jar:4.0.1:compile
org.apache.httpcomponents:httpclient:jar:4.5.3:compile javax.transaction:javax.transaction-api:jar:1.3:compile
org.apache.httpcomponents:httpcore:jar:4.4.6:compile javax.validation:validation-api:jar:2.0.1.Final:compile
org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.28:compile javax.validation:validation-api:jar:sources:1.0.0.GA:compile
org.apache.tomcat:tomcat-jdbc:jar:8.0.28:compile javax.websocket:javax.websocket-api:jar:1.1:compile
org.apache.tomcat:tomcat-juli:jar:8.0.28:compile org.apache.commons:commons-lang3:jar:3.7:compile
org.aspectj:aspectjweaver:jar:1.8.10:compile org.apache.logging.log4j:log4j-api:jar:2.11.1:compile
org.flywaydb:flyway-core:jar:4.0.3:compile org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile
org.glassfish:javax.json:jar:1.0.4:compile org.flywaydb:flyway-core:jar:5.2.4:compile
org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile
org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
org.jsoup:jsoup:jar:1.8.3:compile org.jsoup:jsoup:jar:1.8.3:compile
org.mortbay.jasper:apache-el:jar:8.0.33:compile org.mortbay.jasper:apache-el:jar:8.5.35.1:compile
org.ow2.asm:asm-commons:jar:5.0.1:compile org.ow2.asm:asm-analysis:jar:7.0:compile
org.ow2.asm:asm-tree:jar:5.0.1:compile org.ow2.asm:asm-commons:jar:7.0:compile
org.ow2.asm:asm:jar:5.0.1:compile org.ow2.asm:asm-tree:jar:7.0:compile
org.slf4j:jcl-over-slf4j:jar:1.7.25:compile org.ow2.asm:asm:jar:7.0:compile
org.slf4j:jul-to-slf4j:jar:1.7.25:compile org.reactivestreams:reactive-streams:jar:1.0.2:compile
org.slf4j:log4j-over-slf4j:jar:1.7.25:compile org.slf4j:jul-to-slf4j:jar:1.7.25:compile
org.slf4j:slf4j-api:jar:1.7.25:compile org.slf4j:slf4j-api:jar:1.7.25:compile
org.springframework.amqp:spring-amqp:jar:1.7.6.RELEASE:compile org.springframework.amqp:spring-amqp:jar:2.1.3.RELEASE:compile
org.springframework.amqp:spring-rabbit:jar:1.7.6.RELEASE:compile org.springframework.amqp:spring-rabbit:jar:2.1.3.RELEASE:compile
org.springframework.boot:spring-boot-actuator:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-autoconfigure:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-aop:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-actuator:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-aop:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-jetty:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-json:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-jetty:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-logging:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-logging:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-validation:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-validation:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter-web:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter-web:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot-starter:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot-starter:jar:1.4.7.RELEASE:compile org.springframework.boot:spring-boot:jar:2.1.2.RELEASE:compile
org.springframework.boot:spring-boot:jar:1.4.7.RELEASE:compile org.springframework.cloud:spring-cloud-bus:jar:2.1.0.RELEASE:compile
org.springframework.cloud:spring-cloud-bus:jar:1.2.2.RELEASE:compile org.springframework.cloud:spring-cloud-commons:jar:2.1.0.RELEASE:compile
org.springframework.cloud:spring-cloud-context:jar:1.1.8.RELEASE:compile org.springframework.cloud:spring-cloud-context:jar:2.1.0.RELEASE:compile
org.springframework.cloud:spring-cloud-stream:jar:1.1.2.RELEASE:compile org.springframework.cloud:spring-cloud-starter:jar:2.1.0.RELEASE:compile
org.springframework.data:spring-data-commons:jar:1.12.11.RELEASE:compile org.springframework.cloud:spring-cloud-stream:jar:2.1.0.RELEASE:compile
org.springframework.data:spring-data-jpa:jar:1.10.11.RELEASE:compile org.springframework.data:spring-data-commons:jar:2.1.4.RELEASE:compile
org.springframework.hateoas:spring-hateoas:jar:0.23.0.RELEASE:compile org.springframework.data:spring-data-jpa:jar:2.1.4.RELEASE:compile
org.springframework.integration:spring-integration-core:jar:4.3.10.RELEASE:compile org.springframework.hateoas:spring-hateoas:jar:0.25.0.RELEASE:compile
org.springframework.integration:spring-integration-jmx:jar:4.3.10.RELEASE:compile org.springframework.integration:spring-integration-core:jar:5.1.2.RELEASE:compile
org.springframework.integration:spring-integration-tuple:jar:1.0.0.RELEASE:compile org.springframework.integration:spring-integration-jmx:jar:5.1.2.RELEASE:compile
org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile org.springframework.integration:spring-integration-tuple:jar:1.0.0.RELEASE:compile
org.springframework.retry:spring-retry:jar:1.1.5.RELEASE:compile org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
org.springframework.security:spring-security-aspects:jar:4.1.4.RELEASE:compile org.springframework.retry:spring-retry:jar:1.2.3.RELEASE:compile
org.springframework.security:spring-security-config:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-aspects:jar:5.1.3.RELEASE:compile
org.springframework.security:spring-security-core:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-config:jar:5.1.3.RELEASE:compile
org.springframework.security:spring-security-crypto:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-core:jar:5.1.3.RELEASE:compile
org.springframework.security:spring-security-web:jar:4.1.4.RELEASE:compile org.springframework.security:spring-security-crypto:jar:5.1.3.RELEASE:compile
org.springframework:spring-aop:jar:4.3.9.RELEASE:compile org.springframework.security:spring-security-web:jar:5.1.3.RELEASE:compile
org.springframework:spring-aspects:jar:4.3.9.RELEASE:compile org.springframework:spring-aop:jar:5.1.4.RELEASE:compile
org.springframework:spring-beans:jar:4.3.9.RELEASE:compile org.springframework:spring-aspects:jar:5.1.4.RELEASE:compile
org.springframework:spring-context-support:jar:4.3.9.RELEASE:compile org.springframework:spring-beans:jar:5.1.4.RELEASE:compile
org.springframework:spring-context:jar:4.3.9.RELEASE:compile org.springframework:spring-context-support:jar:5.1.4.RELEASE:compile
org.springframework:spring-core:jar:4.3.9.RELEASE:compile org.springframework:spring-context:jar:5.1.4.RELEASE:compile
org.springframework:spring-expression:jar:4.3.9.RELEASE:compile org.springframework:spring-core:jar:5.1.4.RELEASE:compile
org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile org.springframework:spring-expression:jar:5.1.4.RELEASE:compile
org.springframework:spring-messaging:jar:4.3.9.RELEASE:compile org.springframework:spring-jcl:jar:5.1.4.RELEASE:compile
org.springframework:spring-orm:jar:4.3.9.RELEASE:compile org.springframework:spring-jdbc:jar:5.1.4.RELEASE:compile
org.springframework:spring-tuple:jar:1.0.0.RELEASE:compile org.springframework:spring-messaging:jar:5.1.4.RELEASE:compile
org.springframework:spring-tx:jar:4.3.9.RELEASE:compile org.springframework:spring-orm:jar:5.1.4.RELEASE:compile
org.springframework:spring-web:jar:4.3.9.RELEASE:compile org.springframework:spring-tuple:jar:1.0.0.RELEASE:compile
org.springframework:spring-webmvc:jar:4.3.9.RELEASE:compile org.springframework:spring-tx:jar:5.1.4.RELEASE:compile
org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.6.1.3:compile org.springframework:spring-web:jar:5.1.4.RELEASE:compile
org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile org.springframework:spring-webmvc:jar:5.1.4.RELEASE:compile
org.vaadin.addons:tokenfield:jar:7.0.1:compile org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.6.1.3:compile
org.vaadin.alump.distributionbar:dbar-addon:jar:2.0.0:compile org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile
org.vaadin.spring.addons:vaadin-spring-addon-eventbus:jar:0.0.6.RELEASE:compile org.vaadin.addons:tokenfield:jar:7.0.1:compile
org.vaadin.spring.extensions:vaadin-spring-ext-core:jar:0.0.6.RELEASE:compile org.vaadin.alump.distributionbar:dbar-addon:jar:2.0.0:compile
org.vaadin.spring.extensions:vaadin-spring-ext-security:jar:0.0.6.RELEASE:compile org.vaadin.spring.addons:vaadin-spring-addon-eventbus:jar:0.0.6.RELEASE:compile
org.w3c.css:sac:jar:1.3:compile org.vaadin.spring.extensions:vaadin-spring-ext-core:jar:0.0.6.RELEASE:compile
org.vaadin.spring.extensions:vaadin-spring-ext-security:jar:0.0.6.RELEASE:compile
org.w3c.css:sac:jar:1.3:compile

View File

@@ -10,13 +10,13 @@
cd .. cd ..
# Provided and compile (excludes the test modules) # Provided and compile (excludes the test modules)
mvn dependency:list -DexcludeGroupIds=org.eclipse -pl !org.eclipse.hawkbit:hawkbit-repository-test,!org.eclipse.hawkbit:hawkbit-dmf-rabbitmq-test -Dsort=true -DoutputFile=dependencies.txt mvn dependency:list -DexcludeGroupIds=org.eclipse,org.aspectj -pl '!org.eclipse.hawkbit:hawkbit-repository-test,!org.eclipse.hawkbit:hawkbit-dmf-rabbitmq-test' -Dsort=true -DoutputFile=dependencies.txt
find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:compile'|sort|uniq > .3rd-party/compile.txt find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:compile'| tr -d '[:blank:]'| sed -e 's/(optional)//'|sort|uniq > .3rd-party/compile.txt
find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:provided'|sort|uniq > .3rd-party/provided.txt find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:provided'| tr -d '[:blank:]'| sed -e 's/(optional)//'|sort|uniq > .3rd-party/provided.txt
# Test dependencies # Test dependencies
mvn dependency:list -DexcludeGroupIds=org.eclipse -Dsort=true -DoutputFile=dependencies.txt mvn dependency:list -DexcludeGroupIds=org.eclipse -Dsort=true -DoutputFile=dependencies.txt
find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:test'|sort|uniq > .3rd-party/test.txt find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:test'| tr -d '[:blank:]'| sed -e 's/(optional)//'|sort|uniq > .3rd-party/test.txt
# Cleanup temp files # Cleanup temp files
find . -name dependencies.txt|while read i; do rm $i;done find . -name dependencies.txt|while read i; do rm $i;done

View File

@@ -1 +1 @@
javax.servlet:javax.servlet-api:jar:3.1.0:provided javax.servlet:javax.servlet-api:jar:4.0.1:provided

150
.3rd-party/test.txt vendored
View File

@@ -1,72 +1,78 @@
ant:ant:jar:1.6.5:test ant:ant:jar:1.6.5:test
asm:asm:jar:3.3.1:test colt:colt:jar:1.2.0:test
cglib:cglib-nodep:jar:3.1:test com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.8:test
colt:colt:jar:1.2.0:test com.google.code.gson:gson:jar:2.8.5:test
com.esotericsoftware:kryo-shaded:jar:3.0.3:test com.google.gwt.gwtmockito:gwtmockito:jar:1.1.8:test
com.esotericsoftware:minlog:jar:1.3.0:test com.google.gwt:gwt-dev:jar:2.8.0:test
com.google.code.gson:gson:jar:2.7:test com.google.gwt:gwt-user:jar:2.8.0:test
com.google.gwt.gwtmockito:gwtmockito:jar:1.1.8:test com.google.jsinterop:jsinterop-annotations:jar:1.0.1:test
com.google.gwt:gwt-dev:jar:2.8.0:test com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.1:test
com.google.gwt:gwt-user:jar:2.8.0:test com.ibm.icu:icu4j:jar:50.1.1:test
com.google.jsinterop:jsinterop-annotations:jar:1.0.1:test com.jayway.jsonpath:json-path:jar:2.4.0:test
com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.1:test com.rabbitmq:http-client:jar:2.1.0.RELEASE:test
com.ibm.icu:icu4j:jar:50.1.1:test com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
com.jayway.awaitility:awaitility:jar:1.7.0:test commons-codec:commons-codec:jar:1.11:test
com.jayway.jsonpath:json-path:jar:2.0.0:test commons-collections:commons-collections:jar:3.2.2:test
commons-collections:commons-collections:jar:3.2.2:test commons-net:commons-net:jar:3.6:test
javax.el:javax.el-api:jar:2.2.4:test io.qameta.allure:allure-java-commons:jar:2.7.0:test
junit:junit:jar:4.12:test io.qameta.allure:allure-junit4:jar:2.7.0:test
net._01001111:jlorem:jar:1.1:test io.qameta.allure:allure2-model-api:jar:1.0.0:test
net.minidev:asm:jar:1.0.2:test io.qameta.allure:allure2-model-jackson:jar:1.0.0:test
net.minidev:json-smart:jar:2.1.1:test io.qameta.allure:allure2-model-pojo:jar:1.0.0:test
net.sourceforge.cssparser:cssparser:jar:0.9.18:test javax.el:javax.el-api:jar:2.2.4:test
net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:test junit:junit:jar:4.12:test
net.sourceforge.htmlunit:htmlunit:jar:2.21:test net._01001111:jlorem:jar:1.1:test
net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:test net.bytebuddy:byte-buddy-agent:jar:1.9.7:test
org.apache.httpcomponents:httpmime:jar:4.5.3:test net.bytebuddy:byte-buddy:jar:1.9.7:test
org.apache.tika:tika-core:jar:1.7:test net.minidev:accessors-smart:jar:1.2:test
org.aspectj:aspectjrt:jar:1.8.10:test net.minidev:json-smart:jar:2.3:test
org.assertj:assertj-core:jar:3.6.2:test net.sourceforge.htmlunit:htmlunit-core-js:jar:2.33:test
org.hamcrest:hamcrest-all:jar:1.3:test net.sourceforge.htmlunit:htmlunit-cssparser:jar:1.2.0:test
org.hamcrest:hamcrest-core:jar:1.3:test net.sourceforge.htmlunit:htmlunit:jar:2.33:test
org.hamcrest:hamcrest-library:jar:1.3:test net.sourceforge.htmlunit:neko-htmlunit:jar:2.33:test
org.javassist:javassist:jar:3.20.0-GA:test org.apache.commons:commons-text:jar:1.4:test
org.json:json:jar:20141113:test org.apache.httpcomponents:httpclient:jar:4.5.6:test
org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.9.3:test org.apache.httpcomponents:httpcore:jar:4.4.10:test
org.mariadb.jdbc:mariadb-java-client:jar:2.0.2:test org.apache.httpcomponents:httpmime:jar:4.5.6:test
org.mockito:mockito-core:jar:1.10.19:test org.apache.tika:tika-core:jar:1.14:test
org.mortbay.jasper:apache-jsp:jar:8.0.33:test org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.14:test
org.objenesis:objenesis:jar:2.1:test org.aspectj:aspectjrt:jar:1.9.2:test
org.ow2.asm:asm-commons:jar:5.0.3:test org.aspectj:aspectjweaver:jar:1.9.2:test
org.ow2.asm:asm-tree:jar:5.0.3:test org.assertj:assertj-core:jar:3.11.1:test
org.ow2.asm:asm-util:jar:5.0.3:test org.awaitility:awaitility:jar:3.1.2:test
org.ow2.asm:asm:jar:5.0.3:test org.hamcrest:hamcrest-all:jar:1.3:test
org.powermock:powermock-api-mockito-common:jar:1.6.5:test org.hamcrest:hamcrest-core:jar:1.3:test
org.powermock:powermock-api-mockito:jar:1.6.5:test org.hamcrest:hamcrest-library:jar:1.3:test
org.powermock:powermock-api-support:jar:1.6.5:test org.javassist:javassist:jar:3.22.0-GA:test
org.powermock:powermock-core:jar:1.6.5:test org.jooq:joor-java-8:jar:0.9.9:test
org.powermock:powermock-module-junit4-common:jar:1.6.5:test org.mariadb.jdbc:mariadb-java-client:jar:2.3.0:test
org.powermock:powermock-module-junit4:jar:1.6.5:test org.mockito:mockito-core:jar:2.23.4:test
org.powermock:powermock-reflect:jar:1.6.5:test org.mortbay.jasper:apache-jsp:jar:8.5.33.1:test
org.skyscreamer:jsonassert:jar:1.3.0:test org.objenesis:objenesis:jar:2.6:test
org.springframework.amqp:spring-rabbit-junit:jar:1.7.6.RELEASE:test org.ow2.asm:asm-commons:jar:5.0.3:test
org.springframework.amqp:spring-rabbit-test:jar:1.7.6.RELEASE:test org.ow2.asm:asm-tree:jar:5.0.3:test
org.springframework.boot:spring-boot-starter-test:jar:1.4.7.RELEASE:test org.ow2.asm:asm-util:jar:5.0.3:test
org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.7.RELEASE:test org.ow2.asm:asm:jar:5.0.3:test
org.springframework.boot:spring-boot-test:jar:1.4.7.RELEASE:test org.ow2.asm:asm:jar:5.0.4:test
org.springframework.cloud:spring-cloud-stream-binder-test:jar:1.1.2.RELEASE:test org.skyscreamer:jsonassert:jar:1.5.0:test
org.springframework.cloud:spring-cloud-stream-test-support:jar:1.1.2.RELEASE:test org.springframework.amqp:spring-rabbit-junit:jar:2.1.3.RELEASE:test
org.springframework.integration:spring-integration-test:jar:4.3.10.RELEASE:test org.springframework.amqp:spring-rabbit-test:jar:2.1.3.RELEASE:test
org.springframework:spring-test:jar:4.3.9.RELEASE:test org.springframework.boot:spring-boot-starter-test:jar:2.1.2.RELEASE:test
org.yaml:snakeyaml:jar:1.17:test org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.2.RELEASE:test
ru.qatools.commons:properties:jar:2.0.RC5:test org.springframework.boot:spring-boot-test:jar:2.1.2.RELEASE:test
ru.yandex.qatools.allure:allure-java-adaptor-api:jar:1.5.4:test org.springframework.cloud:spring-cloud-function-context:jar:2.0.0.RELEASE:test
ru.yandex.qatools.allure:allure-java-annotations:jar:1.5.4:test org.springframework.cloud:spring-cloud-function-core:jar:2.0.0.RELEASE:test
ru.yandex.qatools.allure:allure-java-aspects:jar:1.5.4:test org.springframework.cloud:spring-cloud-stream-binder-test:jar:2.1.0.RELEASE:test
ru.yandex.qatools.allure:allure-junit-adaptor:jar:1.5.4:test org.springframework.cloud:spring-cloud-stream-test-support:jar:2.1.0.RELEASE:test
ru.yandex.qatools.allure:allure-model:jar:1.5.4:test org.springframework.integration:spring-integration-test-support:jar:5.1.2.RELEASE:test
tapestry:tapestry:jar:4.0.2:test org.springframework.integration:spring-integration-test:jar:5.1.2.RELEASE:test
xalan:serializer:jar:2.7.2:test org.springframework.restdocs:spring-restdocs-core:jar:2.0.3.RELEASE:test
xalan:xalan:jar:2.7.2:test org.springframework.restdocs:spring-restdocs-mockmvc:jar:2.0.3.RELEASE:test
xerces:xercesImpl:jar:2.11.0:test org.springframework:spring-test:jar:5.1.4.RELEASE:test
xml-apis:xml-apis:jar:1.4.01:test org.xmlunit:xmlunit-core:jar:2.6.2:test
org.yaml:snakeyaml:jar:1.23:test
tapestry:tapestry:jar:4.0.2:test
xalan:serializer:jar:2.7.2:test
xalan:xalan:jar:2.7.2:test
xerces:xercesImpl:jar:2.12.0:test
xml-apis:xml-apis:jar:1.4.01:test

View File

@@ -56,4 +56,4 @@ jobs:
notify: notify:
webhooks: webhooks:
# Gitter hook # Gitter hook
- url: https://webhooks.gitter.im/e/a20a6bc2bda5a8a77d39 - url: https://webhooks.gitter.im/e/a20a6bc2bda5a8a77d39

View File

@@ -33,6 +33,7 @@ We offer a sandbox installation that is free for everyone to try out hawkBit. Ho
In addition the following vendors offer free trial accounts for their hawkBit compatible products: In addition the following vendors offer free trial accounts for their hawkBit compatible products:
- [Bosch IoT Rollouts](https://www.bosch-iot-suite.com/rollouts/) - [Bosch IoT Rollouts](https://www.bosch-iot-suite.com/rollouts/)
- [Kynetics Update Factory](https://www.kynetics.com/iot-platform-update-factory)
# Device Integration # Device Integration

View File

@@ -5,24 +5,26 @@ weight: 31
--- ---
In this guide we describe how to run a full featured hawkBit setup based on a production ready infrastructure. It is based on the hawkBit example modules and update server. In this guide we describe how to run a full featured hawkBit setup based on a production ready infrastructure. It is based on the hawkBit example modules and update server.
<!--more-->
<!--more-->
{{% note %}} {{% note %}}
The update server can in fact be run stand alone. However, only with an embedded H2, no Device Management Federation API and no artifact storage. The update server can in fact be run stand alone. However, only with an embedded H2, no Device Management Federation API and no artifact storage.
{{% /note %}} {{% /note %}}
## System Architecture ## System Architecture
This guide describes a target architecture that is more like one that you will expect in a production system. This guide describes a target architecture that is more like one that you will expect in a production system.
- hawkBit [Update Server](https://github.com/eclipse/hawkbit/tree/master/hawkbit-runtime/hawkbit-update-server). - hawkBit [Update Server](https://github.com/eclipse/hawkbit/tree/master/hawkbit-runtime/hawkbit-update-server).
- [MariaDB](https://mariadb.org) for the repository. - [MariaDB](https://mariadb.org) for the repository.
- [RabbitMQ](https://www.rabbitmq.com) for DMF communication. - [RabbitMQ](https://www.rabbitmq.com) for DMF communication.
- For testing and demonstration purposes we will also use: - For testing and demonstration purposes we will also use:
- [hawkBit Device Simulator](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-device-simulator). - [hawkBit Device Simulator](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-device-simulator).
- [hawkBit Management API example client](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-mgmt-api-client). - [hawkBit Management API example client](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-mgmt-api-client).
## Prerequisites ## Prerequisites
- You have a working [hawkBit core build](https://github.com/eclipse/hawkbit). - You have a working [hawkBit core build](https://github.com/eclipse/hawkbit).
- You have a working [hawkBit examples build](https://github.com/eclipse/hawkbit-examples). - You have a working [hawkBit examples build](https://github.com/eclipse/hawkbit-examples).
@@ -31,18 +33,20 @@ This guide describes a target architecture that is more like one that you will e
As mentioned you can create your own application with hawkBit inside or adapt the existing example app. The second option will be shown here. As mentioned you can create your own application with hawkBit inside or adapt the existing example app. The second option will be shown here.
### Set MariaDB dependency to compile in the [update server POM](https://github.com/eclipse/hawkbit/blob/master/hawkbit-runtime/hawkbit-update-server/pom.xml) ### Set MariaDB dependency to compile in the [update server POM](https://github.com/eclipse/hawkbit/blob/master/hawkbit-runtime/hawkbit-update-server/pom.xml)
```xml ```xml
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
``` ```
### Configure MariaDB/MySQL connection settings. ### Configure MariaDB/MySQL connection settings.
For this you can either edit the existing *application.properties* or create a [new profile](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-profile-specific-properties). For this you can either edit the existing _application.properties_ or create a [new profile](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-profile-specific-properties).
``` ```properties
spring.jpa.database=MYSQL spring.jpa.database=MYSQL
spring.datasource.url=jdbc:mysql://localhost:3306/YOUR_SCHEMA spring.datasource.url=jdbc:mysql://localhost:3306/YOUR_SCHEMA
spring.datasource.username=YOUR_USER spring.datasource.username=YOUR_USER
@@ -54,7 +58,7 @@ spring.datasource.driverClassName=org.mariadb.jdbc.Driver
We provide already defaults that should work with a standard Rabbit installation. Otherwise configure the following in the `application.properties` of the two services: We provide already defaults that should work with a standard Rabbit installation. Otherwise configure the following in the `application.properties` of the two services:
``` ```properties
spring.rabbitmq.username=guest spring.rabbitmq.username=guest
spring.rabbitmq.password=guest spring.rabbitmq.password=guest
spring.rabbitmq.virtualHost=/ spring.rabbitmq.virtualHost=/
@@ -67,30 +71,33 @@ spring.rabbitmq.port=5672
Should only be necessary if your system does not run on localhost or uses a different port than the example app. Should only be necessary if your system does not run on localhost or uses a different port than the example app.
Adapt `application.properties` in this case: Adapt `application.properties` in this case:
```
```properties
hawkbit.url=localhost:8080 hawkbit.url=localhost:8080
``` ```
or provide the parameter on command line: or provide the parameter on command line:
```
```properties
hawkbit-example-mgmt-simulator-##VERSION##.jar --hawkbit.url=YOUR_HOST:PORT hawkbit-example-mgmt-simulator-##VERSION##.jar --hawkbit.url=YOUR_HOST:PORT
``` ```
## Compile & Run ## Compile & Run
### Compile & Run your _"production ready"_ app. ### Compile & Run your _"production ready"_ app
see [update server](https://github.com/eclipse/hawkbit/tree/master/hawkbit-runtime/hawkbit-update-server) see [update server](https://github.com/eclipse/hawkbit/tree/master/hawkbit-runtime/hawkbit-update-server)
### Compile & Run example scenario [creation script](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-example-mgmt-simulator) (optional). ### Compile & Run example scenario [creation script](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-example-mgmt-simulator) (optional)
This has to be done before the device simulator is started. hawkBit creates the mandatory tenant metadata with first login into either _Management UI_ or API (which is done by this client). This has to be done before the device simulator is started. hawkBit creates the mandatory tenant metadata with first login into either _Management UI_ or API (which is done by this client).
However, this is not done by _DMF_ which is in fact used by the device simulator, i.e. without calling _Management API_ first hawkBit would drop all _DMF_ messages as the tenant is unknown. However, this is not done by _DMF_ which is in fact used by the device simulator, i.e. without calling _Management API_ first hawkBit would drop all _DMF_ messages as the tenant is unknown.
### Compile & Run device simulator (optional). ### Compile & Run device simulator (optional)
see [device simulator](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-device-simulator) see [device simulator](https://github.com/eclipse/hawkbit-examples/tree/master/hawkbit-device-simulator)
# Enjoy hawkBit with a real database, artifact storage and all [interfaces](../../apis/) available. # Enjoy hawkBit with a real database, artifact storage and all [interfaces](../../apis/) available
![](../../images/hawkbit_ui.png) ![](../../images/hawkbit_ui.png)

View File

@@ -11,13 +11,21 @@ package org.eclipse.hawkbit.artifact.repository;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.io.Files;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
@@ -26,12 +34,32 @@ import io.qameta.allure.Story;
@Feature("Unit Tests - Artifact File System Repository") @Feature("Unit Tests - Artifact File System Repository")
@Story("Test storing artifact binaries in the file-system") @Story("Test storing artifact binaries in the file-system")
public class ArtifactFilesystemRepositoryTest { public class ArtifactFilesystemRepositoryTest {
private static final Logger LOG = LoggerFactory.getLogger(ArtifactFilesystemRepositoryTest.class);
private static final String TENANT = "test_tenant"; private static final String TENANT = "test_tenant";
private final ArtifactFilesystemProperties artifactResourceProperties = new ArtifactFilesystemProperties(); private static ArtifactFilesystemProperties artifactResourceProperties;
private final ArtifactFilesystemRepository artifactFilesystemRepository = new ArtifactFilesystemRepository( private static ArtifactFilesystemRepository artifactFilesystemRepository;
artifactResourceProperties);
@BeforeClass
public static void setup() {
artifactResourceProperties = new ArtifactFilesystemProperties();
artifactResourceProperties.setPath(Files.createTempDir().getAbsolutePath());
artifactFilesystemRepository = new ArtifactFilesystemRepository(artifactResourceProperties);
}
@AfterClass
public static void afterClass() {
if (new File(artifactResourceProperties.getPath()).exists()) {
try {
FileUtils.deleteDirectory(new File(artifactResourceProperties.getPath()));
} catch (final IOException | IllegalArgumentException e) {
LOG.warn("Cannot delete file-directory", e);
}
}
}
@Test @Test
@Description("Verfies that an artifact can be successfully stored in the file-system repository") @Description("Verfies that an artifact can be successfully stored in the file-system repository")

View File

@@ -41,7 +41,7 @@ public class PropertyHostnameResolverAutoConfiguration {
*/ */
@Bean @Bean
@ConditionalOnMissingBean(value = HostnameResolver.class) @ConditionalOnMissingBean(value = HostnameResolver.class)
public HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) { HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) {
return () -> { return () -> {
try { try {
return new URL(serverProperties.getUrl()); return new URL(serverProperties.getUrl());
@@ -58,7 +58,7 @@ public class PropertyHostnameResolverAutoConfiguration {
*/ */
@Bean @Bean
@ConditionalOnMissingBean(ArtifactUrlHandler.class) @ConditionalOnMissingBean(ArtifactUrlHandler.class)
public PropertyBasedArtifactUrlHandler propertyBasedArtifactUrlHandler( PropertyBasedArtifactUrlHandler propertyBasedArtifactUrlHandler(
final ArtifactUrlHandlerProperties urlHandlerProperties) { final ArtifactUrlHandlerProperties urlHandlerProperties) {
return new PropertyBasedArtifactUrlHandler(urlHandlerProperties); return new PropertyBasedArtifactUrlHandler(urlHandlerProperties);
} }

View File

@@ -8,28 +8,20 @@
*/ */
package org.eclipse.hawkbit.autoconfigure.cache; package org.eclipse.hawkbit.autoconfigure.cache;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.cache.TenancyCacheManager; import org.eclipse.hawkbit.cache.TenancyCacheManager;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager; import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.guava.GuavaCacheManager; import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.cache.interceptor.CacheOperationInvocationContext;
import org.springframework.cache.interceptor.SimpleCacheResolver;
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.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import com.google.common.cache.CacheBuilder; import com.github.benmanes.caffeine.cache.Caffeine;
/** /**
* A configuration for configuring the spring {@link CacheManager} for specific * A configuration for configuring the spring {@link CacheManager} for specific
@@ -43,13 +35,6 @@ import com.google.common.cache.CacheBuilder;
@EnableCaching @EnableCaching
public class CacheAutoConfiguration { public class CacheAutoConfiguration {
@Autowired
private TenantAware tenantAware;
@Autowired
@Qualifier("directCacheManager")
private CacheManager directCacheManager;
/** /**
* @return the default cache manager bean if none other cache manager is * @return the default cache manager bean if none other cache manager is
* existing. * existing.
@@ -57,7 +42,8 @@ public class CacheAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@Primary @Primary
public TenancyCacheManager cacheManager() { TenancyCacheManager cacheManager(@Qualifier("directCacheManager") final CacheManager directCacheManager,
final TenantAware tenantAware) {
return new TenantAwareCacheManager(directCacheManager, tenantAware); return new TenantAwareCacheManager(directCacheManager, tenantAware);
} }
@@ -70,9 +56,6 @@ public class CacheAutoConfiguration {
@EnableConfigurationProperties(CacheProperties.class) @EnableConfigurationProperties(CacheProperties.class)
static class DirectCacheManagerConfiguration { static class DirectCacheManagerConfiguration {
@Autowired
private CacheProperties cacheProperties;
/** /**
* @return the direct cache manager to access without tenant aware * @return the direct cache manager to access without tenant aware
* check, cause in sometimes it's necessary to access the cache * check, cause in sometimes it's necessary to access the cache
@@ -81,143 +64,17 @@ public class CacheAutoConfiguration {
*/ */
@Bean(name = "directCacheManager") @Bean(name = "directCacheManager")
@ConditionalOnMissingBean(name = "directCacheManager") @ConditionalOnMissingBean(name = "directCacheManager")
public CacheManager directCacheManager() { public CacheManager directCacheManager(final CacheProperties cacheProperties) {
final GuavaCacheManager cacheManager = new GuavaCacheManager(); final CaffeineCacheManager cacheManager = new CaffeineCacheManager();
if (cacheProperties.getTtl() > 0) { if (cacheProperties.getTtl() > 0) {
final CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder() final Caffeine<Object, Object> cacheBuilder = Caffeine.newBuilder()
.expireAfterWrite(cacheProperties.getTtl(), cacheProperties.getTtlUnit()); .expireAfterWrite(cacheProperties.getTtl(), cacheProperties.getTtlUnit());
cacheManager.setCacheBuilder(cacheBuilder); cacheManager.setCaffeine(cacheBuilder);
} }
return cacheManager; return cacheManager;
} }
} }
/**
* A {@link SimpleCacheResolver} implementation which includes the
* {@link TenantAware#getCurrentTenant()} into the cache name before
* resolving it.
*/
public class TenantCacheResolver extends SimpleCacheResolver {
@Override
public Collection<Cache> resolveCaches(final CacheOperationInvocationContext<?> context) {
return super.resolveCaches(context).stream().map(TenantCacheWrapper::new).collect(Collectors.toList());
}
@Override
protected Collection<String> getCacheNames(final CacheOperationInvocationContext<?> context) {
return super.getCacheNames(context).stream()
.map(cacheName -> tenantAware.getCurrentTenant() + "." + cacheName).collect(Collectors.toList());
}
}
/**
* An {@link Cache} wrapper which returns the name of the cache include the
* {@link TenantAware#getCurrentTenant()}.
*
*
*
*
*/
public class TenantCacheWrapper implements Cache {
private final Cache delegate;
/**
* @param delegate
*/
public TenantCacheWrapper(final Cache delegate) {
this.delegate = delegate;
}
/**
* @return
* @see org.springframework.cache.Cache#getName()
*/
@Override
public String getName() {
return tenantAware.getCurrentTenant() + "." + delegate.getName();
}
/**
* @return
* @see org.springframework.cache.Cache#getNativeCache()
*/
@Override
public Object getNativeCache() {
return delegate.getNativeCache();
}
/**
* @param key
* @return
* @see org.springframework.cache.Cache#get(java.lang.Object)
*/
@Override
public ValueWrapper get(final Object key) {
return delegate.get(key);
}
/**
* @param key
* @param type
* @return
* @see org.springframework.cache.Cache#get(java.lang.Object,
* java.lang.Class)
*/
@Override
public <T> T get(final Object key, final Class<T> type) {
return delegate.get(key, type);
}
/**
* @param key
* @param value
* @see org.springframework.cache.Cache#put(java.lang.Object,
* java.lang.Object)
*/
@Override
public void put(final Object key, final Object value) {
delegate.put(key, value);
}
/**
* @param key
* @param value
* @return
* @see org.springframework.cache.Cache#putIfAbsent(java.lang.Object,
* java.lang.Object)
*/
@Override
public ValueWrapper putIfAbsent(final Object key, final Object value) {
return delegate.putIfAbsent(key, value);
}
/**
* @param key
* @see org.springframework.cache.Cache#evict(java.lang.Object)
*/
@Override
public void evict(final Object key) {
delegate.evict(key);
}
/**
*
* @see org.springframework.cache.Cache#clear()
*/
@Override
public void clear() {
delegate.clear();
}
@Override
public <T> T get(final Object key, final Callable<T> valueLoader) {
return delegate.get(key, valueLoader);
}
}
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.autoconfigure.cache;
import org.eclipse.hawkbit.cache.DefaultDownloadIdCache; import org.eclipse.hawkbit.cache.DefaultDownloadIdCache;
import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.cache.DownloadIdCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -24,9 +23,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class DownloadIdCacheAutoConfiguration { public class DownloadIdCacheAutoConfiguration {
@Autowired
private CacheManager cacheManager;
/** /**
* Bean for the downloadId cache that returns the DefaultDownloadIdCache. * Bean for the downloadId cache that returns the DefaultDownloadIdCache.
* The DefaultDownloadIdCache cannot be used within a cluster because the * The DefaultDownloadIdCache cannot be used within a cluster because the
@@ -38,7 +34,7 @@ public class DownloadIdCacheAutoConfiguration {
*/ */
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public DownloadIdCache downloadIdCache() { public DownloadIdCache downloadIdCache(final CacheManager cacheManager) {
return new DefaultDownloadIdCache(cacheManager); return new DefaultDownloadIdCache(cacheManager);
} }

View File

@@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.cloud.bus.ConditionalOnBusEnabled; import org.springframework.cloud.bus.ConditionalOnBusEnabled;
import org.springframework.cloud.bus.ServiceMatcher; import org.springframework.cloud.bus.ServiceMatcher;
import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan; import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan;
import org.springframework.cloud.stream.annotation.StreamMessageConverter;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -43,14 +44,6 @@ import io.protostuff.Schema;
@RemoteApplicationEventScan(basePackages = "org.eclipse.hawkbit.repository.event.remote") @RemoteApplicationEventScan(basePackages = "org.eclipse.hawkbit.repository.event.remote")
@PropertySource("classpath:/hawkbit-eventbus-defaults.properties") @PropertySource("classpath:/hawkbit-eventbus-defaults.properties")
public class EventPublisherAutoConfiguration { public class EventPublisherAutoConfiguration {
@Autowired
@Qualifier("asyncExecutor")
private Executor executor;
@Autowired
private TenantAware tenantAware;
/** /**
* Server internal event publisher that allows parallel event processing if * Server internal event publisher that allows parallel event processing if
* the event listener is marked as so. * the event listener is marked as so.
@@ -58,7 +51,8 @@ public class EventPublisherAutoConfiguration {
* @return publisher bean * @return publisher bean
*/ */
@Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME) @Bean(name = AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME)
public ApplicationEventMulticaster applicationEventMulticaster() { ApplicationEventMulticaster applicationEventMulticaster(@Qualifier("asyncExecutor") final Executor executor,
final TenantAware tenantAware) {
final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher( final SimpleApplicationEventMulticaster simpleApplicationEventMulticaster = new TenantAwareApplicationEventPublisher(
tenantAware, applicationEventFilter()); tenantAware, applicationEventFilter());
simpleApplicationEventMulticaster.setTaskExecutor(executor); simpleApplicationEventMulticaster.setTaskExecutor(executor);
@@ -72,7 +66,7 @@ public class EventPublisherAutoConfiguration {
* @return the singleton instance of the {@link EventPublisherHolder} * @return the singleton instance of the {@link EventPublisherHolder}
*/ */
@Bean @Bean
public EventPublisherHolder eventBusHolder() { EventPublisherHolder eventBusHolder() {
return EventPublisherHolder.getInstance(); return EventPublisherHolder.getInstance();
} }
@@ -82,7 +76,7 @@ public class EventPublisherAutoConfiguration {
*/ */
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ApplicationEventFilter applicationEventFilter() { ApplicationEventFilter applicationEventFilter() {
return e -> false; return e -> false;
} }
@@ -144,6 +138,7 @@ public class EventPublisherAutoConfiguration {
* @return the protostuff io message converter * @return the protostuff io message converter
*/ */
@Bean @Bean
@StreamMessageConverter
public MessageConverter busProtoBufConverter() { public MessageConverter busProtoBufConverter() {
return new BusProtoStuffMessageConverter(); return new BusProtoStuffMessageConverter();
} }

View File

@@ -14,7 +14,6 @@ import org.eclipse.hawkbit.im.authentication.MultitenancyIndicator;
import org.eclipse.hawkbit.im.authentication.PermissionUtils; import org.eclipse.hawkbit.im.authentication.PermissionUtils;
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
import org.eclipse.hawkbit.im.authentication.UserPrincipal; import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -22,7 +21,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter; import org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
@@ -37,8 +36,11 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@ConditionalOnMissingBean(UserDetailsService.class) @ConditionalOnMissingBean(UserDetailsService.class)
public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticationConfigurerAdapter { public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticationConfigurerAdapter {
@Autowired private final SecurityProperties securityProperties;
private SecurityProperties securityProperties;
InMemoryUserManagementAutoConfiguration(final SecurityProperties securityProperties) {
this.securityProperties = securityProperties;
}
@Override @Override
public void configure(final AuthenticationManagerBuilder auth) throws Exception { public void configure(final AuthenticationManagerBuilder auth) throws Exception {
@@ -52,7 +54,7 @@ public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticatio
*/ */
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public UserDetailsService userDetailsService() { UserDetailsService userDetailsService() {
final InMemoryUserDetailsManager inMemoryUserDetailsManager = new InMemoryUserPrincipalDetailsManager(); final InMemoryUserDetailsManager inMemoryUserDetailsManager = new InMemoryUserPrincipalDetailsManager();
inMemoryUserDetailsManager.setAuthenticationManager(null); inMemoryUserDetailsManager.setAuthenticationManager(null);
inMemoryUserDetailsManager.createUser(new User(securityProperties.getUser().getName(), inMemoryUserDetailsManager.createUser(new User(securityProperties.getUser().getName(),
@@ -65,7 +67,7 @@ public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticatio
*/ */
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public MultitenancyIndicator multiTenancyIndicator() { MultitenancyIndicator multiTenancyIndicator() {
return () -> false; return () -> false;
} }

View File

@@ -52,7 +52,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean; import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.AdviceMode;
@@ -108,9 +107,6 @@ public class SecurityManagedConfiguration {
private static final int DOS_FILTER_ORDER = -200; private static final int DOS_FILTER_ORDER = -200;
@Autowired
private AuthenticationConfiguration configuration;
/** /**
* @return the {@link UserAuthenticationFilter} to include into the hawkBit * @return the {@link UserAuthenticationFilter} to include into the hawkBit
* security configuration. * security configuration.
@@ -122,7 +118,8 @@ public class SecurityManagedConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
// Exception squid:S00112 - Is aspectJ proxy // Exception squid:S00112 - Is aspectJ proxy
@SuppressWarnings({ "squid:S00112" }) @SuppressWarnings({ "squid:S00112" })
public UserAuthenticationFilter userAuthenticationFilter() throws Exception { UserAuthenticationFilter userAuthenticationFilter(final AuthenticationConfiguration configuration)
throws Exception {
return new UserAuthenticationFilterBasicAuth(configuration.getAuthenticationManager()); return new UserAuthenticationFilterBasicAuth(configuration.getAuthenticationManager());
} }
@@ -154,19 +151,19 @@ public class SecurityManagedConfiguration {
private final TenantConfigurationManagement tenantConfigurationManagement; private final TenantConfigurationManagement tenantConfigurationManagement;
private final TenantAware tenantAware; private final TenantAware tenantAware;
private final DdiSecurityProperties ddiSecurityConfiguration; private final DdiSecurityProperties ddiSecurityConfiguration;
private final SecurityProperties springSecurityProperties; private final HawkbitSecurityProperties securityProperties;
private final SystemSecurityContext systemSecurityContext; private final SystemSecurityContext systemSecurityContext;
@Autowired @Autowired
ControllerSecurityConfigurationAdapter(final ControllerManagement controllerManagement, ControllerSecurityConfigurationAdapter(final ControllerManagement controllerManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware, final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
final DdiSecurityProperties ddiSecurityConfiguration, final SecurityProperties springSecurityProperties, final DdiSecurityProperties ddiSecurityConfiguration,
final SystemSecurityContext systemSecurityContext) { final HawkbitSecurityProperties securityProperties, final SystemSecurityContext systemSecurityContext) {
this.controllerManagement = controllerManagement; this.controllerManagement = controllerManagement;
this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantConfigurationManagement = tenantConfigurationManagement;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.ddiSecurityConfiguration = ddiSecurityConfiguration; this.ddiSecurityConfiguration = ddiSecurityConfiguration;
this.springSecurityProperties = springSecurityProperties; this.securityProperties = securityProperties;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;
} }
@@ -219,7 +216,7 @@ public class SecurityManagedConfiguration {
HttpSecurity httpSec = http.csrf().disable(); HttpSecurity httpSec = http.csrf().disable();
if (springSecurityProperties.isRequireSsl()) { if (securityProperties.isRequireSsl()) {
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
} }
@@ -270,19 +267,19 @@ public class SecurityManagedConfiguration {
private final TenantConfigurationManagement tenantConfigurationManagement; private final TenantConfigurationManagement tenantConfigurationManagement;
private final TenantAware tenantAware; private final TenantAware tenantAware;
private final DdiSecurityProperties ddiSecurityConfiguration; private final DdiSecurityProperties ddiSecurityConfiguration;
private final SecurityProperties springSecurityProperties; private final HawkbitSecurityProperties securityProperties;
private final SystemSecurityContext systemSecurityContext; private final SystemSecurityContext systemSecurityContext;
@Autowired @Autowired
ControllerDownloadSecurityConfigurationAdapter(final ControllerManagement controllerManagement, ControllerDownloadSecurityConfigurationAdapter(final ControllerManagement controllerManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware, final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware,
final DdiSecurityProperties ddiSecurityConfiguration, final SecurityProperties springSecurityProperties, final DdiSecurityProperties ddiSecurityConfiguration,
final SystemSecurityContext systemSecurityContext) { final HawkbitSecurityProperties securityProperties, final SystemSecurityContext systemSecurityContext) {
this.controllerManagement = controllerManagement; this.controllerManagement = controllerManagement;
this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantConfigurationManagement = tenantConfigurationManagement;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.ddiSecurityConfiguration = ddiSecurityConfiguration; this.ddiSecurityConfiguration = ddiSecurityConfiguration;
this.springSecurityProperties = springSecurityProperties; this.securityProperties = securityProperties;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;
} }
@@ -341,7 +338,7 @@ public class SecurityManagedConfiguration {
HttpSecurity httpSec = http.csrf().disable(); HttpSecurity httpSec = http.csrf().disable();
if (springSecurityProperties.isRequireSsl()) { if (securityProperties.isRequireSsl()) {
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
} }
@@ -465,7 +462,7 @@ public class SecurityManagedConfiguration {
private SystemManagement systemManagement; private SystemManagement systemManagement;
@Autowired @Autowired
private SecurityProperties springSecurityProperties; private HawkbitSecurityProperties securityProperties;
@Autowired @Autowired
private SystemSecurityContext systemSecurityContext; private SystemSecurityContext systemSecurityContext;
@@ -497,10 +494,10 @@ public class SecurityManagedConfiguration {
protected void configure(final HttpSecurity http) throws Exception { protected void configure(final HttpSecurity http) throws Exception {
final BasicAuthenticationEntryPoint basicAuthEntryPoint = new BasicAuthenticationEntryPoint(); final BasicAuthenticationEntryPoint basicAuthEntryPoint = new BasicAuthenticationEntryPoint();
basicAuthEntryPoint.setRealmName(springSecurityProperties.getBasic().getRealm()); basicAuthEntryPoint.setRealmName(securityProperties.getBasicRealm());
HttpSecurity httpSec = http.regexMatcher("\\/rest.*|\\/system/admin.*").csrf().disable(); HttpSecurity httpSec = http.regexMatcher("\\/rest.*|\\/system/admin.*").csrf().disable();
if (springSecurityProperties.isRequireSsl()) { if (securityProperties.isRequireSsl()) {
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
} }
@@ -545,9 +542,6 @@ public class SecurityManagedConfiguration {
@Autowired @Autowired
private VaadinSecurityContext vaadinSecurityContext; private VaadinSecurityContext vaadinSecurityContext;
@Autowired
private SecurityProperties springSecurityProperties;
@Autowired @Autowired
private HawkbitSecurityProperties hawkbitSecurityProperties; private HawkbitSecurityProperties hawkbitSecurityProperties;
@@ -635,7 +629,7 @@ public class SecurityManagedConfiguration {
// disable as CSRF is handled by Vaadin // disable as CSRF is handled by Vaadin
.csrf().disable(); .csrf().disable();
if (springSecurityProperties.isRequireSsl()) { if (hawkbitSecurityProperties.isRequireSsl()) {
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
} else { } else {

View File

@@ -7,12 +7,9 @@
# http://www.eclipse.org/legal/epl-v10.html # http://www.eclipse.org/legal/epl-v10.html
# #
# Displayed basic auth realm
security.basic.realm=HawkBit
# User Security # User Security
security.user.name=admin spring.security.user.name=admin
security.user.password=admin spring.security.user.password={noop}admin
# DDI and download security # DDI and download security
hawkbit.server.ddi.security.authentication.header.enabled=false hawkbit.server.ddi.security.authentication.header.enabled=false

View File

@@ -10,10 +10,6 @@ package org.eclipse.hawkbit.tenancy;
/** /**
* Interface for components that are aware of the application's current tenant. * Interface for components that are aware of the application's current tenant.
*
*
*
*
*/ */
public interface TenantAware { public interface TenantAware {

View File

@@ -59,9 +59,9 @@
<artifactId>spring-boot</artifactId> <artifactId>spring-boot</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>spring-boot-starter-json</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>

View File

@@ -20,7 +20,7 @@ import com.google.common.collect.Maps;
* Bean which holds the necessary properties for configuring the AMQP deadletter * Bean which holds the necessary properties for configuring the AMQP deadletter
* queue. * queue.
*/ */
@ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter") @ConfigurationProperties("hawkbit.dmf.rabbitmq.dead-letter")
public class AmqpDeadletterProperties { public class AmqpDeadletterProperties {
private static final int THREE_WEEKS = 21; private static final int THREE_WEEKS = 21;

View File

@@ -35,8 +35,8 @@ import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -140,7 +140,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
.forEach( .forEach(
module -> modules.put(module, module -> modules.put(module,
softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
new PageRequest(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()) PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId())
.getContent())); .getContent()));
targetManagement.getByControllerID(assignedEvent.getActions().keySet()) targetManagement.getByControllerID(assignedEvent.getActions().keySet())

View File

@@ -9,11 +9,9 @@
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -43,7 +41,6 @@ import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.messaging.converter.MessageConversionException;
import org.springframework.messaging.handler.annotation.Header; import org.springframework.messaging.handler.annotation.Header;
import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@@ -271,7 +268,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
if (isCorrelationIdNotEmpty(message)) { if (isCorrelationIdNotEmpty(message)) {
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message correlation-id " messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message correlation-id "
+ convertCorrelationId(message)); + message.getMessageProperties().getCorrelationId());
} }
final Status status = mapStatus(message, actionUpdateStatus, action); final Status status = mapStatus(message, actionUpdateStatus, action);
@@ -287,8 +284,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
} }
private static boolean isCorrelationIdNotEmpty(final Message message) { private static boolean isCorrelationIdNotEmpty(final Message message) {
return message.getMessageProperties().getCorrelationId() != null return StringUtils.hasLength(message.getMessageProperties().getCorrelationId());
&& message.getMessageProperties().getCorrelationId().length > 0;
} }
// Exception squid:MethodCyclomaticComplexity - false positive, is a simple // Exception squid:MethodCyclomaticComplexity - false positive, is a simple
@@ -341,10 +337,6 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
return null; return null;
} }
private static String convertCorrelationId(final Message message) {
return new String(message.getMessageProperties().getCorrelationId(), StandardCharsets.UTF_8);
}
private Action getUpdateActionStatus(final Status status, final ActionStatusCreate actionStatus) { private Action getUpdateActionStatus(final Status status, final ActionStatusCreate actionStatus) {
if (Status.CANCELED.equals(status)) { if (Status.CANCELED.equals(status)) {
return controllerManagement.addCancelActionStatus(actionStatus); return controllerManagement.addCancelActionStatus(actionStatus);

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory; import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpoint;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.util.ErrorHandler; import org.springframework.util.ErrorHandler;
@@ -44,8 +45,9 @@ public class ConfigurableRabbitListenerContainerFactory extends SimpleRabbitList
// Exception squid:UnusedProtectedMethod - called by // Exception squid:UnusedProtectedMethod - called by
// AbstractRabbitListenerContainerFactory // AbstractRabbitListenerContainerFactory
@SuppressWarnings("squid:UnusedProtectedMethod") @SuppressWarnings("squid:UnusedProtectedMethod")
protected void initializeContainer(final SimpleMessageListenerContainer instance) { protected void initializeContainer(final SimpleMessageListenerContainer instance,
super.initializeContainer(instance); final RabbitListenerEndpoint endpoint) {
super.initializeContainer(instance, endpoint);
instance.setDeclarationRetries(declarationRetries); instance.setDeclarationRetries(declarationRetries);
} }
} }

View File

@@ -9,15 +9,15 @@
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.UUID; import java.util.UUID;
import org.eclipse.hawkbit.util.IpUtil; import org.eclipse.hawkbit.util.IpUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData; import org.springframework.util.StringUtils;
/** /**
* A default implementation for the sender service. The service sends all amqp * A default implementation for the sender service. The service sends all amqp
@@ -47,7 +47,7 @@ public class DefaultAmqpMessageSenderService extends BaseAmqpService implements
final String correlationId = UUID.randomUUID().toString(); final String correlationId = UUID.randomUUID().toString();
if (isCorrelationIdEmpty(message)) { if (isCorrelationIdEmpty(message)) {
message.getMessageProperties().setCorrelationId(correlationId.getBytes(StandardCharsets.UTF_8)); message.getMessageProperties().setCorrelationId(correlationId);
} }
if (LOGGER.isTraceEnabled()) { if (LOGGER.isTraceEnabled()) {
@@ -60,8 +60,7 @@ public class DefaultAmqpMessageSenderService extends BaseAmqpService implements
} }
protected static boolean isCorrelationIdEmpty(final Message message) { protected static boolean isCorrelationIdEmpty(final Message message) {
return message.getMessageProperties().getCorrelationId() == null return !StringUtils.hasLength(message.getMessageProperties().getCorrelationId());
|| message.getMessageProperties().getCorrelationId().length <= 0;
} }
} }

View File

@@ -10,9 +10,9 @@ package org.eclipse.hawkbit.amqp;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -51,7 +51,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -164,7 +164,6 @@ public class AmqpControllerAuthenticationTest {
final AbstractDbArtifact artifact = new ArtifactFilesystem(new File("does not exist"), SHA1, final AbstractDbArtifact artifact = new ArtifactFilesystem(new File("does not exist"), SHA1,
new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null); new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null);
when(artifactManagementMock.loadArtifactBinary(SHA1)).thenReturn(Optional.of(artifact));
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate,
mock(AmqpMessageDispatcherService.class), controllerManagementMock, new JpaEntityFactory()); mock(AmqpMessageDispatcherService.class), controllerManagementMock, new JpaEntityFactory());

View File

@@ -12,9 +12,9 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyObject; import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Matchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.io.File; import java.io.File;
@@ -59,7 +59,7 @@ import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper; import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import io.qameta.allure.Description; import io.qameta.allure.Description;
@@ -69,7 +69,7 @@ import io.qameta.allure.Story;
@ActiveProfiles({ "test" }) @ActiveProfiles({ "test" })
@Feature("Component Tests - Device Management Federation API") @Feature("Component Tests - Device Management Federation API")
@Story("AmqpMessage Dispatcher Service Test") @Story("AmqpMessage Dispatcher Service Test")
@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class }) @SpringBootTest(classes = { RepositoryApplicationConfiguration.class })
public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
private static final String TENANT = "default"; private static final String TENANT = "default";
@@ -214,7 +214,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
}); });
} }
} }
@Test @Test
@Description("Verifies that sending update controller attributes event works.") @Description("Verifies that sending update controller attributes event works.")
public void sendUpdateAttributesRequest() { public void sendUpdateAttributesRequest() {

View File

@@ -10,10 +10,10 @@ package org.eclipse.hawkbit.amqp;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Matchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Matchers.anyLong; import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Matchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -43,7 +43,6 @@ import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.UpdateMode; import org.eclipse.hawkbit.repository.UpdateMode;
import org.eclipse.hawkbit.repository.builder.ActionStatusBuilder; import org.eclipse.hawkbit.repository.builder.ActionStatusBuilder;
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate; import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityTokenGeneratorHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityTokenGeneratorHolder;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -60,7 +59,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.amqp.AmqpRejectAndDontRequeueException; import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.core.MessageProperties;
@@ -392,8 +391,6 @@ public class AmqpMessageHandlerServiceTest {
final Artifact localArtifactMock = mock(Artifact.class); final Artifact localArtifactMock = mock(Artifact.class);
when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock)); when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyString(), anyLong()))
.thenThrow(EntityNotFoundException.class);
// test // test
final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message);
@@ -515,15 +512,11 @@ public class AmqpMessageHandlerServiceTest {
final Target targetMock = mock(Target.class); final Target targetMock = mock(Target.class);
final DistributionSet distributionSetMock = mock(DistributionSet.class); final DistributionSet distributionSetMock = mock(DistributionSet.class);
when(distributionSetMock.getId()).thenReturn(1L);
when(actionMock.getDistributionSet()).thenReturn(distributionSetMock); when(actionMock.getDistributionSet()).thenReturn(distributionSetMock);
when(actionMock.getId()).thenReturn(targetId); when(actionMock.getId()).thenReturn(targetId);
when(actionMock.getStatus()).thenReturn(status);
when(actionMock.getTenant()).thenReturn("DEFAULT"); when(actionMock.getTenant()).thenReturn("DEFAULT");
when(actionMock.getTarget()).thenReturn(targetMock); when(actionMock.getTarget()).thenReturn(targetMock);
when(targetMock.getControllerId()).thenReturn("target1"); when(targetMock.getControllerId()).thenReturn("target1");
when(targetMock.getSecurityToken()).thenReturn("securityToken");
when(targetMock.getAddress()).thenReturn(null);
return actionMock; return actionMock;
} }

View File

@@ -39,6 +39,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.TestdataFactory; import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
import org.eclipse.hawkbit.util.IpUtil; import org.eclipse.hawkbit.util.IpUtil;
import org.junit.Assert; import org.junit.Assert;
@@ -49,7 +50,8 @@ import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.test.RabbitListenerTestHarness; import org.springframework.amqp.rabbit.test.RabbitListenerTestHarness;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
import org.springframework.test.context.ContextConfiguration;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -58,9 +60,10 @@ import io.qameta.allure.Step;
* Common class for {@link AmqpMessageHandlerServiceIntegrationTest} and * Common class for {@link AmqpMessageHandlerServiceIntegrationTest} and
* {@link AmqpMessageDispatcherServiceIntegrationTest}. * {@link AmqpMessageDispatcherServiceIntegrationTest}.
*/ */
@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, @ContextConfiguration(classes = { DmfApiConfiguration.class, DmfTestConfiguration.class,
DmfApiConfiguration.class, DmfTestConfiguration.class }) RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class,
public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest { TestSupportBinderAutoConfiguration.class })
public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest {
protected static final String TENANT_EXIST = "DEFAULT"; protected static final String TENANT_EXIST = "DEFAULT";
protected static final String CREATED_BY = "CONTROLLER_PLUG_AND_PLAY"; protected static final String CREATED_BY = "CONTROLLER_PLUG_AND_PLAY";
@@ -99,7 +102,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
} }
protected void verifyDeadLetterMessages(final int expectedMessages) { protected void verifyDeadLetterMessages(final int expectedMessages) {
createConditionFactory().until(() -> { createConditionFactory().untilAsserted(() -> {
Mockito.verify(getDeadletterListener(), Mockito.times(expectedMessages)).handleMessage(Mockito.any()); Mockito.verify(getDeadletterListener(), Mockito.times(expectedMessages)).handleMessage(Mockito.any());
}); });
} }
@@ -165,8 +168,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
final Map<String, Object> headers = replyMessage.getMessageProperties().getHeaders(); final Map<String, Object> headers = replyMessage.getMessageProperties().getHeaders();
assertThat(headers.get(MessageHeaderKey.TENANT)).isEqualTo(TENANT_EXIST); assertThat(headers.get(MessageHeaderKey.TENANT)).isEqualTo(TENANT_EXIST);
assertThat(correlationId) assertThat(correlationId).isEqualTo(replyMessage.getMessageProperties().getCorrelationId());
.isEqualTo(new String(replyMessage.getMessageProperties().getCorrelationId(), StandardCharsets.UTF_8));
assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.PING_RESPONSE.toString()); assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.PING_RESPONSE.toString());
assertThat(Long.valueOf(new String(replyMessage.getBody(), StandardCharsets.UTF_8))) assertThat(Long.valueOf(new String(replyMessage.getBody(), StandardCharsets.UTF_8)))
.isLessThanOrEqualTo(System.currentTimeMillis()); .isLessThanOrEqualTo(System.currentTimeMillis());
@@ -213,7 +215,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
} }
protected void verifyReplyToListener() { protected void verifyReplyToListener() {
createConditionFactory().until(() -> { createConditionFactory().untilAsserted(() -> {
Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any()); Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any());
}); });
} }
@@ -306,7 +308,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
protected Message createPingMessage(final String correlationId, final String tenant) { protected Message createPingMessage(final String correlationId, final String tenant) {
final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant); final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant);
messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.PING.toString()); messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.PING.toString());
messageProperties.setCorrelationId(correlationId.getBytes()); messageProperties.setCorrelationId(correlationId);
messageProperties.setReplyTo(DmfTestConfiguration.REPLY_TO_EXCHANGE); messageProperties.setReplyTo(DmfTestConfiguration.REPLY_TO_EXCHANGE);
return createMessage(null, messageProperties); return createMessage(null, messageProperties);
@@ -354,7 +356,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) { protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId)); waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId));
createConditionFactory().until(() -> { createConditionFactory().untilAsserted(() -> {
try { try {
final Map<String, String> controllerAttributes = securityRule final Map<String, String> controllerAttributes = securityRule
.runAsPrivileged(() -> targetManagement.getControllerAttributes(controllerId)); .runAsPrivileged(() -> targetManagement.getControllerAttributes(controllerId));

View File

@@ -19,8 +19,6 @@ import org.eclipse.hawkbit.amqp.DmfApiConfiguration;
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse;
import org.eclipse.hawkbit.rabbitmq.test.AbstractAmqpIntegrationTest; import org.eclipse.hawkbit.rabbitmq.test.AbstractAmqpIntegrationTest;
import org.eclipse.hawkbit.rabbitmq.test.AmqpTestConfiguration;
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -35,7 +33,7 @@ import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -45,8 +43,7 @@ import io.qameta.allure.Story;
@Feature("Component Tests - Device Management Federation API") @Feature("Component Tests - Device Management Federation API")
@Story("Amqp Authentication Message Handler") @Story("Amqp Authentication Message Handler")
@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, @SpringBootTest(classes = { DmfApiConfiguration.class })
DmfApiConfiguration.class })
public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmqpIntegrationTest { public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmqpIntegrationTest {
private static final String TARGET_SECRUITY_TOKEN = "12345"; private static final String TARGET_SECRUITY_TOKEN = "12345";

View File

@@ -40,7 +40,7 @@ import io.qameta.allure.Story;
@Feature("Component Tests - Device Management Federation API") @Feature("Component Tests - Device Management Federation API")
@Story("Amqp Message Dispatcher Service") @Story("Amqp Message Dispatcher Service")
public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceIntegrationTest { public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
private static final String TARGET_PREFIX = "Dmf_disp_"; private static final String TARGET_PREFIX = "Dmf_disp_";
@Test @Test

View File

@@ -58,7 +58,7 @@ import io.qameta.allure.Story;
@Feature("Component Tests - Device Management Federation API") @Feature("Component Tests - Device Management Federation API")
@Story("Amqp Message Handler Service") @Story("Amqp Message Handler Service")
public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegrationTest { public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
private static final String CORRELATION_ID = UUID.randomUUID().toString(); private static final String CORRELATION_ID = UUID.randomUUID().toString();
private static final String TARGET_PREFIX = "Dmf_hand_"; private static final String TARGET_PREFIX = "Dmf_hand_";
@@ -836,7 +836,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra
} }
private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) { private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) {
createConditionFactory().await().until(() -> { createConditionFactory().await().untilAsserted(() -> {
try { try {
securityRule.runAsPrivileged(() -> { securityRule.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement final List<ActionStatus> actionStatusList = deploymentManagement
@@ -870,7 +870,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra
final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant); final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant);
messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.EVENT.toString()); messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.EVENT.toString());
messageProperties.getHeaders().put(MessageHeaderKey.TOPIC, eventTopic.toString()); messageProperties.getHeaders().put(MessageHeaderKey.TOPIC, eventTopic.toString());
messageProperties.setCorrelationId(CORRELATION_ID.getBytes()); messageProperties.setCorrelationId(CORRELATION_ID);
return createMessage(payload, messageProperties); return createMessage(payload, messageProperties);
} }
@@ -896,7 +896,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra
private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) { private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) {
assertEmptyReceiverQueueCount(); assertEmptyReceiverQueueCount();
createConditionFactory().until(() -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)) createConditionFactory().untilAsserted(() -> Mockito
.handleMessage(Mockito.any())); .verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
} }
} }

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.integration.listener;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.nio.charset.StandardCharsets;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -53,9 +52,7 @@ public class ReplyToListener implements TestRabbitListener {
} }
if (messageType == MessageType.PING_RESPONSE) { if (messageType == MessageType.PING_RESPONSE) {
final String correlationId = new String(message.getMessageProperties().getCorrelationId(), pingResponseMessages.put(message.getMessageProperties().getCorrelationId(), message);
StandardCharsets.UTF_8);
pingResponseMessages.put(correlationId, message);
return; return;
} }

View File

@@ -9,58 +9,74 @@
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.hawkbit</groupId> <parent>
<artifactId>hawkbit-dmf-parent</artifactId> <groupId>org.eclipse.hawkbit</groupId>
<version>0.3.0-SNAPSHOT</version> <artifactId>hawkbit-dmf-parent</artifactId>
</parent> <version>0.3.0-SNAPSHOT</version>
<artifactId>hawkbit-dmf-rabbitmq-test</artifactId> </parent>
<name>hawkBit :: DMF :: RabbitMq Test module</name> <artifactId>hawkbit-dmf-rabbitmq-test</artifactId>
<name>hawkBit :: DMF :: RabbitMq Test module</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-api</artifactId> <artifactId>hawkbit-repository-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-core</artifactId> <artifactId>hawkbit-repository-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-jpa</artifactId> <artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-dmf-api</artifactId> <artifactId>hawkbit-dmf-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.amqp</groupId> <groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-junit</artifactId> <artifactId>spring-rabbit-junit</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.amqp</groupId> <groupId>com.rabbitmq</groupId>
<artifactId>spring-rabbit-test</artifactId> <artifactId>http-client</artifactId>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.springframework</groupId>
<artifactId>hawkbit-repository-test</artifactId> <artifactId>spring-web</artifactId>
<version>${project.version}</version> <scope>compile</scope>
<scope>compile</scope> </dependency>
</dependency> <dependency>
</dependencies> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-test</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project> </project>

View File

@@ -8,9 +8,13 @@
*/ */
package org.eclipse.hawkbit.rabbitmq.test; package org.eclipse.hawkbit.rabbitmq.test;
import java.time.Duration;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@@ -22,18 +26,18 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.junit.BrokerRunning; import org.springframework.amqp.rabbit.junit.BrokerRunning;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import com.jayway.awaitility.Awaitility; @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class,
import com.jayway.awaitility.core.ConditionFactory; TestConfiguration.class, TestSupportBinderAutoConfiguration.class })
@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class })
// Dirty context is necessary to create a new vhost and recreate all necessary // Dirty context is necessary to create a new vhost and recreate all necessary
// beans after every test class. // beans after every test class.
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) @DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest { public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest {
private static final Duration TIMEOUT = Duration.ofSeconds(5);
@Rule @Rule
@Autowired @Autowired
@@ -59,7 +63,7 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes
} }
protected ConditionFactory createConditionFactory() { protected ConditionFactory createConditionFactory() {
return Awaitility.await().atMost(5, TimeUnit.SECONDS); return Awaitility.await().atMost(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
} }
protected Message createMessage(final Object payload, final MessageProperties messageProperties) { protected Message createMessage(final Object payload, final MessageProperties messageProperties) {

View File

@@ -26,8 +26,9 @@ import com.rabbitmq.http.client.domain.UserPermissions;
* Creates and deletes a new virtual host if the rabbit mq management api is * Creates and deletes a new virtual host if the rabbit mq management api is
* available. * available.
* *
*
*/ */
// exception squid:S2068 - Test instance passwd
@SuppressWarnings("squid:S2068")
public class RabbitMqSetupService { public class RabbitMqSetupService {
private static final String GUEST = "guest"; private static final String GUEST = "guest";
@@ -44,7 +45,7 @@ public class RabbitMqSetupService {
private String password; private String password;
public RabbitMqSetupService(RabbitProperties properties) { public RabbitMqSetupService(final RabbitProperties properties) {
hostname = properties.getHost(); hostname = properties.getHost();
username = properties.getUsername(); username = properties.getUsername();
if (StringUtils.isEmpty(username)) { if (StringUtils.isEmpty(username)) {
@@ -118,7 +119,7 @@ public class RabbitMqSetupService {
static class AlivenessException extends RuntimeException { static class AlivenessException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public AlivenessException(String hostname) { public AlivenessException(final String hostname) {
super("Aliveness test failed for " + hostname super("Aliveness test failed for " + hostname
+ ":15672 guest/quest; rabbit mq management api not available"); + ":15672 guest/quest; rabbit mq management api not available");
} }

View File

@@ -42,8 +42,20 @@
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>com.esotericsoftware</groupId> <groupId>org.springframework.security</groupId>
<artifactId>kryo-shaded</artifactId> <artifactId>spring-security-rsa</artifactId>
</exclusion>
<exclusion>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>

View File

@@ -24,8 +24,8 @@ import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.QuotaExceededException;
import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException; import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
import org.eclipse.hawkbit.repository.exception.QuotaExceededException;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.ActionStatus;
@@ -400,9 +400,9 @@ public interface ControllerManagement {
/** /**
* Cancels given {@link Action} for this {@link Target}. However, it might * Cancels given {@link Action} for this {@link Target}. However, it might
* be possible that the controller will continue to work on the cancelation. * be possible that the controller will continue to work on the
* The controller needs to acknowledge or reject the cancelation using * cancellation. The controller needs to acknowledge or reject the
* {@link DdiRootController#postCancelActionFeedback}. * cancellation using {@link DdiRootController#postCancelActionFeedback}.
* *
* @param actionId * @param actionId
* to be canceled * to be canceled

View File

@@ -21,7 +21,7 @@ import org.springframework.data.domain.Sort;
public final class OffsetBasedPageRequest extends PageRequest { public final class OffsetBasedPageRequest extends PageRequest {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final int offset; private final long offset;
/** /**
* Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed, * Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed,
@@ -32,8 +32,8 @@ public final class OffsetBasedPageRequest extends PageRequest {
* @param limit * @param limit
* the limit of the page to be returned. * the limit of the page to be returned.
*/ */
public OffsetBasedPageRequest(final int offset, final int limit) { public OffsetBasedPageRequest(final long offset, final int limit) {
this(offset, limit, null); this(offset, limit, Sort.unsorted());
} }
/** /**
@@ -47,13 +47,13 @@ public final class OffsetBasedPageRequest extends PageRequest {
* @param sort * @param sort
* sort can be {@literal null}. * sort can be {@literal null}.
*/ */
public OffsetBasedPageRequest(final int offset, final int limit, final Sort sort) { public OffsetBasedPageRequest(final long offset, final int limit, final Sort sort) {
super(0, limit, sort); super(0, limit, sort);
this.offset = offset; this.offset = offset;
} }
@Override @Override
public int getOffset() { public long getOffset() {
return offset; return offset;
} }
@@ -67,7 +67,7 @@ public final class OffsetBasedPageRequest extends PageRequest {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = super.hashCode(); int result = super.hashCode();
result = prime * result + offset; result = prime * result + (int) (offset ^ (offset >>> 32));
return result; return result;
} }
@@ -79,11 +79,14 @@ public final class OffsetBasedPageRequest extends PageRequest {
if (!super.equals(obj)) { if (!super.equals(obj)) {
return false; return false;
} }
if (!(obj instanceof OffsetBasedPageRequest)) { if (getClass() != obj.getClass()) {
return false; return false;
} }
final OffsetBasedPageRequest other = (OffsetBasedPageRequest) obj; final OffsetBasedPageRequest other = (OffsetBasedPageRequest) obj;
return offset == other.offset; if (offset != other.offset) {
return false;
}
return true;
} }
} }

View File

@@ -631,6 +631,7 @@ public interface TargetManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if target with given ID does not exist * if target with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Map<String, String> getControllerAttributes(@NotEmpty String controllerId); Map<String, String> getControllerAttributes(@NotEmpty String controllerId);
/** /**
@@ -642,6 +643,7 @@ public interface TargetManagement {
* @throws EntityNotFoundException * @throws EntityNotFoundException
* if target with given ID does not exist * if target with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void requestControllerAttributes(@NotEmpty String controllerId); void requestControllerAttributes(@NotEmpty String controllerId);
/** /**
@@ -652,8 +654,33 @@ public interface TargetManagement {
* @return {@code true}: update of controller attributes triggered. * @return {@code true}: update of controller attributes triggered.
* {@code false}: update of controller attributes not requested. * {@code false}: update of controller attributes not requested.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
boolean isControllerAttributesRequested(@NotEmpty String controllerId); boolean isControllerAttributesRequested(@NotEmpty String controllerId);
/**
* Retrieves {@link Target}s where
* {@link #isControllerAttributesRequested(String)}.
*
* @param pageReq
* page parameter
*
* @return the found {@link Target}s
*
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findByControllerAttributesRequested(@NotNull Pageable pageReq);
/**
* Verifies that {@link Target} with given controller ID exists in the
* repository.
*
* @param controllerId
* of target
* @return {@code true} if target with given ID exists
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
boolean existsByControllerId(@NotEmpty String controllerId);
/** /**
* Creates a list of target meta data entries. * Creates a list of target meta data entries.
* *

View File

@@ -40,7 +40,7 @@ public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements Te
* the applicationId * the applicationId
*/ */
public RemoteTenantAwareEvent(final Object source, final String tenant, final String applicationId) { public RemoteTenantAwareEvent(final Object source, final String tenant, final String applicationId) {
super(source, applicationId, "**"); super(source, applicationId);
this.tenant = tenant; this.tenant = tenant;
} }

View File

@@ -25,7 +25,7 @@ public final class ArtifactBinaryNotFoundException extends AbstractServerRtExcep
/** /**
* Creates a new FileUploadFailedException with * Creates a new FileUploadFailedException with
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. * {@link SpServerError#SP_ARTIFACT_LOAD_FAILED} error.
*/ */
public ArtifactBinaryNotFoundException() { public ArtifactBinaryNotFoundException() {
super(SpServerError.SP_ARTIFACT_LOAD_FAILED); super(SpServerError.SP_ARTIFACT_LOAD_FAILED);

View File

@@ -26,7 +26,7 @@ public final class ArtifactDeleteFailedException extends AbstractServerRtExcepti
/** /**
* Creates a new FileUploadFailedException with * Creates a new FileUploadFailedException with
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. * {@link SpServerError#SP_ARTIFACT_DELETE_FAILED} error.
*/ */
public ArtifactDeleteFailedException() { public ArtifactDeleteFailedException() {
super(SpServerError.SP_ARTIFACT_DELETE_FAILED); super(SpServerError.SP_ARTIFACT_DELETE_FAILED);

View File

@@ -22,7 +22,7 @@ public final class ArtifactUploadFailedException extends AbstractServerRtExcepti
/** /**
* Creates a new FileUploadFailedException with * Creates a new FileUploadFailedException with
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. * {@link SpServerError#SP_ARTIFACT_UPLOAD_FAILED} error.
*/ */
public ArtifactUploadFailedException() { public ArtifactUploadFailedException() {
super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED); super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED);

View File

@@ -8,13 +8,15 @@
*/ */
package org.eclipse.hawkbit.repository.rsql; package org.eclipse.hawkbit.repository.rsql;
import java.io.Serializable;
/** /**
* Implementations map a placeholder to the associated value. * Implementations map a placeholder to the associated value.
* <p> * <p>
* This is used in context of string replacement. * This is used in context of string replacement.
*/ */
@FunctionalInterface @FunctionalInterface
public interface VirtualPropertyReplacer { public interface VirtualPropertyReplacer extends Serializable {
/** /**
* Looks up a placeholders and replaces them * Looks up a placeholders and replaces them

View File

@@ -9,7 +9,7 @@
package org.eclipse.hawkbit.repository.model.helper; package org.eclipse.hawkbit.repository.model.helper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
/** /**
@@ -26,7 +26,7 @@ public final class EventPublisherHolder {
private ApplicationEventPublisher eventPublisher; private ApplicationEventPublisher eventPublisher;
@Autowired @Autowired
private ApplicationContext applicationContext; private BusProperties bus;
private EventPublisherHolder() { private EventPublisherHolder() {
@@ -47,7 +47,7 @@ public final class EventPublisherHolder {
} }
public String getApplicationId() { public String getApplicationId() {
return applicationContext.getId(); return bus.getId();
} }
} }

View File

@@ -42,10 +42,12 @@ import org.eclipse.hawkbit.repository.TimestampCalculator;
*/ */
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer { public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
private StrSubstitutor substitutor; private static final long serialVersionUID = 1L;
private transient StrSubstitutor substitutor;
@Override @Override
public String lookup(String rhs) { public String lookup(final String rhs) {
String resolved = null; String resolved = null;
if ("now_ts".equalsIgnoreCase(rhs)) { if ("now_ts".equalsIgnoreCase(rhs)) {
@@ -57,7 +59,7 @@ public class VirtualPropertyResolver extends StrLookup<String> implements Virtua
} }
@Override @Override
public String replace(String input) { public String replace(final String input) {
if (substitutor == null) { if (substitutor == null) {
substitutor = new StrSubstitutor(this, StrSubstitutor.DEFAULT_PREFIX, StrSubstitutor.DEFAULT_SUFFIX, substitutor = new StrSubstitutor(this, StrSubstitutor.DEFAULT_PREFIX, StrSubstitutor.DEFAULT_SUFFIX,
StrSubstitutor.DEFAULT_ESCAPE); StrSubstitutor.DEFAULT_ESCAPE);

View File

@@ -21,7 +21,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.cloud.bus.event.RemoteApplicationEvent; import org.springframework.cloud.bus.event.RemoteApplicationEvent;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessageHeaders;

View File

@@ -103,16 +103,6 @@
<artifactId>allure-junit4</artifactId> <artifactId>allure-junit4</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
@@ -121,7 +111,7 @@
<plugin> <plugin>
<groupId>com.ethlo.persistence.tools</groupId> <groupId>com.ethlo.persistence.tools</groupId>
<artifactId>eclipselink-maven-plugin</artifactId> <artifactId>eclipselink-maven-plugin</artifactId>
<version>2.7.0</version> <version>2.7.1.1</version>
<executions> <executions>
<execution> <execution>
<id>modelgen</id> <id>modelgen</id>

View File

@@ -34,7 +34,7 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -50,19 +50,19 @@ public abstract class AbstractDsAssignmentStrategy {
protected final TargetRepository targetRepository; protected final TargetRepository targetRepository;
protected final AfterTransactionCommitExecutor afterCommit; protected final AfterTransactionCommitExecutor afterCommit;
protected final ApplicationEventPublisher eventPublisher; protected final ApplicationEventPublisher eventPublisher;
protected final ApplicationContext applicationContext; protected final BusProperties bus;
private final ActionRepository actionRepository; private final ActionRepository actionRepository;
private final ActionStatusRepository actionStatusRepository; private final ActionStatusRepository actionStatusRepository;
private final QuotaManagement quotaManagement; private final QuotaManagement quotaManagement;
AbstractDsAssignmentStrategy(final TargetRepository targetRepository, AbstractDsAssignmentStrategy(final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final ActionRepository actionRepository, final BusProperties bus, final ActionRepository actionRepository,
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) {
this.targetRepository = targetRepository; this.targetRepository = targetRepository;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.eventPublisher = eventPublisher; this.eventPublisher = eventPublisher;
this.applicationContext = applicationContext; this.bus = bus;
this.actionRepository = actionRepository; this.actionRepository = actionRepository;
this.actionStatusRepository = actionStatusRepository; this.actionStatusRepository = actionStatusRepository;
this.quotaManagement = quotaManagement; this.quotaManagement = quotaManagement;
@@ -138,14 +138,12 @@ public abstract class AbstractDsAssignmentStrategy {
return; return;
} }
afterCommit.afterCommit( afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant,
() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, distributionSetId, distributionSetId, actions, bus.getId(), actions.get(0).isMaintenanceWindowAvailable())));
actions, applicationContext.getId(), actions.get(0).isMaintenanceWindowAvailable())));
} }
protected void sendTargetUpdatedEvent(final JpaTarget target) { protected void sendTargetUpdatedEvent(final JpaTarget target) {
afterCommit.afterCommit( afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId())));
() -> eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId())));
} }
/** /**
@@ -216,8 +214,8 @@ public abstract class AbstractDsAssignmentStrategy {
* the action id of the assignment * the action id of the assignment
*/ */
void cancelAssignDistributionSetEvent(final Target target, final Long actionId) { void cancelAssignDistributionSetEvent(final Target target, final Long actionId) {
afterCommit.afterCommit(() -> eventPublisher afterCommit.afterCommit(
.publishEvent(new CancelTargetAssignmentEvent(target, actionId, applicationContext.getId()))); () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId())));
} }
JpaAction createTargetAction(final Map<String, TargetWithActionType> targetsWithActionMap, final JpaTarget target, JpaAction createTargetAction(final Map<String, TargetWithActionType> targetsWithActionMap, final JpaTarget target,

View File

@@ -147,7 +147,7 @@ public interface DistributionSetRepository
@Override @Override
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
@Query("SELECT d FROM JpaDistributionSet d WHERE d.id IN ?1") @Query("SELECT d FROM JpaDistributionSet d WHERE d.id IN ?1")
List<JpaDistributionSet> findAll(Iterable<Long> ids); List<JpaDistributionSet> findAllById(Iterable<Long> ids);
/** /**
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety * Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety

View File

@@ -86,5 +86,5 @@ public interface DistributionSetTagRepository
@Override @Override
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
@Query("SELECT d FROM JpaDistributionSetTag d WHERE d.id IN ?1") @Query("SELECT d FROM JpaDistributionSetTag d WHERE d.id IN ?1")
List<JpaDistributionSetTag> findAll(Iterable<Long> ids); List<JpaDistributionSetTag> findAllById(Iterable<Long> ids);
} }

View File

@@ -93,7 +93,7 @@ public interface DistributionSetTypeRepository
*/ */
@Override @Override
@Query("SELECT d FROM JpaDistributionSetType d WHERE d.id IN ?1") @Query("SELECT d FROM JpaDistributionSetType d WHERE d.id IN ?1")
List<JpaDistributionSetType> findAll(Iterable<Long> ids); List<JpaDistributionSetType> findAllById(Iterable<Long> ids);
/** /**
* Counts the {@link SoftwareModuleType}s which are associated with the * Counts the {@link SoftwareModuleType}s which are associated with the

View File

@@ -193,12 +193,12 @@ public class JpaArtifactManagement implements ArtifactManagement {
((JpaSoftwareModule) existing.getSoftwareModule()).removeArtifact(existing); ((JpaSoftwareModule) existing.getSoftwareModule()).removeArtifact(existing);
softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule()); softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule());
localArtifactRepository.delete(id); localArtifactRepository.deleteById(id);
} }
@Override @Override
public Optional<Artifact> get(final long id) { public Optional<Artifact> get(final long id) {
return Optional.ofNullable(localArtifactRepository.findOne(id)); return Optional.ofNullable(localArtifactRepository.findById(id).orElse(null));
} }
@Override @Override
@@ -226,7 +226,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
} }
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) { private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) {
if (!softwareModuleRepository.exists(swId)) { if (!softwareModuleRepository.existsById(swId)) {
throw new EntityNotFoundException(SoftwareModule.class, swId); throw new EntityNotFoundException(SoftwareModule.class, swId);
} }
} }
@@ -256,13 +256,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
} }
private SoftwareModule getModuleAndThrowExceptionIfThatFails(final Long moduleId) { private SoftwareModule getModuleAndThrowExceptionIfThatFails(final Long moduleId) {
final SoftwareModule softwareModule = softwareModuleRepository.findOne(moduleId); return softwareModuleRepository.findById(moduleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId));
if (softwareModule == null) {
LOG.debug("no software module with ID {} exists", moduleId);
throw new EntityNotFoundException(SoftwareModule.class, moduleId);
}
return softwareModule;
} }
} }

View File

@@ -40,10 +40,10 @@ import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants; import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.RepositoryProperties; import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.UpdateMode; import org.eclipse.hawkbit.repository.UpdateMode;
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate; import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
@@ -76,7 +76,7 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
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;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -94,7 +94,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionCallback;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@@ -119,9 +118,6 @@ public class JpaControllerManagement implements ControllerManagement {
@Autowired @Autowired
private TargetRepository targetRepository; private TargetRepository targetRepository;
@Autowired
private TargetManagement targetManagement;
@Autowired @Autowired
private SoftwareModuleRepository softwareModuleRepository; private SoftwareModuleRepository softwareModuleRepository;
@@ -144,7 +140,7 @@ public class JpaControllerManagement implements ControllerManagement {
private ApplicationEventPublisher eventPublisher; private ApplicationEventPublisher eventPublisher;
@Autowired @Autowired
private ApplicationContext applicationContext; private BusProperties bus;
@Autowired @Autowired
private AfterTransactionCommitExecutor afterCommit; private AfterTransactionCommitExecutor afterCommit;
@@ -215,7 +211,7 @@ public class JpaControllerManagement implements ControllerManagement {
return getPollingTime(); return getPollingTime();
} }
return (new EventTimer(getPollingTime(), getMinPollingTime(), ChronoUnit.SECONDS)) return new EventTimer(getPollingTime(), getMinPollingTime(), ChronoUnit.SECONDS)
.timeToNextEvent(getMaintenanceWindowPollCount(), action.getMaintenanceWindowStartTime().orElse(null)); .timeToNextEvent(getMaintenanceWindowPollCount(), action.getMaintenanceWindowStartTime().orElse(null));
} }
@@ -324,13 +320,13 @@ public class JpaControllerManagement implements ControllerManagement {
} }
private void throwExceptionIfTargetDoesNotExist(final Long targetId) { private void throwExceptionIfTargetDoesNotExist(final Long targetId) {
if (!targetRepository.exists(targetId)) { if (!targetRepository.existsById(targetId)) {
throw new EntityNotFoundException(Target.class, targetId); throw new EntityNotFoundException(Target.class, targetId);
} }
} }
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long moduleId) { private void throwExceptionIfSoftwareModuleDoesNotExist(final Long moduleId) {
if (!softwareModuleRepository.exists(moduleId)) { if (!softwareModuleRepository.existsById(moduleId)) {
throw new EntityNotFoundException(SoftwareModule.class, moduleId); throw new EntityNotFoundException(SoftwareModule.class, moduleId);
} }
} }
@@ -372,21 +368,20 @@ public class JpaControllerManagement implements ControllerManagement {
final Specification<JpaTarget> spec = (targetRoot, query, cb) -> cb final Specification<JpaTarget> spec = (targetRoot, query, cb) -> cb
.equal(targetRoot.get(JpaTarget_.controllerId), controllerId); .equal(targetRoot.get(JpaTarget_.controllerId), controllerId);
final JpaTarget target = targetRepository.findOne(spec); final Optional<JpaTarget> target = targetRepository.findOne(spec);
if (target == null) { if (!target.isPresent()) {
final Target result = targetRepository.save((JpaTarget) entityFactory.target().create() final Target result = targetRepository.save((JpaTarget) entityFactory.target().create()
.controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId) .controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId)
.status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis()) .status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis())
.address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build()); .address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build());
afterCommit.afterCommit( afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(result, bus.getId())));
() -> eventPublisher.publishEvent(new TargetPollEvent(result, applicationContext.getId())));
return result; return result;
} }
return updateTargetStatus(target, address); return updateTargetStatus(target.get(), address);
} }
/** /**
@@ -433,8 +428,8 @@ public class JpaControllerManagement implements ControllerManagement {
pollChunks.forEach(chunk -> { pollChunks.forEach(chunk -> {
setLastTargetQuery(tenant, System.currentTimeMillis(), chunk); setLastTargetQuery(tenant, System.currentTimeMillis(), chunk);
chunk.forEach(controllerId -> afterCommit.afterCommit(() -> eventPublisher chunk.forEach(controllerId -> afterCommit.afterCommit(
.publishEvent(new TargetPollEvent(controllerId, tenant, applicationContext.getId())))); () -> eventPublisher.publishEvent(new TargetPollEvent(controllerId, tenant, bus.getId()))));
}); });
return null; return null;
@@ -468,7 +463,7 @@ public class JpaControllerManagement implements ControllerManagement {
} }
private static String formatQueryInStatementParams(final Collection<String> paramNames) { private static String formatQueryInStatementParams(final Collection<String> paramNames) {
return "#" + Joiner.on(",#").join(paramNames); return "#" + String.join(",#", paramNames);
} }
/** /**
@@ -488,8 +483,7 @@ public class JpaControllerManagement implements ControllerManagement {
toUpdate.setAddress(address.toString()); toUpdate.setAddress(address.toString());
toUpdate.setLastTargetQuery(System.currentTimeMillis()); toUpdate.setLastTargetQuery(System.currentTimeMillis());
afterCommit.afterCommit( afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, bus.getId())));
() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId())));
return targetRepository.save(toUpdate); return targetRepository.save(toUpdate);
} }
@@ -583,7 +577,7 @@ public class JpaControllerManagement implements ControllerManagement {
private boolean actionIsNotActiveButIntermediateFeedbackStillAllowed(final ActionStatus actionStatus, private boolean actionIsNotActiveButIntermediateFeedbackStillAllowed(final ActionStatus actionStatus,
final boolean actionActive) { final boolean actionActive) {
return !actionActive && (repositoryProperties.isRejectActionStatusForClosedAction() return !actionActive && (repositoryProperties.isRejectActionStatusForClosedAction()
|| (Status.ERROR.equals(actionStatus.getStatus()) || Status.FINISHED.equals(actionStatus.getStatus()))); || Status.ERROR.equals(actionStatus.getStatus()) || Status.FINISHED.equals(actionStatus.getStatus()));
} }
/** /**
@@ -615,12 +609,23 @@ public class JpaControllerManagement implements ControllerManagement {
final Action savedAction = actionRepository.save(action); final Action savedAction = actionRepository.save(action);
if (controllerId != null) { if (controllerId != null) {
targetManagement.requestControllerAttributes(controllerId); requestControllerAttributes(controllerId);
} }
return savedAction; return savedAction;
} }
private void requestControllerAttributes(final String controllerId) {
final JpaTarget target = (JpaTarget) getByControllerId(controllerId)
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
target.setRequestControllerAttributes(true);
eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class.getName(), bus.getId()));
}
private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) { private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) {
mergedAction.setActive(false); mergedAction.setActive(false);
mergedAction.setStatus(Status.ERROR); mergedAction.setStatus(Status.ERROR);
@@ -823,12 +828,12 @@ public class JpaControllerManagement implements ControllerManagement {
@Override @Override
public Optional<Target> get(final long targetId) { public Optional<Target> get(final long targetId) {
return Optional.ofNullable(targetRepository.findOne(targetId)); return targetRepository.findById(targetId).map(t -> (Target) t);
} }
@Override @Override
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) { public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) {
if (!actionRepository.exists(actionId)) { if (!actionRepository.existsById(actionId)) {
throw new EntityNotFoundException(Action.class, actionId); throw new EntityNotFoundException(Action.class, actionId);
} }
@@ -848,7 +853,7 @@ public class JpaControllerManagement implements ControllerManagement {
? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT ? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT
: messageCount; : messageCount;
final PageRequest pageable = new PageRequest(0, limit, new Sort(Direction.DESC, "occurredAt")); final PageRequest pageable = PageRequest.of(0, limit, new Sort(Direction.DESC, "occurredAt"));
final Page<String> messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId, final Page<String> messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId,
RepositoryConstants.SERVER_MESSAGE_PREFIX + "%"); RepositoryConstants.SERVER_MESSAGE_PREFIX + "%");
@@ -860,7 +865,7 @@ public class JpaControllerManagement implements ControllerManagement {
@Override @Override
public Optional<SoftwareModule> getSoftwareModule(final long id) { public Optional<SoftwareModule> getSoftwareModule(final long id) {
return Optional.ofNullable(softwareModuleRepository.findOne(id)); return softwareModuleRepository.findById(id).map(s -> (SoftwareModule) s);
} }
@Override @Override
@@ -868,7 +873,7 @@ public class JpaControllerManagement implements ControllerManagement {
final Collection<Long> moduleId) { final Collection<Long> moduleId) {
return softwareModuleMetadataRepository return softwareModuleMetadataRepository
.findBySoftwareModuleIdInAndTargetVisible(new PageRequest(0, RepositoryConstants.MAX_META_DATA_COUNT), .findBySoftwareModuleIdInAndTargetVisible(PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT),
moduleId, true) moduleId, true)
.getContent().stream().collect(Collectors.groupingBy(o -> (Long) o[0], .getContent().stream().collect(Collectors.groupingBy(o -> (Long) o[0],
Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList()))); Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
@@ -896,8 +901,8 @@ public class JpaControllerManagement implements ControllerManagement {
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((controllerId == null) ? 0 : controllerId.hashCode()); result = prime * result + (controllerId == null ? 0 : controllerId.hashCode());
result = prime * result + ((tenant == null) ? 0 : tenant.hashCode()); result = prime * result + (tenant == null ? 0 : tenant.hashCode());
return result; return result;
} }
@@ -980,7 +985,7 @@ public class JpaControllerManagement implements ControllerManagement {
} }
private void cancelAssignDistributionSetEvent(final JpaTarget target, final Long actionId) { private void cancelAssignDistributionSetEvent(final JpaTarget target, final Long actionId) {
afterCommit.afterCommit(() -> eventPublisher afterCommit.afterCommit(
.publishEvent(new CancelTargetAssignmentEvent(target, actionId, applicationContext.getId()))); () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId())));
} }
} }

View File

@@ -69,7 +69,7 @@ import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.data.domain.AuditorAware; import org.springframework.data.domain.AuditorAware;
@@ -88,7 +88,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
/** /**
@@ -125,7 +124,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
private final TargetManagement targetManagement; private final TargetManagement targetManagement;
private final AuditorAware<String> auditorProvider; private final AuditorAware<String> auditorProvider;
private final ApplicationEventPublisher eventPublisher; private final ApplicationEventPublisher eventPublisher;
private final ApplicationContext applicationContext; private final BusProperties bus;
private final AfterTransactionCommitExecutor afterCommit; private final AfterTransactionCommitExecutor afterCommit;
private final VirtualPropertyReplacer virtualPropertyReplacer; private final VirtualPropertyReplacer virtualPropertyReplacer;
private final PlatformTransactionManager txManager; private final PlatformTransactionManager txManager;
@@ -141,7 +140,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
final DistributionSetRepository distributionSetRepository, final TargetRepository targetRepository, final DistributionSetRepository distributionSetRepository, final TargetRepository targetRepository,
final ActionStatusRepository actionStatusRepository, final TargetManagement targetManagement, final ActionStatusRepository actionStatusRepository, final TargetManagement targetManagement,
final AuditorAware<String> auditorProvider, final ApplicationEventPublisher eventPublisher, final AuditorAware<String> auditorProvider, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final AfterTransactionCommitExecutor afterCommit, final BusProperties bus, final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final Database database) { final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final Database database) {
@@ -153,14 +152,14 @@ public class JpaDeploymentManagement implements DeploymentManagement {
this.targetManagement = targetManagement; this.targetManagement = targetManagement;
this.auditorProvider = auditorProvider; this.auditorProvider = auditorProvider;
this.eventPublisher = eventPublisher; this.eventPublisher = eventPublisher;
this.applicationContext = applicationContext; this.bus = bus;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
this.txManager = txManager; this.txManager = txManager;
onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, bus,
applicationContext, actionRepository, actionStatusRepository, quotaManagement); actionRepository, actionStatusRepository, quotaManagement);
offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher,
applicationContext, actionRepository, actionStatusRepository, quotaManagement); bus, actionRepository, actionStatusRepository, quotaManagement);
this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantConfigurationManagement = tenantConfigurationManagement;
this.quotaManagement = quotaManagement; this.quotaManagement = quotaManagement;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;
@@ -367,7 +366,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
private void setAssignedDistributionSetAndTargetUpdateStatus(final AbstractDsAssignmentStrategy assignmentStrategy, private void setAssignedDistributionSetAndTargetUpdateStatus(final AbstractDsAssignmentStrategy assignmentStrategy,
final JpaDistributionSet set, final List<List<Long>> targetIdsChunks) { final JpaDistributionSet set, final List<List<Long>> targetIdsChunks) {
final String currentUser = auditorProvider != null ? auditorProvider.getCurrentAuditor() : null; final String currentUser = auditorProvider.getCurrentAuditor().orElse(null);
assignmentStrategy.updateTargetStatus(set, targetIdsChunks, currentUser); assignmentStrategy.updateTargetStatus(set, targetIdsChunks, currentUser);
} }
@@ -385,7 +384,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
private void createActionsStatus(final Collection<JpaAction> actions, private void createActionsStatus(final Collection<JpaAction> actions,
final AbstractDsAssignmentStrategy assignmentStrategy, final String actionMessage) { final AbstractDsAssignmentStrategy assignmentStrategy, final String actionMessage) {
actionStatusRepository actionStatusRepository
.save(actions.stream().map(action -> assignmentStrategy.createActionStatus(action, actionMessage)) .saveAll(actions.stream().map(action -> assignmentStrategy.createActionStatus(action, actionMessage))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
@@ -493,7 +492,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
if (!CollectionUtils.isEmpty(targetAssignments)) { if (!CollectionUtils.isEmpty(targetAssignments)) {
afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant,
distributionSetId, targetAssignments, applicationContext.getId(), maintenanceWindowAvailable))); distributionSetId, targetAssignments, bus.getId(), maintenanceWindowAvailable)));
} }
return rolloutGroupActions.getTotalElements(); return rolloutGroupActions.getTotalElements();
@@ -503,7 +502,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
private Page<Action> findActionsByRolloutAndRolloutGroupParent(final Long rolloutId, private Page<Action> findActionsByRolloutAndRolloutGroupParent(final Long rolloutId,
final Long rolloutGroupParentId, final int limit) { final Long rolloutGroupParentId, final int limit) {
final PageRequest pageRequest = new PageRequest(0, limit); final PageRequest pageRequest = PageRequest.of(0, limit);
if (rolloutGroupParentId == null) { if (rolloutGroupParentId == null) {
return actionRepository.findByRolloutIdAndRolloutGroupParentIsNullAndStatus(pageRequest, rolloutId, return actionRepository.findByRolloutIdAndRolloutGroupParentIsNullAndStatus(pageRequest, rolloutId,
Action.Status.SCHEDULED); Action.Status.SCHEDULED);
@@ -577,7 +576,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
@Override @Override
public Optional<Action> findAction(final long actionId) { public Optional<Action> findAction(final long actionId) {
return Optional.ofNullable(actionRepository.findOne(actionId)); return actionRepository.findById(actionId).map(a -> (Action) a);
} }
@Override @Override
@@ -644,7 +643,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
} }
private void throwExceptionIfDistributionSetDoesNotExist(final Long dsId) { private void throwExceptionIfDistributionSetDoesNotExist(final Long dsId) {
if (!distributionSetRepository.exists(dsId)) { if (!distributionSetRepository.existsById(dsId)) {
throw new EntityNotFoundException(DistributionSet.class, dsId); throw new EntityNotFoundException(DistributionSet.class, dsId);
} }
} }
@@ -666,7 +665,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
@Override @Override
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) { public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) {
if (!actionRepository.exists(actionId)) { if (!actionRepository.existsById(actionId)) {
throw new EntityNotFoundException(Action.class, actionId); throw new EntityNotFoundException(Action.class, actionId);
} }
@@ -690,7 +689,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
final CriteriaQuery<String> selMsgQuery = msgQuery.select(join); final CriteriaQuery<String> selMsgQuery = msgQuery.select(join);
selMsgQuery.where(cb.equal(as.get(JpaActionStatus_.id), actionStatusId)); selMsgQuery.where(cb.equal(as.get(JpaActionStatus_.id), actionStatusId));
final List<String> result = entityManager.createQuery(selMsgQuery).setFirstResult(pageable.getOffset()) final List<String> result = entityManager.createQuery(selMsgQuery).setFirstResult((int) pageable.getOffset())
.setMaxResults(pageable.getPageSize()).getResultList().stream().collect(Collectors.toList()); .setMaxResults(pageable.getPageSize()).getResultList().stream().collect(Collectors.toList());
return new PageImpl<>(result, pageable, totalCount); return new PageImpl<>(result, pageable, totalCount);
@@ -777,7 +776,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
} }
private static String formatInClause(final Collection<String> elements) { private static String formatInClause(final Collection<String> elements) {
return "#" + Joiner.on(",#").join(elements); return "#" + String.join(",#", elements);
} }
protected ActionRepository getActionRepository() { protected ActionRepository getActionRepository() {

View File

@@ -57,7 +57,7 @@ import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -105,7 +105,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
private final ApplicationEventPublisher eventPublisher; private final ApplicationEventPublisher eventPublisher;
private final ApplicationContext applicationContext; private final BusProperties bus;
private final TenantAware tenantAware; private final TenantAware tenantAware;
@@ -126,7 +126,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
final DistributionSetMetadataRepository distributionSetMetadataRepository, final DistributionSetMetadataRepository distributionSetMetadataRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository, final TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository,
final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher, final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final TenantAware tenantAware, final BusProperties bus, final TenantAware tenantAware,
final VirtualPropertyReplacer virtualPropertyReplacer, final VirtualPropertyReplacer virtualPropertyReplacer,
final SoftwareModuleRepository softwareModuleRepository, final SoftwareModuleRepository softwareModuleRepository,
final DistributionSetTagRepository distributionSetTagRepository, final DistributionSetTagRepository distributionSetTagRepository,
@@ -142,7 +142,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
this.actionRepository = actionRepository; this.actionRepository = actionRepository;
this.criteriaNoCountDao = criteriaNoCountDao; this.criteriaNoCountDao = criteriaNoCountDao;
this.eventPublisher = eventPublisher; this.eventPublisher = eventPublisher;
this.applicationContext = applicationContext; this.bus = bus;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
this.softwareModuleRepository = softwareModuleRepository; this.softwareModuleRepository = softwareModuleRepository;
@@ -153,7 +153,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
@Override @Override
public Optional<DistributionSet> getWithDetails(final long distid) { public Optional<DistributionSet> getWithDetails(final long distid) {
return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid))); return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid))
.map(d -> (DistributionSet) d);
} }
@Override @Override
@@ -242,7 +243,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
private JpaSoftwareModule findSoftwareModuleAndThrowExceptionIfNotFound(final Long moduleId) { private JpaSoftwareModule findSoftwareModuleAndThrowExceptionIfNotFound(final Long moduleId) {
return Optional.ofNullable(softwareModuleRepository.findOne(moduleId)) return softwareModuleRepository.findById(moduleId)
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)); .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId));
} }
@@ -282,7 +283,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
afterCommit.afterCommit(() -> distributionSetIDs.forEach( afterCommit.afterCommit(() -> distributionSetIDs.forEach(
dsId -> eventPublisher.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId -> eventPublisher.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(),
dsId, JpaDistributionSet.class.getName(), applicationContext.getId())))); dsId, JpaDistributionSet.class.getName(), bus.getId()))));
} }
@Override @Override
@@ -370,12 +371,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
* @return a single DistributionSet which is either installed or assigned to * @return a single DistributionSet which is either installed or assigned to
* a specific target or {@code null}. * a specific target or {@code null}.
*/ */
private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget( private Optional<JpaDistributionSet> findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
final DistributionSetFilter distributionSetFilter) { final DistributionSetFilter distributionSetFilter) {
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications( final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
distributionSetFilter); distributionSetFilter);
if (CollectionUtils.isEmpty(specList)) { if (CollectionUtils.isEmpty(specList)) {
return null; return Optional.empty();
} }
return distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList)); return distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList));
} }
@@ -400,12 +401,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
.setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build(); .setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build();
final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( final Optional<JpaDistributionSet> installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
filterWithInstalledTargets); filterWithInstalledTargets);
final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null) final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null)
.setAssignedTargetId(assignedOrInstalled).build(); .setAssignedTargetId(assignedOrInstalled).build();
final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( final Optional<JpaDistributionSet> assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(
filterWithAssignedTargets); filterWithAssignedTargets);
final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null) final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null)
@@ -417,20 +418,20 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
final List<DistributionSet> resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent()); final List<DistributionSet> resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent());
int orderIndex = 0; int orderIndex = 0;
if (installedDS != null) { if (installedDS.isPresent()) {
final boolean remove = resultSet.remove(installedDS); final boolean remove = resultSet.remove(installedDS.get());
if (!remove) { if (!remove) {
resultSet.remove(resultSet.size() - 1); resultSet.remove(resultSet.size() - 1);
} }
resultSet.add(orderIndex, installedDS); resultSet.add(orderIndex, installedDS.get());
orderIndex++; orderIndex++;
} }
if (assignedDS != null && !assignedDS.equals(installedDS)) { if (assignedDS.isPresent() && !assignedDS.equals(installedDS)) {
final boolean remove = resultSet.remove(assignedDS); final boolean remove = resultSet.remove(assignedDS.get());
if (!remove) { if (!remove) {
resultSet.remove(resultSet.size() - 1); resultSet.remove(resultSet.size() - 1);
} }
resultSet.add(orderIndex, assignedDS); resultSet.add(orderIndex, assignedDS.get());
} }
return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements()); return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements());
@@ -440,7 +441,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
public Optional<DistributionSet> getByNameAndVersion(final String distributionName, final String version) { public Optional<DistributionSet> getByNameAndVersion(final String distributionName, final String version) {
final Specification<JpaDistributionSet> spec = DistributionSetSpecification final Specification<JpaDistributionSet> spec = DistributionSetSpecification
.equalsNameAndVersionIgnoreCase(distributionName, version); .equalsNameAndVersionIgnoreCase(distributionName, version);
return Optional.ofNullable(distributionSetRepository.findOne(spec)); return distributionSetRepository.findOne(spec).map(d -> (DistributionSet) d);
} }
@@ -508,7 +509,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key)); () -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key));
touch(metadata.getDistributionSet()); touch(metadata.getDistributionSet());
distributionSetMetadataRepository.delete(metadata.getId()); distributionSetMetadataRepository.deleteById(metadata.getId());
} }
/** /**
@@ -579,12 +580,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
public Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(final long setId, final String key) { public Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(final long setId, final String key) {
throwExceptionIfDistributionSetDoesNotExist(setId); throwExceptionIfDistributionSetDoesNotExist(setId);
return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key))); return distributionSetMetadataRepository.findById(new DsMetadataCompositeKey(setId, key))
.map(dmd -> (DistributionSetMetadata) dmd);
} }
@Override @Override
public Optional<DistributionSet> getByAction(final long actionId) { public Optional<DistributionSet> getByAction(final long actionId) {
if (!actionRepository.exists(actionId)) { if (!actionRepository.existsById(actionId)) {
throw new EntityNotFoundException(Action.class, actionId); throw new EntityNotFoundException(Action.class, actionId);
} }
@@ -676,7 +678,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
private void checkAndThrowIfDistributionSetMetadataAlreadyExists(final DsMetadataCompositeKey metadataId) { private void checkAndThrowIfDistributionSetMetadataAlreadyExists(final DsMetadataCompositeKey metadataId) {
if (distributionSetMetadataRepository.exists(metadataId)) { if (distributionSetMetadataRepository.existsById(metadataId)) {
throw new EntityAlreadyExistsException( throw new EntityAlreadyExistsException(
"Metadata entry with key '" + metadataId.getKey() + "' already exists"); "Metadata entry with key '" + metadataId.getKey() + "' already exists");
} }
@@ -738,14 +740,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) { private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) {
if (!distributionSetRepository.exists(setId)) { if (!distributionSetRepository.existsById(setId)) {
throw new EntityNotFoundException(DistributionSet.class, setId); throw new EntityNotFoundException(DistributionSet.class, setId);
} }
} }
@Override @Override
public List<DistributionSet> get(final Collection<Long> ids) { public List<DistributionSet> get(final Collection<Long> ids) {
return Collections.unmodifiableList(distributionSetRepository.findAll(ids)); return Collections.unmodifiableList(distributionSetRepository.findAllById(ids));
} }
@Override @Override
@@ -757,7 +759,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
private void throwEntityNotFoundExceptionIfDsTagDoesNotExist(final Long tagId) { private void throwEntityNotFoundExceptionIfDsTagDoesNotExist(final Long tagId) {
if (!distributionSetTagRepository.exists(tagId)) { if (!distributionSetTagRepository.existsById(tagId)) {
throw new EntityNotFoundException(DistributionSetTag.class, tagId); throw new EntityNotFoundException(DistributionSetTag.class, tagId);
} }
} }
@@ -791,12 +793,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
@Override @Override
public Optional<DistributionSet> get(final long id) { public Optional<DistributionSet> get(final long id) {
return Optional.ofNullable(distributionSetRepository.findOne(id)); return distributionSetRepository.findById(id).map(d -> (DistributionSet) d);
} }
@Override @Override
public boolean exists(final long id) { public boolean exists(final long id) {
return distributionSetRepository.exists(id); return distributionSetRepository.existsById(id);
} }
} }

View File

@@ -142,7 +142,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
@Override @Override
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long setId) { public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long setId) {
if (!distributionSetRepository.exists(setId)) { if (!distributionSetRepository.existsById(setId)) {
throw new EntityNotFoundException(DistributionSet.class, setId); throw new EntityNotFoundException(DistributionSet.class, setId);
} }
@@ -165,24 +165,24 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> ids) { public void delete(final Collection<Long> ids) {
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAll(ids); final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAllById(ids);
if (setsFound.size() < ids.size()) { if (setsFound.size() < ids.size()) {
throw new EntityNotFoundException(DistributionSetTag.class, ids, throw new EntityNotFoundException(DistributionSetTag.class, ids,
setsFound.stream().map(DistributionSetTag::getId).collect(Collectors.toList())); setsFound.stream().map(DistributionSetTag::getId).collect(Collectors.toList()));
} }
distributionSetTagRepository.delete(setsFound); distributionSetTagRepository.deleteAll(setsFound);
} }
@Override @Override
public List<DistributionSetTag> get(final Collection<Long> ids) { public List<DistributionSetTag> get(final Collection<Long> ids) {
return Collections.unmodifiableList(distributionSetTagRepository.findAll(ids)); return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids));
} }
@Override @Override
public Optional<DistributionSetTag> get(final long id) { public Optional<DistributionSetTag> get(final long id) {
return Optional.ofNullable(distributionSetTagRepository.findOne(id)); return distributionSetTagRepository.findById(id).map(dst -> (DistributionSetTag) dst);
} }
@Override @Override
@@ -190,12 +190,12 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final long id) { public void delete(final long id) {
distributionSetTagRepository.delete(id); distributionSetTagRepository.deleteById(id);
} }
@Override @Override
public boolean exists(final long id) { public boolean exists(final long id) {
return distributionSetTagRepository.exists(id); return distributionSetTagRepository.existsById(id);
} }
@Override @Override

View File

@@ -99,9 +99,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId()); checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId());
update.getMandatory().ifPresent( update.getMandatory().ifPresent(
mand -> softwareModuleTypeRepository.findAll(mand).forEach(type::addMandatoryModuleType)); mand -> softwareModuleTypeRepository.findAllById(mand).forEach(type::addMandatoryModuleType));
update.getOptional() update.getOptional().ifPresent(
.ifPresent(opt -> softwareModuleTypeRepository.findAll(opt).forEach(type::addOptionalModuleType)); opt -> softwareModuleTypeRepository.findAllById(opt).forEach(type::addOptionalModuleType));
} }
return distributionSetTypeRepository.save(type); return distributionSetTypeRepository.save(type);
@@ -113,7 +113,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public DistributionSetType assignMandatorySoftwareModuleTypes(final long dsTypeId, public DistributionSetType assignMandatorySoftwareModuleTypes(final long dsTypeId,
final Collection<Long> softwareModulesTypeIds) { final Collection<Long> softwareModulesTypeIds) {
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
.findAllById(softwareModulesTypeIds);
if (modules.size() < softwareModulesTypeIds.size()) { if (modules.size() < softwareModulesTypeIds.size()) {
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds, throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
@@ -136,7 +137,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
public DistributionSetType assignOptionalSoftwareModuleTypes(final long dsTypeId, public DistributionSetType assignOptionalSoftwareModuleTypes(final long dsTypeId,
final Collection<Long> softwareModulesTypeIds) { final Collection<Long> softwareModulesTypeIds) {
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
.findAllById(softwareModulesTypeIds);
if (modules.size() < softwareModulesTypeIds.size()) { if (modules.size() < softwareModulesTypeIds.size()) {
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds, throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
@@ -206,13 +208,14 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
@Override @Override
public Optional<DistributionSetType> getByName(final String name) { public Optional<DistributionSetType> getByName(final String name) {
return Optional return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name))
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name))); .map(dst -> (DistributionSetType) dst);
} }
@Override @Override
public Optional<DistributionSetType> getByKey(final String key) { public Optional<DistributionSetType> getByKey(final String key) {
return Optional.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key))); return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key))
.map(dst -> (DistributionSetType) dst);
} }
@Override @Override
@@ -238,7 +241,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
toDelete.setDeleted(true); toDelete.setDeleted(true);
distributionSetTypeRepository.save(toDelete); distributionSetTypeRepository.save(toDelete);
} else { } else {
distributionSetTypeRepository.delete(typeId); distributionSetTypeRepository.deleteById(typeId);
} }
} }
@@ -291,29 +294,29 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> ids) { public void delete(final Collection<Long> ids) {
final List<JpaDistributionSetType> setsFound = distributionSetTypeRepository.findAll(ids); final List<JpaDistributionSetType> setsFound = distributionSetTypeRepository.findAllById(ids);
if (setsFound.size() < ids.size()) { if (setsFound.size() < ids.size()) {
throw new EntityNotFoundException(DistributionSetType.class, ids, throw new EntityNotFoundException(DistributionSetType.class, ids,
setsFound.stream().map(DistributionSetType::getId).collect(Collectors.toList())); setsFound.stream().map(DistributionSetType::getId).collect(Collectors.toList()));
} }
distributionSetTypeRepository.delete(setsFound); distributionSetTypeRepository.deleteAll(setsFound);
} }
@Override @Override
public List<DistributionSetType> get(final Collection<Long> ids) { public List<DistributionSetType> get(final Collection<Long> ids) {
return Collections.unmodifiableList(distributionSetTypeRepository.findAll(ids)); return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids));
} }
@Override @Override
public Optional<DistributionSetType> get(final long id) { public Optional<DistributionSetType> get(final long id) {
return Optional.ofNullable(distributionSetTypeRepository.findOne(id)); return distributionSetTypeRepository.findById(id).map(dst -> (DistributionSetType) dst);
} }
@Override @Override
public boolean exists(final long id) { public boolean exists(final long id) {
return distributionSetTypeRepository.exists(id); return distributionSetTypeRepository.existsById(id);
} }
} }

View File

@@ -96,7 +96,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
@Override @Override
public Optional<RolloutGroup> get(final long rolloutGroupId) { public Optional<RolloutGroup> get(final long rolloutGroupId) {
return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId)); return rolloutGroupRepository.findById(rolloutGroupId).map(rg -> (RolloutGroup) rg);
} }
@Override @Override
@@ -128,7 +128,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
} }
private void throwEntityNotFoundExceptionIfRolloutDoesNotExist(final Long rolloutId) { private void throwEntityNotFoundExceptionIfRolloutDoesNotExist(final Long rolloutId) {
if (!rolloutRepository.exists(rolloutId)) { if (!rolloutRepository.existsById(rolloutId)) {
throw new EntityNotFoundException(Rollout.class, rolloutId); throw new EntityNotFoundException(Rollout.class, rolloutId);
} }
} }
@@ -265,7 +265,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
.where(cb.equal(targetRoot.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), .where(cb.equal(targetRoot.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id),
rolloutGroupId)); rolloutGroupId));
final List<TargetWithActionStatus> targetWithActionStatus = entityManager.createQuery(multiselect) final List<TargetWithActionStatus> targetWithActionStatus = entityManager.createQuery(multiselect)
.setFirstResult(pageRequest.getOffset()).setMaxResults(pageRequest.getPageSize()).getResultList() .setFirstResult((int) pageRequest.getOffset()).setMaxResults(pageRequest.getPageSize()).getResultList()
.stream().map(o -> new TargetWithActionStatus((Target) o[0], (Action.Status) o[1])) .stream().map(o -> new TargetWithActionStatus((Target) o[0], (Action.Status) o[1]))
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -285,7 +285,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
} }
private void throwExceptionIfRolloutGroupDoesNotExist(final Long rolloutGroupId) { private void throwExceptionIfRolloutGroupDoesNotExist(final Long rolloutGroupId) {
if (!rolloutGroupRepository.exists(rolloutGroupId)) { if (!rolloutGroupRepository.existsById(rolloutGroupId)) {
throw new EntityNotFoundException(RolloutGroup.class, rolloutGroupId); throw new EntityNotFoundException(RolloutGroup.class, rolloutGroupId);
} }
} }

View File

@@ -77,6 +77,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
@@ -149,20 +150,21 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
@Autowired @Autowired
private RolloutStatusCache rolloutStatusCache; private RolloutStatusCache rolloutStatusCache;
@Autowired private final BusProperties bus;
private ApplicationContext applicationContext;
private final Database database; private final Database database;
JpaRolloutManagement(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, JpaRolloutManagement(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
final RolloutGroupManagement rolloutGroupManagement, final RolloutGroupManagement rolloutGroupManagement,
final DistributionSetManagement distributionSetManagement, final ApplicationContext context, final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
final ApplicationEventPublisher eventPublisher, final VirtualPropertyReplacer virtualPropertyReplacer, final BusProperties bus, final ApplicationEventPublisher eventPublisher,
final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final Database database, final RolloutApprovalStrategy rolloutApprovalStrategy) { final TenantAware tenantAware, final LockRegistry lockRegistry, final Database database,
final RolloutApprovalStrategy rolloutApprovalStrategy) {
super(targetManagement, deploymentManagement, rolloutGroupManagement, distributionSetManagement, context, super(targetManagement, deploymentManagement, rolloutGroupManagement, distributionSetManagement, context,
eventPublisher, virtualPropertyReplacer, txManager, tenantAware, lockRegistry, rolloutApprovalStrategy); eventPublisher, virtualPropertyReplacer, txManager, tenantAware, lockRegistry, rolloutApprovalStrategy);
this.database = database; this.database = database;
this.bus = bus;
} }
@Override @Override
@@ -194,7 +196,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
@Override @Override
public Optional<Rollout> get(final long rolloutId) { public Optional<Rollout> get(final long rolloutId) {
return Optional.ofNullable(rolloutRepository.findOne(rolloutId)); return rolloutRepository.findById(rolloutId).map(r -> (Rollout) r);
} }
@Override @Override
@@ -337,7 +339,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId()); LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout( final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(
new PageRequest(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")), PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")),
rollout.getId()).getContent(); rollout.getId()).getContent();
int readyGroups = 0; int readyGroups = 0;
@@ -431,7 +433,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
final String targetFilter, final long limit) { final String targetFilter, final long limit) {
return DeploymentHelper.runInNewTransaction(txManager, "assignTargetsToRolloutGroup", status -> { return DeploymentHelper.runInNewTransaction(txManager, "assignTargetsToRolloutGroup", status -> {
final PageRequest pageRequest = new PageRequest(0, Math.toIntExact(limit)); final PageRequest pageRequest = PageRequest.of(0, Math.toIntExact(limit));
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(), final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(),
RolloutGroupStatus.READY, group); RolloutGroupStatus.READY, group);
final Page<Target> targets = targetManagement.findByTargetFilterQueryAndNotInRolloutGroups(pageRequest, final Page<Target> targets = targetManagement.findByTargetFilterQueryAndNotInRolloutGroups(pageRequest,
@@ -582,9 +584,11 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
private Long createActionsForTargetsInNewTransaction(final long rolloutId, final long groupId, final int limit) { private Long createActionsForTargetsInNewTransaction(final long rolloutId, final long groupId, final int limit) {
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> {
final PageRequest pageRequest = new PageRequest(0, limit); final PageRequest pageRequest = PageRequest.of(0, limit);
final Rollout rollout = rolloutRepository.findOne(rolloutId); final Rollout rollout = rolloutRepository.findById(rolloutId)
final RolloutGroup group = rolloutGroupRepository.findOne(groupId); .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
final RolloutGroup group = rolloutGroupRepository.findById(groupId)
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, groupId));
final DistributionSet distributionSet = rollout.getDistributionSet(); final DistributionSet distributionSet = rollout.getDistributionSet();
final ActionType actionType = rollout.getActionType(); final ActionType actionType = rollout.getActionType();
@@ -832,9 +836,10 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
} }
} }
private long executeFittingHandler(final Long rolloutId) { private long executeFittingHandler(final long rolloutId) {
LOGGER.debug("handle rollout {}", rolloutId); LOGGER.debug("handle rollout {}", rolloutId);
final JpaRollout rollout = rolloutRepository.findOne(rolloutId); final JpaRollout rollout = rolloutRepository.findById(rolloutId)
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
switch (rollout.getStatus()) { switch (rollout.getStatus()) {
case CREATING: case CREATING:
@@ -882,7 +887,8 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final long rolloutId) { public void delete(final long rolloutId) {
final JpaRollout jpaRollout = rolloutRepository.findOne(rolloutId); final JpaRollout jpaRollout = rolloutRepository.findById(rolloutId)
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
if (jpaRollout == null) { if (jpaRollout == null) {
throw new EntityNotFoundException(Rollout.class, rolloutId); throw new EntityNotFoundException(Rollout.class, rolloutId);
@@ -945,7 +951,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher
.publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId,
JpaRolloutGroup.class.getName(), applicationContext.getId())))); JpaRolloutGroup.class.getName(), bus.getId()))));
} }
private void hardDeleteRollout(final JpaRollout rollout) { private void hardDeleteRollout(final JpaRollout rollout) {
@@ -971,7 +977,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
} }
private Slice<JpaAction> findScheduledActionsByRollout(final JpaRollout rollout) { private Slice<JpaAction> findScheduledActionsByRollout(final JpaRollout rollout) {
return actionRepository.findByRolloutIdAndStatus(new PageRequest(0, TRANSACTION_ACTIONS), rollout.getId(), return actionRepository.findByRolloutIdAndStatus(PageRequest.of(0, TRANSACTION_ACTIONS), rollout.getId(),
Status.SCHEDULED); Status.SCHEDULED);
} }
@@ -1071,7 +1077,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
@Override @Override
public boolean exists(final long rolloutId) { public boolean exists(final long rolloutId) {
return rolloutRepository.exists(rolloutId); return rolloutRepository.existsById(rolloutId);
} }
private Map<Long, List<TotalTargetCountActionStatus>> getStatusCountItemForRollout(final List<Long> rollouts) { private Map<Long, List<TotalTargetCountActionStatus>> getStatusCountItemForRollout(final List<Long> rollouts) {

View File

@@ -180,7 +180,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
} }
private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) { private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) {
if (!softwareModuleTypeRepository.exists(typeId)) { if (!softwareModuleTypeRepository.existsById(typeId)) {
throw new EntityNotFoundException(SoftwareModuleType.class, typeId); throw new EntityNotFoundException(SoftwareModuleType.class, typeId);
} }
} }
@@ -201,7 +201,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
@Override @Override
public Optional<SoftwareModule> get(final long id) { public Optional<SoftwareModule> get(final long id) {
return Optional.ofNullable(softwareModuleRepository.findOne(id)); return softwareModuleRepository.findById(id).map(sm -> (SoftwareModule) sm);
} }
@Override @Override
@@ -252,7 +252,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
deleteGridFsArtifacts(swModule); deleteGridFsArtifacts(swModule);
if (isUnassigned(swModule.getId())) { if (isUnassigned(swModule.getId())) {
softwareModuleRepository.delete(swModule.getId()); softwareModuleRepository.deleteById(swModule.getId());
} else { } else {
assignedModuleIds.add(swModule.getId()); assignedModuleIds.add(swModule.getId());
} }
@@ -261,7 +261,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
if (!assignedModuleIds.isEmpty()) { if (!assignedModuleIds.isEmpty()) {
String currentUser = null; String currentUser = null;
if (auditorProvider != null) { if (auditorProvider != null) {
currentUser = auditorProvider.getCurrentAuditor(); currentUser = auditorProvider.getCurrentAuditor().orElse(null);
} }
softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser, softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser,
assignedModuleIds.toArray(new Long[0])); assignedModuleIds.toArray(new Long[0]));
@@ -374,7 +374,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
// map result // map result
if (pageable.getOffset() < assignedSoftwareModules.size()) { if (pageable.getOffset() < assignedSoftwareModules.size()) {
assignedSoftwareModules assignedSoftwareModules
.subList(pageable.getOffset(), Math.min(assignedSoftwareModules.size(), pageable.getPageSize())) .subList((int) pageable.getOffset(),
Math.min(assignedSoftwareModules.size(), pageable.getPageSize()))
.forEach(sw -> resultList.add(new AssignedSoftwareModule(sw, true))); .forEach(sw -> resultList.add(new AssignedSoftwareModule(sw, true)));
} }
@@ -401,7 +402,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
unassignedQuery.orderBy(cb.asc(unassignedRoot.get(JpaSoftwareModule_.name)), unassignedQuery.orderBy(cb.asc(unassignedRoot.get(JpaSoftwareModule_.name)),
cb.asc(unassignedRoot.get(JpaSoftwareModule_.version))); cb.asc(unassignedRoot.get(JpaSoftwareModule_.version)));
final List<JpaSoftwareModule> unassignedSoftwareModules = entityManager.createQuery(unassignedQuery) final List<JpaSoftwareModule> unassignedSoftwareModules = entityManager.createQuery(unassignedQuery)
.setFirstResult(Math.max(0, pageable.getOffset() - assignedSoftwareModules.size())) .setFirstResult((int) Math.max(0, pageable.getOffset() - assignedSoftwareModules.size()))
.setMaxResults(pageSize).getResultList(); .setMaxResults(pageSize).getResultList();
// map result // map result
unassignedSoftwareModules.forEach(sw -> resultList.add(new AssignedSoftwareModule(sw, false))); unassignedSoftwareModules.forEach(sw -> resultList.add(new AssignedSoftwareModule(sw, false)));
@@ -456,7 +457,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
@Override @Override
public Page<SoftwareModule> findByAssignedTo(final Pageable pageable, final long setId) { public Page<SoftwareModule> findByAssignedTo(final Pageable pageable, final long setId) {
if (!distributionSetRepository.exists(setId)) { if (!distributionSetRepository.existsById(setId)) {
throw new EntityNotFoundException(DistributionSet.class, setId); throw new EntityNotFoundException(DistributionSet.class, setId);
} }
@@ -527,7 +528,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
private void assertSoftwareModuleMetadataDoesNotExist(final Long moduleId, private void assertSoftwareModuleMetadataDoesNotExist(final Long moduleId,
final JpaSoftwareModuleMetadataCreate md) { final JpaSoftwareModuleMetadataCreate md) {
if (softwareModuleMetadataRepository.exists(new SwMetadataCompositeKey(moduleId, md.getKey()))) { if (softwareModuleMetadataRepository.existsById(new SwMetadataCompositeKey(moduleId, md.getKey()))) {
throwMetadataKeyAlreadyExists(md.getKey()); throwMetadataKeyAlreadyExists(md.getKey());
} }
} }
@@ -607,11 +608,11 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key)); key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key));
touch(metadata.getSoftwareModule()); touch(metadata.getSoftwareModule());
softwareModuleMetadataRepository.delete(metadata.getId()); softwareModuleMetadataRepository.deleteById(metadata.getId());
} }
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) { private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) {
if (!softwareModuleRepository.exists(swId)) { if (!softwareModuleRepository.existsById(swId)) {
throw new EntityNotFoundException(SoftwareModule.class, swId); throw new EntityNotFoundException(SoftwareModule.class, swId);
} }
} }
@@ -654,7 +655,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
public Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(final long moduleId, final String key) { public Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(final long moduleId, final String key) {
throwExceptionIfSoftwareModuleDoesNotExist(moduleId); throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key))); return softwareModuleMetadataRepository.findById(new SwMetadataCompositeKey(moduleId, key))
.map(smmd -> (SoftwareModuleMetadata) smmd);
} }
private static void throwMetadataKeyAlreadyExists(final String metadataKey) { private static void throwMetadataKeyAlreadyExists(final String metadataKey) {
@@ -671,7 +673,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
@Override @Override
public boolean exists(final long id) { public boolean exists(final long id) {
return softwareModuleRepository.exists(id); return softwareModuleRepository.existsById(id);
} }
@Override @Override
@@ -680,7 +682,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
throwExceptionIfSoftwareModuleDoesNotExist(moduleId); throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
return convertMdPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible( return convertMdPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible(
new PageRequest(0, RepositoryConstants.MAX_META_DATA_COUNT), moduleId, true), pageable); PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), moduleId, true), pageable);
} }
} }

View File

@@ -168,29 +168,29 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> ids) { public void delete(final Collection<Long> ids) {
final List<JpaSoftwareModuleType> setsFound = softwareModuleTypeRepository.findAll(ids); final List<JpaSoftwareModuleType> setsFound = softwareModuleTypeRepository.findAllById(ids);
if (setsFound.size() < ids.size()) { if (setsFound.size() < ids.size()) {
throw new EntityNotFoundException(SoftwareModuleType.class, ids, throw new EntityNotFoundException(SoftwareModuleType.class, ids,
setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())); setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()));
} }
softwareModuleTypeRepository.delete(setsFound); softwareModuleTypeRepository.deleteAll(setsFound);
} }
@Override @Override
public List<SoftwareModuleType> get(final Collection<Long> ids) { public List<SoftwareModuleType> get(final Collection<Long> ids) {
return Collections.unmodifiableList(softwareModuleTypeRepository.findAll(ids)); return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids));
} }
@Override @Override
public Optional<SoftwareModuleType> get(final long id) { public Optional<SoftwareModuleType> get(final long id) {
return Optional.ofNullable(softwareModuleTypeRepository.findOne(id)); return softwareModuleTypeRepository.findById(id).map(smt -> (SoftwareModuleType) smt);
} }
@Override @Override
public boolean exists(final long id) { public boolean exists(final long id) {
return softwareModuleTypeRepository.exists(id); return softwareModuleTypeRepository.existsById(id);
} }
} }

View File

@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.cache.TenancyCacheManager;
import org.eclipse.hawkbit.repository.RolloutStatusCache; import org.eclipse.hawkbit.repository.RolloutStatusCache;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantStatsManagement; import org.eclipse.hawkbit.repository.TenantStatsManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.configuration.Constants; import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
import org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager; import org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
@@ -160,7 +161,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
} }
private void usageStatsPerTenant(final SystemUsageReportWithTenants report) { private void usageStatsPerTenant(final SystemUsageReportWithTenants report) {
final List<String> tenants = findTenants(new PageRequest(0, MAX_TENANTS_QUERY)).getContent(); final List<String> tenants = findTenants(PageRequest.of(0, MAX_TENANTS_QUERY)).getContent();
tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> { tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> {
report.addTenantData(systemStatsManagement.getStatsOfTenant()); report.addTenantData(systemStatsManagement.getStatsOfTenant());
@@ -276,7 +277,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
public TenantMetaData updateTenantMetadata(final long defaultDsType) { public TenantMetaData updateTenantMetadata(final long defaultDsType) {
final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata(); final JpaTenantMetaData data = (JpaTenantMetaData) getTenantMetadata();
data.setDefaultDsType(distributionSetTypeRepository.findOne(defaultDsType)); data.setDefaultDsType(distributionSetTypeRepository.findById(defaultDsType)
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, defaultDsType)));
return tenantMetaDataRepository.save(data); return tenantMetaDataRepository.save(data);
} }
@@ -312,15 +314,19 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
@Override @Override
public TenantMetaData getTenantMetadata(final long tenantId) { public TenantMetaData getTenantMetadata(final long tenantId) {
return tenantMetaDataRepository.findOne(tenantId); return tenantMetaDataRepository.findById(tenantId)
.orElseThrow(() -> new EntityNotFoundException(TenantMetaData.class, tenantId));
} }
@Override @Override
@Transactional(propagation = Propagation.NOT_SUPPORTED) @Transactional(propagation = Propagation.NOT_SUPPORTED)
// Exception squid:S2229 - calling findTenants without transaction is
// intended in this case
@SuppressWarnings("squid:S2229")
public void forEachTenant(final Consumer<String> consumer) { public void forEachTenant(final Consumer<String> consumer) {
Page<String> tenants; Page<String> tenants;
Pageable query = new PageRequest(0, MAX_TENANTS_QUERY); Pageable query = PageRequest.of(0, MAX_TENANTS_QUERY);
do { do {
tenants = findTenants(query); tenants = findTenants(query);
tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> { tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> {

View File

@@ -39,7 +39,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specifications;
import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.Database;
import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable; import org.springframework.retry.annotation.Retryable;
@@ -99,11 +98,11 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final long targetFilterQueryId) { public void delete(final long targetFilterQueryId) {
if (!targetFilterQueryRepository.exists(targetFilterQueryId)) { if (!targetFilterQueryRepository.existsById(targetFilterQueryId)) {
throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId); throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId);
} }
targetFilterQueryRepository.delete(targetFilterQueryId); targetFilterQueryRepository.deleteById(targetFilterQueryId);
} }
@Override @Override
@@ -178,7 +177,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
return targetFilterQueryRepository.findAll(pageable); return targetFilterQueryRepository.findAll(pageable);
} }
final Specifications<JpaTargetFilterQuery> specs = SpecificationsBuilder.combineWithAnd(specList); final Specification<JpaTargetFilterQuery> specs = SpecificationsBuilder.combineWithAnd(specList);
return targetFilterQueryRepository.findAll(specs, pageable); return targetFilterQueryRepository.findAll(specs, pageable);
} }
@@ -189,7 +188,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
@Override @Override
public Optional<TargetFilterQuery> get(final long targetFilterQueryId) { public Optional<TargetFilterQuery> get(final long targetFilterQueryId) {
return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId)); return targetFilterQueryRepository.findById(targetFilterQueryId).map(tfq -> (TargetFilterQuery) tfq);
} }
@Override @Override

View File

@@ -64,7 +64,7 @@ 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.rsql.VirtualPropertyReplacer; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@@ -111,7 +111,7 @@ public class JpaTargetManagement implements TargetManagement {
private final ApplicationEventPublisher eventPublisher; private final ApplicationEventPublisher eventPublisher;
private final ApplicationContext applicationContext; private final BusProperties bus;
private final TenantAware tenantAware; private final TenantAware tenantAware;
@@ -127,9 +127,9 @@ public class JpaTargetManagement implements TargetManagement {
final DistributionSetRepository distributionSetRepository, final DistributionSetRepository distributionSetRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao, final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao,
final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, final ApplicationEventPublisher eventPublisher, final BusProperties bus, final TenantAware tenantAware,
final TenantAware tenantAware, final AfterTransactionCommitExecutor afterCommit, final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer,
final VirtualPropertyReplacer virtualPropertyReplacer, final Database database) { final Database database) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.quotaManagement = quotaManagement; this.quotaManagement = quotaManagement;
this.targetRepository = targetRepository; this.targetRepository = targetRepository;
@@ -140,7 +140,7 @@ public class JpaTargetManagement implements TargetManagement {
this.targetTagRepository = targetTagRepository; this.targetTagRepository = targetTagRepository;
this.criteriaNoCountDao = criteriaNoCountDao; this.criteriaNoCountDao = criteriaNoCountDao;
this.eventPublisher = eventPublisher; this.eventPublisher = eventPublisher;
this.applicationContext = applicationContext; this.bus = bus;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
@@ -190,13 +190,13 @@ public class JpaTargetManagement implements TargetManagement {
// TargetUpdatedEvent is not sent within the touch() method due to the // TargetUpdatedEvent is not sent within the touch() method due to the
// "lastModifiedAt" field being ignored in JpaTarget // "lastModifiedAt" field being ignored in JpaTarget
eventPublisher.publishEvent(new TargetUpdatedEvent(updatedTarget, applicationContext.getId())); eventPublisher.publishEvent(new TargetUpdatedEvent(updatedTarget, bus.getId()));
return createdMetadata; return createdMetadata;
} }
private void checkAndThrowIfTargetMetadataAlreadyExists(final TargetMetadataCompositeKey metadataId) { private void checkAndThrowIfTargetMetadataAlreadyExists(final TargetMetadataCompositeKey metadataId) {
if (targetMetadataRepository.exists(metadataId)) { if (targetMetadataRepository.existsById(metadataId)) {
throw new EntityAlreadyExistsException( throw new EntityAlreadyExistsException(
"Metadata entry with key '" + metadataId.getKey() + "' already exists"); "Metadata entry with key '" + metadataId.getKey() + "' already exists");
} }
@@ -230,8 +230,8 @@ public class JpaTargetManagement implements TargetManagement {
// check if exists otherwise throw entity not found exception // check if exists otherwise throw entity not found exception
final JpaTargetMetadata updatedMetadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, final JpaTargetMetadata updatedMetadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId,
md.getKey()) md.getKey()).orElseThrow(
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, md.getKey())); () -> new EntityNotFoundException(TargetMetadata.class, controllerId, md.getKey()));
updatedMetadata.setValue(md.getValue()); updatedMetadata.setValue(md.getValue());
// touch it to update the lock revision because we are modifying the // touch it to update the lock revision because we are modifying the
// target indirectly // target indirectly
@@ -239,7 +239,7 @@ public class JpaTargetManagement implements TargetManagement {
final JpaTargetMetadata matadata = targetMetadataRepository.save(updatedMetadata); final JpaTargetMetadata matadata = targetMetadataRepository.save(updatedMetadata);
// target update event is set to ignore "lastModifiedAt" field so it is // target update event is set to ignore "lastModifiedAt" field so it is
// not send automatically within the touch() method // not send automatically within the touch() method
eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId())); eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId()));
return matadata; return matadata;
} }
@@ -252,10 +252,10 @@ public class JpaTargetManagement implements TargetManagement {
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key)); .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key));
final JpaTarget target = touch(controllerId); final JpaTarget target = touch(controllerId);
targetMetadataRepository.delete(metadata.getId()); targetMetadataRepository.deleteById(metadata.getId());
// target update event is set to ignore "lastModifiedAt" field so it is // target update event is set to ignore "lastModifiedAt" field so it is
// not send automatically within the touch() method // not send automatically within the touch() method
eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId())); eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId()));
} }
@Override @Override
@@ -294,7 +294,8 @@ public class JpaTargetManagement implements TargetManagement {
public Optional<TargetMetadata> getMetaDataByControllerId(final String controllerId, final String key) { public Optional<TargetMetadata> getMetaDataByControllerId(final String controllerId, final String key) {
final Long targetId = getByControllerIdAndThrowIfNotFound(controllerId).getId(); final Long targetId = getByControllerIdAndThrowIfNotFound(controllerId).getId();
return Optional.ofNullable(targetMetadataRepository.findOne(new TargetMetadataCompositeKey(targetId, key))); return targetMetadataRepository.findById(new TargetMetadataCompositeKey(targetId, key))
.map(t -> (TargetMetadata) t);
} }
@Override @Override
@@ -344,7 +345,7 @@ public class JpaTargetManagement implements TargetManagement {
@Retryable(include = { @Retryable(include = {
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
public void delete(final Collection<Long> targetIDs) { public void delete(final Collection<Long> targetIDs) {
final List<JpaTarget> targets = targetRepository.findAll(targetIDs); final List<JpaTarget> targets = targetRepository.findAllById(targetIDs);
if (targets.size() < targetIDs.size()) { if (targets.size() < targetIDs.size()) {
throw new EntityNotFoundException(Target.class, targetIDs, throw new EntityNotFoundException(Target.class, targetIDs,
@@ -356,7 +357,7 @@ public class JpaTargetManagement implements TargetManagement {
afterCommit.afterCommit(() -> targets.forEach(target -> eventPublisher.publishEvent( afterCommit.afterCommit(() -> targets.forEach(target -> eventPublisher.publishEvent(
new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(),
Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null), Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null),
JpaTarget.class.getName(), applicationContext.getId())))); JpaTarget.class.getName(), bus.getId()))));
} }
@Override @Override
@@ -366,7 +367,7 @@ public class JpaTargetManagement implements TargetManagement {
public void deleteByControllerID(final String controllerID) { public void deleteByControllerID(final String controllerID) {
final Target target = getByControllerIdAndThrowIfNotFound(controllerID); final Target target = getByControllerIdAndThrowIfNotFound(controllerID);
targetRepository.delete(target.getId()); targetRepository.deleteById(target.getId());
} }
@Override @Override
@@ -394,7 +395,7 @@ public class JpaTargetManagement implements TargetManagement {
} }
private void throwEntityNotFoundIfDsDoesNotExist(final Long distributionSetID) { private void throwEntityNotFoundIfDsDoesNotExist(final Long distributionSetID) {
if (!distributionSetRepository.exists(distributionSetID)) { if (!distributionSetRepository.existsById(distributionSetID)) {
throw new EntityNotFoundException(DistributionSet.class, distributionSetID); throw new EntityNotFoundException(DistributionSet.class, distributionSetID);
} }
} }
@@ -452,7 +453,7 @@ public class JpaTargetManagement implements TargetManagement {
private List<Specification<JpaTarget>> buildSpecificationList(final FilterParams filterParams) { private List<Specification<JpaTarget>> buildSpecificationList(final FilterParams filterParams) {
final List<Specification<JpaTarget>> specList = new ArrayList<>(); final List<Specification<JpaTarget>> specList = new ArrayList<>();
if (filterParams.getFilterByStatus() != null && !filterParams.getFilterByStatus().isEmpty()) { if ((filterParams.getFilterByStatus() != null) && !filterParams.getFilterByStatus().isEmpty()) {
specList.add(TargetSpecifications.hasTargetUpdateStatus(filterParams.getFilterByStatus())); specList.add(TargetSpecifications.hasTargetUpdateStatus(filterParams.getFilterByStatus()));
} }
if (filterParams.getOverdueState() != null) { if (filterParams.getOverdueState() != null) {
@@ -475,8 +476,8 @@ public class JpaTargetManagement implements TargetManagement {
} }
private static boolean isHasTagsFilterActive(final FilterParams filterParams) { private static boolean isHasTagsFilterActive(final FilterParams filterParams) {
return filterParams.getSelectTargetWithNoTag() != null && (filterParams.getSelectTargetWithNoTag() return ((filterParams.getSelectTargetWithNoTag() != null) && filterParams.getSelectTargetWithNoTag())
|| (filterParams.getFilterByTagNames() != null && filterParams.getFilterByTagNames().length > 0)); || ((filterParams.getFilterByTagNames() != null) && (filterParams.getFilterByTagNames().length > 0));
} }
private Slice<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<JpaTarget>> specList) { private Slice<Target> findByCriteriaAPI(final Pageable pageable, final List<Specification<JpaTarget>> specList) {
@@ -617,7 +618,7 @@ public class JpaTargetManagement implements TargetManagement {
// index of the array and // index of the array and
// the 2nd contains the selectCase int value. // the 2nd contains the selectCase int value.
final int pageSize = pageable.getPageSize(); final int pageSize = pageable.getPageSize();
final List<JpaTarget> resultList = entityManager.createQuery(query).setFirstResult(pageable.getOffset()) final List<JpaTarget> resultList = entityManager.createQuery(query).setFirstResult((int) pageable.getOffset())
.setMaxResults(pageSize + 1).getResultList(); .setMaxResults(pageSize + 1).getResultList();
final boolean hasNext = resultList.size() > pageSize; final boolean hasNext = resultList.size() > pageSize;
return new SliceImpl<>(Collections.unmodifiableList(resultList), pageable, hasNext); return new SliceImpl<>(Collections.unmodifiableList(resultList), pageable, hasNext);
@@ -676,7 +677,7 @@ public class JpaTargetManagement implements TargetManagement {
@Override @Override
public Page<Target> findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) { public Page<Target> findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) {
if (!rolloutGroupRepository.exists(group)) { if (!rolloutGroupRepository.existsById(group)) {
throw new EntityNotFoundException(RolloutGroup.class, group); throw new EntityNotFoundException(RolloutGroup.class, group);
} }
@@ -733,7 +734,7 @@ public class JpaTargetManagement implements TargetManagement {
} }
private void throwEntityNotFoundExceptionIfTagDoesNotExist(final Long tagId) { private void throwEntityNotFoundExceptionIfTagDoesNotExist(final Long tagId) {
if (!targetTagRepository.exists(tagId)) { if (!targetTagRepository.existsById(tagId)) {
throw new EntityNotFoundException(TargetTag.class, tagId); throw new EntityNotFoundException(TargetTag.class, tagId);
} }
} }
@@ -773,12 +774,12 @@ public class JpaTargetManagement implements TargetManagement {
@Override @Override
public Optional<Target> get(final long id) { public Optional<Target> get(final long id) {
return Optional.ofNullable(targetRepository.findOne(id)); return targetRepository.findById(id).map(t -> (Target) t);
} }
@Override @Override
public List<Target> get(final Collection<Long> ids) { public List<Target> get(final Collection<Long> ids) {
return Collections.unmodifiableList(targetRepository.findAll(ids)); return Collections.unmodifiableList(targetRepository.findAllById(ids));
} }
@Override @Override
@@ -796,7 +797,7 @@ public class JpaTargetManagement implements TargetManagement {
eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class.getName(), applicationContext.getId())); JpaTarget.class.getName(), bus.getId()));
} }
@Override @Override
@@ -806,4 +807,14 @@ public class JpaTargetManagement implements TargetManagement {
return target.isRequestControllerAttributes(); return target.isRequestControllerAttributes();
} }
@Override
public boolean existsByControllerId(final String controllerId) {
return targetRepository.existsByControllerId(controllerId);
}
@Override
public Page<Target> findByControllerAttributesRequested(final Pageable pageReq) {
return targetRepository.findByRequestControllerAttributesIsTrue(pageReq);
}
} }

View File

@@ -138,7 +138,7 @@ public class JpaTargetTagManagement implements TargetTagManagement {
@Override @Override
public Optional<TargetTag> get(final long id) { public Optional<TargetTag> get(final long id) {
return Optional.ofNullable(targetTagRepository.findOne(id)); return targetTagRepository.findById(id).map(tt -> (TargetTag) tt);
} }
@Override @Override

View File

@@ -103,7 +103,7 @@ public class NoCountPagingRepository {
@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((int) pageable.getOffset());
query.setMaxResults(pageable.getPageSize()); query.setMaxResults(pageable.getPageSize());
final List<T> content = query.getResultList(); final List<T> content = query.getResultList();

View File

@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -43,10 +43,10 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
OfflineDsAssignmentStrategy(final TargetRepository targetRepository, OfflineDsAssignmentStrategy(final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final ActionRepository actionRepository, final BusProperties bus, final ActionRepository actionRepository,
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) {
super(targetRepository, afterCommit, eventPublisher, applicationContext, actionRepository, super(targetRepository, afterCommit, eventPublisher, bus, actionRepository, actionStatusRepository,
actionStatusRepository, quotaManagement); quotaManagement);
} }
@Override @Override

View File

@@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.springframework.context.ApplicationContext; import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -41,10 +41,10 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
OnlineDsAssignmentStrategy(final TargetRepository targetRepository, OnlineDsAssignmentStrategy(final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final ActionRepository actionRepository, final BusProperties bus, final ActionRepository actionRepository,
final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) {
super(targetRepository, afterCommit, eventPublisher, applicationContext, actionRepository, super(targetRepository, afterCommit, eventPublisher, bus, actionRepository, actionStatusRepository,
actionStatusRepository, quotaManagement); quotaManagement);
} }
@Override @Override

View File

@@ -63,6 +63,7 @@ import org.eclipse.hawkbit.repository.jpa.builder.JpaSoftwareModuleMetadataBuild
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetFilterQueryBuilder; import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetFilterQueryBuilder;
import org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager; import org.eclipse.hawkbit.repository.jpa.configuration.MultiTenantJpaTransactionManager;
import org.eclipse.hawkbit.repository.jpa.event.JpaEventEntityManager; import org.eclipse.hawkbit.repository.jpa.event.JpaEventEntityManager;
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitDefaultServiceExecutor;
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder;
@@ -70,6 +71,10 @@ import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityTokenGeneratorHol
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder;
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantAwareHolder; import org.eclipse.hawkbit.repository.jpa.model.helper.TenantAwareHolder;
import org.eclipse.hawkbit.repository.jpa.rollout.RolloutScheduler; import org.eclipse.hawkbit.repository.jpa.rollout.RolloutScheduler;
import org.eclipse.hawkbit.repository.jpa.rollout.condition.PauseRolloutGroupAction;
import org.eclipse.hawkbit.repository.jpa.rollout.condition.StartNextGroupRolloutGroupSuccessAction;
import org.eclipse.hawkbit.repository.jpa.rollout.condition.ThresholdRolloutGroupErrorCondition;
import org.eclipse.hawkbit.repository.jpa.rollout.condition.ThresholdRolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParserValidationOracle; import org.eclipse.hawkbit.repository.jpa.rsql.RsqlParserValidationOracle;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
@@ -87,16 +92,18 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.persistence.config.PersistenceUnitProperties; import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.orm.jpa.EntityScan; import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@@ -123,23 +130,71 @@ import com.google.common.collect.Maps;
* General configuration for hawkBit's Repository. * General configuration for hawkBit's Repository.
* *
*/ */
@EnableJpaRepositories(basePackages = { "org.eclipse.hawkbit.repository.jpa" }) @EnableJpaRepositories("org.eclipse.hawkbit.repository.jpa")
@EnableTransactionManagement @EnableTransactionManagement
@EnableJpaAuditing @EnableJpaAuditing
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@Configuration @Configuration
@ComponentScan
@EnableScheduling @EnableScheduling
@EnableRetry @EnableRetry
@EntityScan("org.eclipse.hawkbit.repository.jpa.model") @EntityScan("org.eclipse.hawkbit.repository.jpa.model")
@PropertySource("classpath:/hawkbit-jpa-defaults.properties") @PropertySource("classpath:/hawkbit-jpa-defaults.properties")
@Import({ RepositoryDefaultConfiguration.class }) @Import({ RepositoryDefaultConfiguration.class, DataSourceAutoConfiguration.class,
SystemManagementCacheKeyGenerator.class })
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
@Autowired protected RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties properties,
RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties jpaProperties, final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) { final ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
super(dataSource, jpaProperties, jtaTransactionManagerProvider); super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers);
}
@Bean
@ConditionalOnMissingBean
PauseRolloutGroupAction pauseRolloutGroupAction(final RolloutManagement rolloutManagement,
final RolloutGroupRepository rolloutGroupRepository, final SystemSecurityContext systemSecurityContext) {
return new PauseRolloutGroupAction(rolloutManagement, rolloutGroupRepository, systemSecurityContext);
}
@Bean
@ConditionalOnMissingBean
StartNextGroupRolloutGroupSuccessAction startNextRolloutGroupAction(
final RolloutGroupRepository rolloutGroupRepository, final DeploymentManagement deploymentManagement,
final SystemSecurityContext systemSecurityContext) {
return new StartNextGroupRolloutGroupSuccessAction(rolloutGroupRepository, deploymentManagement,
systemSecurityContext);
}
@Bean
@ConditionalOnMissingBean
ThresholdRolloutGroupErrorCondition thresholdRolloutGroupErrorCondition(final ActionRepository actionRepository) {
return new ThresholdRolloutGroupErrorCondition(actionRepository);
}
@Bean
@ConditionalOnMissingBean
ThresholdRolloutGroupSuccessCondition thresholdRolloutGroupSuccessCondition(
final ActionRepository actionRepository) {
return new ThresholdRolloutGroupSuccessCondition(actionRepository);
}
@Bean
@ConditionalOnMissingBean
SystemManagementCacheKeyGenerator systemManagementCacheKeyGenerator() {
return new SystemManagementCacheKeyGenerator();
}
@Bean
@ConditionalOnMissingBean
AfterTransactionCommitDefaultServiceExecutor afterTransactionCommitDefaultServiceExecutor() {
return new AfterTransactionCommitDefaultServiceExecutor();
}
@Bean
@ConditionalOnMissingBean
NoCountPagingRepository noCountPagingRepository() {
return new NoCountPagingRepository();
} }
@Bean @Bean
@@ -163,7 +218,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
ApplicationEventFilter applicationEventFilter(final RepositoryProperties repositoryProperties) { ApplicationEventFilter applicationEventFilter(final RepositoryProperties repositoryProperties) {
return e -> (e instanceof TargetPollEvent) && !repositoryProperties.isPublishTargetPollEvent(); return e -> e instanceof TargetPollEvent && !repositoryProperties.isPublishTargetPollEvent();
} }
/** /**
@@ -389,16 +444,16 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
final DistributionSetMetadataRepository distributionSetMetadataRepository, final DistributionSetMetadataRepository distributionSetMetadataRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository, final TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository,
final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher, final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher,
final ApplicationContext applicationContext, final TenantAware tenantAware, final BusProperties bus, final TenantAware tenantAware,
final VirtualPropertyReplacer virtualPropertyReplacer, final VirtualPropertyReplacer virtualPropertyReplacer,
final SoftwareModuleRepository softwareModuleRepository, final SoftwareModuleRepository softwareModuleRepository,
final DistributionSetTagRepository distributionSetTagRepository, final DistributionSetTagRepository distributionSetTagRepository,
final AfterTransactionCommitExecutor afterCommit, final JpaProperties properties) { final AfterTransactionCommitExecutor afterCommit, final JpaProperties properties) {
return new JpaDistributionSetManagement(entityManager, distributionSetRepository, distributionSetTagManagement, return new JpaDistributionSetManagement(entityManager, distributionSetRepository, distributionSetTagManagement,
systemManagement, distributionSetTypeManagement, quotaManagement, distributionSetMetadataRepository, systemManagement, distributionSetTypeManagement, quotaManagement, distributionSetMetadataRepository,
targetFilterQueryRepository, actionRepository, criteriaNoCountDao, eventPublisher, applicationContext, targetFilterQueryRepository, actionRepository, criteriaNoCountDao, eventPublisher, bus, tenantAware,
tenantAware, virtualPropertyReplacer, softwareModuleRepository, distributionSetTagRepository, virtualPropertyReplacer, softwareModuleRepository, distributionSetTagRepository, afterCommit,
afterCommit, properties.getDatabase()); properties.getDatabase());
} }
@@ -455,13 +510,13 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
final DistributionSetRepository distributionSetRepository, final DistributionSetRepository distributionSetRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao, final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao,
final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, final ApplicationEventPublisher eventPublisher, final BusProperties bus, final TenantAware tenantAware,
final TenantAware tenantAware, final AfterTransactionCommitExecutor afterCommit, final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer,
final VirtualPropertyReplacer virtualPropertyReplacer, final JpaProperties properties) { final JpaProperties properties) {
return new JpaTargetManagement(entityManager, quotaManagement, targetRepository, targetMetadataRepository, return new JpaTargetManagement(entityManager, quotaManagement, targetRepository, targetMetadataRepository,
rolloutGroupRepository, distributionSetRepository, targetFilterQueryRepository, targetTagRepository, rolloutGroupRepository, distributionSetRepository, targetFilterQueryRepository, targetTagRepository,
criteriaNoCountDao, eventPublisher, applicationContext, tenantAware, afterCommit, criteriaNoCountDao, eventPublisher, bus, tenantAware, afterCommit, virtualPropertyReplacer,
virtualPropertyReplacer, properties.getDatabase()); properties.getDatabase());
} }
/** /**
@@ -565,12 +620,13 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
RolloutManagement rolloutManagement(final TargetManagement targetManagement, RolloutManagement rolloutManagement(final TargetManagement targetManagement,
final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement, final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement,
final DistributionSetManagement distributionSetManagement, final ApplicationContext context, final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
final ApplicationEventPublisher eventPublisher, final VirtualPropertyReplacer virtualPropertyReplacer, final BusProperties bus, final ApplicationEventPublisher eventPublisher,
final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final JpaProperties properties, final RolloutApprovalStrategy rolloutApprovalStrategy) { final TenantAware tenantAware, final LockRegistry lockRegistry, final JpaProperties properties,
final RolloutApprovalStrategy rolloutApprovalStrategy) {
return new JpaRolloutManagement(targetManagement, deploymentManagement, rolloutGroupManagement, return new JpaRolloutManagement(targetManagement, deploymentManagement, rolloutGroupManagement,
distributionSetManagement, context, eventPublisher, virtualPropertyReplacer, txManager, tenantAware, distributionSetManagement, context, bus, eventPublisher, virtualPropertyReplacer, txManager,
lockRegistry, properties.getDatabase(), rolloutApprovalStrategy); tenantAware, lockRegistry, properties.getDatabase(), rolloutApprovalStrategy);
} }
/** /**
@@ -614,15 +670,15 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
final ActionRepository actionRepository, final DistributionSetRepository distributionSetRepository, final ActionRepository actionRepository, final DistributionSetRepository distributionSetRepository,
final TargetRepository targetRepository, final ActionStatusRepository actionStatusRepository, final TargetRepository targetRepository, final ActionStatusRepository actionStatusRepository,
final TargetManagement targetManagement, final AuditorAware<String> auditorProvider, final TargetManagement targetManagement, final AuditorAware<String> auditorProvider,
final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, final ApplicationEventPublisher eventPublisher, final BusProperties bus,
final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer, final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer,
final PlatformTransactionManager txManager, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware,
final JpaProperties properties) { final JpaProperties properties) {
return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetRepository, targetRepository, return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetRepository, targetRepository,
actionStatusRepository, targetManagement, auditorProvider, eventPublisher, applicationContext, actionStatusRepository, targetManagement, auditorProvider, eventPublisher, bus, afterCommit,
afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement, quotaManagement, virtualPropertyReplacer, txManager, tenantConfigurationManagement, quotaManagement,
systemSecurityContext, tenantAware, properties.getDatabase()); systemSecurityContext, tenantAware, properties.getDatabase());
} }

View File

@@ -84,5 +84,5 @@ public interface SoftwareModuleTypeRepository
@Override @Override
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
@Query("SELECT d FROM JpaSoftwareModuleType d WHERE d.id IN ?1") @Query("SELECT d FROM JpaSoftwareModuleType d WHERE d.id IN ?1")
List<JpaSoftwareModuleType> findAll(Iterable<Long> ids); List<JpaSoftwareModuleType> findAllById(Iterable<Long> ids);
} }

View File

@@ -15,13 +15,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
/** /**
* Implementation of {@link CurrentTenantCacheKeyGenerator}. * Implementation of {@link CurrentTenantCacheKeyGenerator}.
* *
*/ */
@Service
public class SystemManagementCacheKeyGenerator implements CurrentTenantCacheKeyGenerator { public class SystemManagementCacheKeyGenerator implements CurrentTenantCacheKeyGenerator {
@Autowired @Autowired

View File

@@ -177,6 +177,18 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
*/ */
Page<Target> findByAssignedDistributionSetId(Pageable pageable, Long setID); Page<Target> findByAssignedDistributionSetId(Pageable pageable, Long setID);
/**
* retrieves {@link Target}s where
* {@link JpaTarget#isRequestControllerAttributes()}.
*
* @param pageReq
* page parameter
*
* @return the found {@link Target}s
*
*/
Page<Target> findByRequestControllerAttributesIsTrue(Pageable pageable);
/** /**
* Counts number of targets with given distribution set Id. * Counts number of targets with given distribution set Id.
* *
@@ -209,7 +221,7 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
@Override @Override
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
@Query("SELECT t FROM JpaTarget t WHERE t.id IN ?1") @Query("SELECT t FROM JpaTarget t WHERE t.id IN ?1")
List<JpaTarget> findAll(Iterable<Long> ids); List<JpaTarget> findAllById(Iterable<Long> ids);
/** /**
* *

View File

@@ -102,7 +102,7 @@ public class AutoAssignChecker {
public void check() { public void check() {
LOGGER.debug("Auto assigned check call"); LOGGER.debug("Auto assigned check call");
final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE); final PageRequest pageRequest = PageRequest.of(0, PAGE_SIZE);
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
.findWithAutoAssignDS(pageRequest); .findWithAutoAssignDS(pageRequest);
@@ -176,7 +176,7 @@ public class AutoAssignChecker {
private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId, private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId,
final int count) { final int count) {
final Page<Target> targets = targetManagement final Page<Target> targets = targetManagement
.findByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery); .findByTargetFilterQueryAndNonDS(PageRequest.of(0, count), dsId, targetFilterQuery);
return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(), return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(),
Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList()); Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList());

View File

@@ -13,7 +13,6 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionSynchronizationAdapter; import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -22,7 +21,6 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* A Service which calls register runnable. This runnables will executed after a * A Service which calls register runnable. This runnables will executed after a
* successful spring transaction commit.The class is thread safe. * successful spring transaction commit.The class is thread safe.
*/ */
@Service
public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter
implements AfterTransactionCommitExecutor { implements AfterTransactionCommitExecutor {
private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class); private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class);

View File

@@ -77,8 +77,8 @@ public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMe
return defaultDsType; return defaultDsType;
} }
public void setDefaultDsType(final DistributionSetType defaultDsType) { public void setDefaultDsType(final JpaDistributionSetType defaultDsType) {
this.defaultDsType = (JpaDistributionSetType) defaultDsType; this.defaultDsType = defaultDsType;
} }
@Override @Override

View File

@@ -15,24 +15,25 @@ 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.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/** /**
* Error action evaluator which pauses the whole {@link Rollout} and sets the * Error action evaluator which pauses the whole {@link Rollout} and sets the
* current {@link RolloutGroup} to error. * current {@link RolloutGroup} to error.
*/ */
@Component("pauseRolloutGroupAction")
public class PauseRolloutGroupAction implements RolloutGroupActionEvaluator { public class PauseRolloutGroupAction implements RolloutGroupActionEvaluator {
@Autowired private final RolloutManagement rolloutManagement;
private RolloutManagement rolloutManagement;
@Autowired private final RolloutGroupRepository rolloutGroupRepository;
private RolloutGroupRepository rolloutGroupRepository;
@Autowired private final SystemSecurityContext systemSecurityContext;
private SystemSecurityContext systemSecurityContext;
public PauseRolloutGroupAction(final RolloutManagement rolloutManagement,
final RolloutGroupRepository rolloutGroupRepository, final SystemSecurityContext systemSecurityContext) {
this.rolloutManagement = rolloutManagement;
this.rolloutGroupRepository = rolloutGroupRepository;
this.systemSecurityContext = systemSecurityContext;
}
@Override @Override
public boolean verifyExpression(final String expression) { public boolean verifyExpression(final String expression) {

View File

@@ -19,25 +19,26 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
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.stereotype.Component;
/** /**
* Success action which starts the next following {@link RolloutGroup}. * Success action which starts the next following {@link RolloutGroup}.
*/ */
@Component("startNextRolloutGroupAction")
public class StartNextGroupRolloutGroupSuccessAction implements RolloutGroupActionEvaluator { public class StartNextGroupRolloutGroupSuccessAction implements RolloutGroupActionEvaluator {
private static final Logger logger = LoggerFactory.getLogger(StartNextGroupRolloutGroupSuccessAction.class); private static final Logger logger = LoggerFactory.getLogger(StartNextGroupRolloutGroupSuccessAction.class);
@Autowired private final RolloutGroupRepository rolloutGroupRepository;
private RolloutGroupRepository rolloutGroupRepository;
@Autowired private final DeploymentManagement deploymentManagement;
private DeploymentManagement deploymentManagement;
@Autowired private final SystemSecurityContext systemSecurityContext;
private SystemSecurityContext systemSecurityContext;
public StartNextGroupRolloutGroupSuccessAction(final RolloutGroupRepository rolloutGroupRepository,
final DeploymentManagement deploymentManagement, final SystemSecurityContext systemSecurityContext) {
this.rolloutGroupRepository = rolloutGroupRepository;
this.deploymentManagement = deploymentManagement;
this.systemSecurityContext = systemSecurityContext;
}
@Override @Override
public boolean verifyExpression(final String expression) { public boolean verifyExpression(final String expression) {

View File

@@ -16,19 +16,19 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
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.stereotype.Component;
/** /**
* *
*/ */
@Component("thresholdRolloutGroupErrorCondition")
public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator { public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator {
private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class); private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class);
@Autowired private final ActionRepository actionRepository;
private ActionRepository actionRepository;
public ThresholdRolloutGroupErrorCondition(final ActionRepository actionRepository) {
this.actionRepository = actionRepository;
}
@Override @Override
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {

View File

@@ -14,19 +14,19 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
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.stereotype.Component;
/** /**
* Threshold to calculate if rollout group success condition is reached and the * Threshold to calculate if rollout group success condition is reached and the
* next rollout group can get started. * next rollout group can get started.
*/ */
@Component("thresholdRolloutGroupSuccessCondition")
public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator { public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator {
private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupSuccessCondition.class); private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupSuccessCondition.class);
@Autowired private final ActionRepository actionRepository;
private ActionRepository actionRepository;
public ThresholdRolloutGroupSuccessCondition(final ActionRepository actionRepository) {
this.actionRepository = actionRepository;
}
@Override @Override
public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) {

View File

@@ -159,6 +159,8 @@ public final class RSQLUtility {
private static final class RSQLSpecification<A extends Enum<A> & FieldNameProvider, T> implements Specification<T> { private static final class RSQLSpecification<A extends Enum<A> & FieldNameProvider, T> implements Specification<T> {
private static final long serialVersionUID = 1L;
private final String rsql; private final String rsql;
private final Class<A> enumType; private final Class<A> enumType;
private final VirtualPropertyReplacer virtualPropertyReplacer; private final VirtualPropertyReplacer virtualPropertyReplacer;

View File

@@ -76,7 +76,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
context.setSyntaxErrorContext(errorContext); context.setSyntaxErrorContext(errorContext);
try { try {
targetManagement.findByRsql(new PageRequest(0, 1), rsqlQuery); targetManagement.findByRsql(PageRequest.of(0, 1), rsqlQuery);
context.setSyntaxError(false); context.setSyntaxError(false);
suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery)); suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery));
} catch (final RSQLParameterSyntaxException | RSQLParserException ex) { } catch (final RSQLParameterSyntaxException | RSQLParserException ex) {

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.specifications;
import java.util.List; import java.util.List;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.domain.Specifications;
/** /**
* Helper class to easily combine {@link Specification} instances. * Helper class to easily combine {@link Specification} instances.
@@ -31,11 +30,11 @@ public final class SpecificationsBuilder {
* all specification which will combine * all specification which will combine
* @return <null> if the given specification list is empty * @return <null> if the given specification list is empty
*/ */
public static <T> Specifications<T> combineWithAnd(final List<Specification<T>> specList) { public static <T> Specification<T> combineWithAnd(final List<Specification<T>> specList) {
if (specList.isEmpty()) { if (specList.isEmpty()) {
return null; return null;
} }
Specifications<T> specs = Specifications.where(specList.get(0)); Specification<T> specs = Specification.where(specList.get(0));
for (final Specification<T> specification : specList.subList(1, specList.size())) { for (final Specification<T> specification : specList.subList(1, specList.size())) {
specs = specs.and(specification); specs = specs.and(specification);
} }

View File

@@ -7,6 +7,8 @@
# http://www.eclipse.org/legal/epl-v10.html # http://www.eclipse.org/legal/epl-v10.html
# #
spring.main.allow-bean-definition-overriding=true
### JPA / Datasource - START ### JPA / Datasource - START
spring.jpa.database=H2 spring.jpa.database=H2
spring.jpa.show-sql=false spring.jpa.show-sql=false
@@ -17,8 +19,9 @@ spring.jpa.properties.eclipselink.logging.level=off
spring.datasource.eclipselink.query-results-cache=false spring.datasource.eclipselink.query-results-cache=false
spring.datasource.eclipselink.cache.shared.default=false spring.datasource.eclipselink.cache.shared.default=false
# Flyway DDL # Flyway DDL
flyway.enabled=true spring.flyway.enabled=true
flyway.initOnMigrate=true spring.flyway.init-on-migrate=true
flyway.cleanDisabled=true spring.flyway.clean-disabled=true
flyway.sqlMigrationSuffix=${spring.jpa.database}.sql spring.flyway.sql-migration-suffixes=${spring.jpa.database}.sql
spring.flyway.table=schema_version
### JPA / Datasource - END ### JPA / Datasource - END

View File

@@ -47,7 +47,7 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
final BusJacksonAutoConfiguration autoConfiguration = new BusJacksonAutoConfiguration(); final BusJacksonAutoConfiguration autoConfiguration = new BusJacksonAutoConfiguration();
this.jacksonMessageConverter = autoConfiguration.busJsonConverter(); this.jacksonMessageConverter = autoConfiguration.busJsonConverter(null);
ReflectionTestUtils.setField(jacksonMessageConverter, "packagesToScan", ReflectionTestUtils.setField(jacksonMessageConverter, "packagesToScan",
new String[] { "org.eclipse.hawkbit.repository.event.remote", new String[] { "org.eclipse.hawkbit.repository.event.remote",
ClassUtils.getPackageName(RemoteApplicationEvent.class) }); ClassUtils.getPackageName(RemoteApplicationEvent.class) });

View File

@@ -26,23 +26,25 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
import org.eclipse.hawkbit.repository.test.util.RolloutTestApprovalStrategy; import org.eclipse.hawkbit.repository.test.util.RolloutTestApprovalStrategy;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@SpringApplicationConfiguration(classes = { @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class,
org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration.class }) TestSupportBinderAutoConfiguration.class })
@TestPropertySource(locations = "classpath:/jpa-test.properties") @TestPropertySource(locations = "classpath:/jpa-test.properties")
public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest { public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest {
protected static final String INVALID_TEXT_HTML = "</noscript><br><script>"; protected static final String INVALID_TEXT_HTML = "</noscript><br><script>";
protected static final String NOT_EXIST_ID = "1234"; protected static final String NOT_EXIST_ID = "12345678990";
protected static final long NOT_EXIST_IDL = Long.parseLong(NOT_EXIST_ID); protected static final long NOT_EXIST_IDL = Long.parseLong(NOT_EXIST_ID);
@PersistenceContext @PersistenceContext

View File

@@ -82,8 +82,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
NOT_EXIST_IDL, "xxx", null, null, false, null, artifactSize)), NOT_EXIST_IDL, "xxx", null, null, false, null, artifactSize)),
"SoftwareModule"); "SoftwareModule");
verifyThrownExceptionBy(() -> artifactManagement.create( verifyThrownExceptionBy(
new ArtifactUpload(IOUtils.toInputStream(artifactData, "UTF-8"), 1234L, "xxx", false, artifactSize)), () -> artifactManagement.create(new ArtifactUpload(IOUtils.toInputStream(artifactData, "UTF-8"),
NOT_EXIST_IDL, "xxx", null, null, false, null, artifactSize)),
"SoftwareModule"); "SoftwareModule");
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact"); verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
@@ -120,7 +121,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1); final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1);
createArtifactForSoftwareModule("file11", sm.getId(), artifactSize, inputStream2); createArtifactForSoftwareModule("file11", sm.getId(), artifactSize, inputStream2);
createArtifactForSoftwareModule("file12", sm.getId(), artifactSize, inputStream3); createArtifactForSoftwareModule("file12", sm.getId(), artifactSize, inputStream3);
final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize, inputStream4); final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize,
inputStream4);
assertThat(artifact1).isInstanceOf(Artifact.class); assertThat(artifact1).isInstanceOf(Artifact.class);
assertThat(artifact1.getSoftwareModule().getId()).isEqualTo(sm.getId()); assertThat(artifact1.getSoftwareModule().getId()).isEqualTo(sm.getId());
@@ -152,9 +154,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
final long smID = softwareModuleRepository final long smID = softwareModuleRepository
.save(new JpaSoftwareModule(osType, "smIllegalFilenameTest", "1.0", null, null)).getId(); .save(new JpaSoftwareModule(osType, "smIllegalFilenameTest", "1.0", null, null)).getId();
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(() -> artifactManagement.create( assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
new ArtifactUpload(IOUtils.toInputStream(artifactData, "UTF-8"), smID, illegalFilename, false, () -> artifactManagement.create(new ArtifactUpload(IOUtils.toInputStream(artifactData, "UTF-8"), smID,
artifactSize))); illegalFilename, false, artifactSize)));
assertThat(softwareModuleManagement.get(smID).get().getArtifacts()).hasSize(0); assertThat(softwareModuleManagement.get(smID).get().getArtifacts()).hasSize(0);
} }
@@ -284,7 +286,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
final InputStream inputStream2 = new RandomGeneratedInputStream(artifactSize)) { final InputStream inputStream2 = new RandomGeneratedInputStream(artifactSize)) {
final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1); final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1);
final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize, inputStream2); final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize,
inputStream2);
assertThat(artifactRepository.findAll()).hasSize(2); assertThat(artifactRepository.findAll()).hasSize(2);
@@ -292,16 +295,18 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(artifact2.getId()).isNotNull(); assertThat(artifact2.getId()).isNotNull();
assertThat(((JpaArtifact) artifact1).getSha1Hash()).isNotEqualTo(((JpaArtifact) artifact2).getSha1Hash()); assertThat(((JpaArtifact) artifact1).getSha1Hash()).isNotEqualTo(((JpaArtifact) artifact2).getSha1Hash());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())) assertThat(
.isNotNull(); binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNotNull();
assertThat( assertThat(
binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash())) binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash()))
.isNotNull(); .isNotNull();
artifactManagement.delete(artifact1.getId()); artifactManagement.delete(artifact1.getId());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())) assertThat(
.isNull(); binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNull();
assertThat( assertThat(
binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash())) binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash()))
.isNotNull(); .isNotNull();
@@ -331,22 +336,26 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
try (final InputStream inputStream1 = new ByteArrayInputStream(randomBytes); try (final InputStream inputStream1 = new ByteArrayInputStream(randomBytes);
final InputStream inputStream2 = new ByteArrayInputStream(randomBytes)) { final InputStream inputStream2 = new ByteArrayInputStream(randomBytes)) {
final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1); final Artifact artifact1 = createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1);
final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize, inputStream2); final Artifact artifact2 = createArtifactForSoftwareModule("file2", sm2.getId(), artifactSize,
inputStream2);
assertThat(artifactRepository.findAll()).hasSize(2); assertThat(artifactRepository.findAll()).hasSize(2);
assertThat(artifact1.getId()).isNotNull(); assertThat(artifact1.getId()).isNotNull();
assertThat(artifact2.getId()).isNotNull(); assertThat(artifact2.getId()).isNotNull();
assertThat(((JpaArtifact) artifact1).getSha1Hash()).isEqualTo(((JpaArtifact) artifact2).getSha1Hash()); assertThat(((JpaArtifact) artifact1).getSha1Hash()).isEqualTo(((JpaArtifact) artifact2).getSha1Hash());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())) assertThat(
.isNotNull(); binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNotNull();
artifactManagement.delete(artifact1.getId()); artifactManagement.delete(artifact1.getId());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())) assertThat(
.isNotNull(); binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNotNull();
artifactManagement.delete(artifact2.getId()); artifactManagement.delete(artifact2.getId());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())) assertThat(
.isNull(); binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash()))
.isNull();
} }
} }

View File

@@ -688,8 +688,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// populated; // populated;
final List<JpaTarget> allFoundTargets = targetRepository.findAll(); final List<JpaTarget> allFoundTargets = targetRepository.findAll();
final List<JpaTarget> deployedTargetsFromDB = targetRepository.findAll(deployedTargetIDs); final List<JpaTarget> deployedTargetsFromDB = targetRepository.findAllById(deployedTargetIDs);
final List<JpaTarget> undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs); final List<JpaTarget> undeployedTargetsFromDB = targetRepository.findAllById(undeployedTargetIDs);
// test that number of Targets // test that number of Targets
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).as("number of target is wrong") assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).as("number of target is wrong")
@@ -721,7 +721,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
+ "from target/controller. Expected behaviour is that in case of OK finished update the target will go to " + "from target/controller. Expected behaviour is that in case of OK finished update the target will go to "
+ "IN_SYNC status and installed DS is set to the assigned DS entry.") + "IN_SYNC status and installed DS is set to the assigned DS entry.")
public void assignDistributionSetAndAddFinishedActionStatus() { public void assignDistributionSetAndAddFinishedActionStatus() {
final PageRequest pageRequest = new PageRequest(0, 100, Direction.ASC, ActionStatusFields.ID.getFieldName()); final PageRequest pageRequest = PageRequest.of(0, 100, Direction.ASC, ActionStatusFields.ID.getFieldName());
final DeploymentResult deployResWithDsA = prepareComplexRepo("undep-A-T", 2, "dep-A-T", 4, 1, "dsA"); final DeploymentResult deployResWithDsA = prepareComplexRepo("undep-A-T", 2, "dep-A-T", 4, 1, "dsA");
final DeploymentResult deployResWithDsB = prepareComplexRepo("undep-B-T", 3, "dep-B-T", 5, 1, "dsB"); final DeploymentResult deployResWithDsB = prepareComplexRepo("undep-B-T", 3, "dep-B-T", 5, 1, "dsB");
@@ -815,7 +815,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
+ "if the DS is assigned to a target and a hard delete if the DS is not in use at all.") + "if the DS is assigned to a target and a hard delete if the DS is not in use at all.")
public void deleteDistributionSet() { public void deleteDistributionSet() {
final PageRequest pageRequest = new PageRequest(0, 100, Direction.ASC, "id"); final PageRequest pageRequest = PageRequest.of(0, 100, Direction.ASC, "id");
final String undeployedTargetPrefix = "undep-T"; final String undeployedTargetPrefix = "undep-T";
final int noOfUndeployedTargets = 2; final int noOfUndeployedTargets = 2;

View File

@@ -868,10 +868,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
} }
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds1.getId()); .findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds1.getId());
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds2.getId()); .findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds2.getId());
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10); assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10); assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);

View File

@@ -59,15 +59,12 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0), @ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
@Expect(type = TargetTagUpdatedEvent.class, count = 0) }) @Expect(type = TargetTagUpdatedEvent.class, count = 0) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag");
"DistributionSetTag");
verifyThrownExceptionBy( verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
"DistributionSet"); "DistributionSet");
verifyThrownExceptionBy( verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
"DistributionSetTag"); "DistributionSetTag");
} }
@@ -82,16 +79,11 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13); final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9); final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
final DistributionSetTag tagA = distributionSetTagManagement final DistributionSetTag tagA = distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
.create(entityFactory.tag().create().name("A")); final DistributionSetTag tagB = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
final DistributionSetTag tagB = distributionSetTagManagement final DistributionSetTag tagC = distributionSetTagManagement.create(entityFactory.tag().create().name("C"));
.create(entityFactory.tag().create().name("B")); final DistributionSetTag tagX = distributionSetTagManagement.create(entityFactory.tag().create().name("X"));
final DistributionSetTag tagC = distributionSetTagManagement final DistributionSetTag tagY = distributionSetTagManagement.create(entityFactory.tag().create().name("Y"));
.create(entityFactory.tag().create().name("C"));
final DistributionSetTag tagX = distributionSetTagManagement
.create(entityFactory.tag().create().name("X"));
final DistributionSetTag tagY = distributionSetTagManagement
.create(entityFactory.tag().create().name("Y"));
toggleTagAssignment(dsAs, tagA); toggleTagAssignment(dsAs, tagA);
toggleTagAssignment(dsBs, tagB); toggleTagAssignment(dsBs, tagB);
@@ -210,8 +202,8 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
assertThat(result.getAssigned()).isEqualTo(0); assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedEntity()).isEmpty(); assertThat(result.getAssignedEntity()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40); assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.get( assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList()))); .get(concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
assertThat(result.getDistributionSetTag()).isEqualTo(tag); assertThat(result.getDistributionSetTag()).isEqualTo(tag);
} }
@@ -219,15 +211,15 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Ensures that a created tag is persisted in the repository as defined.") @Description("Ensures that a created tag is persisted in the repository as defined.")
public void createDistributionSetTag() { public void createDistributionSetTag() {
final Tag tag = distributionSetTagManagement.create( final Tag tag = distributionSetTagManagement
entityFactory.tag().create().name("kai1").description("kai2").colour("colour")); .create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found") assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
.isEqualTo("kai2"); .isEqualTo("kai2");
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found") assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
.isEqualTo("colour"); .isEqualTo("colour");
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour()) assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
.as("wrong tag found").isEqualTo("colour"); .isEqualTo("colour");
} }
@Test @Test
@@ -238,7 +230,7 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
final DistributionSetTag toDelete = tags.iterator().next(); final DistributionSetTag toDelete = tags.iterator().next();
for (final DistributionSet set : distributionSetRepository.findAll()) { for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetRepository.findOne(set.getId()).getTags()).as("Wrong tag found") assertThat(distributionSetRepository.findById(set.getId()).get().getTags()).as("Wrong tag found")
.contains(toDelete); .contains(toDelete);
} }
@@ -246,12 +238,13 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
distributionSetTagManagement.delete(tags.iterator().next().getName()); distributionSetTagManagement.delete(tags.iterator().next().getName());
// check // check
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull(); assertThat(distributionSetTagRepository.findById(toDelete.getId())).as("Deleted tag should be null")
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()) .isNotPresent();
.as("Wrong size of tags after deletion").hasSize(19); assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of tags after deletion")
.hasSize(19);
for (final DistributionSet set : distributionSetRepository.findAll()) { for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetRepository.findOne(set.getId()).getTags()).as("Wrong found tags") assertThat(distributionSetRepository.findById(set.getId()).get().getTags()).as("Wrong found tags")
.doesNotContain(toDelete); .doesNotContain(toDelete);
} }
} }
@@ -272,8 +265,7 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).") @Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
public void failedDuplicateDsTagNameExceptionAfterUpdate() { public void failedDuplicateDsTagNameExceptionAfterUpdate() {
distributionSetTagManagement.create(entityFactory.tag().create().name("A")); distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
final DistributionSetTag tag = distributionSetTagManagement final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
.create(entityFactory.tag().create().name("B"));
try { try {
distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A")); distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
@@ -294,14 +286,13 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
final DistributionSetTag savedAssigned = tags.iterator().next(); final DistributionSetTag savedAssigned = tags.iterator().next();
// persist // persist
distributionSetTagManagement distributionSetTagManagement.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
// check data // check data
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()) assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of ds tags")
.as("Wrong size of ds tags").hasSize(tags.size()); .hasSize(tags.size());
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found") assertThat(distributionSetTagRepository.findById(savedAssigned.getId()).get().getName())
.isEqualTo("test123"); .as("Wrong ds tag found").isEqualTo("test123");
} }
@Test @Test

View File

@@ -72,7 +72,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)), testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)),
"SoftwareModuleType"); "SoftwareModuleType");
verifyThrownExceptionBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(1234L, verifyThrownExceptionBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(NOT_EXIST_IDL,
Arrays.asList(osType.getId())), "DistributionSetType"); Arrays.asList(osType.getId())), "DistributionSetType");
verifyThrownExceptionBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes( verifyThrownExceptionBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(
testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)), testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)),

View File

@@ -8,6 +8,8 @@
*/ */
package org.eclipse.hawkbit.repository.jpa; package org.eclipse.hawkbit.repository.jpa;
import static org.assertj.core.api.Assertions.assertThat;
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent;
@@ -20,8 +22,6 @@ import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.junit.Test; import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;

View File

@@ -17,6 +17,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -1547,41 +1548,40 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
} }
@Test @Test
@Description("Creating a rollout with approval role or approval engine disabled results in the rollout being in " + @Description("Creating a rollout with approval role or approval engine disabled results in the rollout being in "
"READY state.") + "READY state.")
public void createdRolloutWithApprovalRoleOrApprovalDisabledTransitionsToReadyState() { public void createdRolloutWithApprovalRoleOrApprovalDisabledTransitionsToReadyState() {
approvalStrategy.setApprovalNeeded(false); approvalStrategy.setApprovalNeeded(false);
final String successCondition = "50"; final String successCondition = "50";
final String errorCondition = "80"; final String errorCondition = "80";
final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 5, successCondition,
5, successCondition, errorCondition); errorCondition);
assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.READY); assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.READY);
} }
@Test @Test
@Description("Creating a rollout without approver role and approval enabled leads to transition to " + @Description("Creating a rollout without approver role and approval enabled leads to transition to "
"WAITING_FOR_APPROVAL state.") + "WAITING_FOR_APPROVAL state.")
public void createdRolloutWithoutApprovalRoleTransitionsToWaitingForApprovalState() { public void createdRolloutWithoutApprovalRoleTransitionsToWaitingForApprovalState() {
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
final String successCondition = "50"; final String successCondition = "50";
final String errorCondition = "80"; final String errorCondition = "80";
final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 5, successCondition,
5, successCondition, errorCondition); errorCondition);
assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL); assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL);
} }
@Test @Test
@Description("Approving a rollout leads to transition to READY state.") @Description("Approving a rollout leads to transition to READY state.")
public void approvedRolloutTransitionsToReadyState() { public void approvedRolloutTransitionsToReadyState() {
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
final String successCondition = "50"; final String successCondition = "50";
final String errorCondition = "80"; final String errorCondition = "80";
final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 5, successCondition,
5, successCondition, errorCondition); errorCondition);
assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL); assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL);
rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED); rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED);
final Rollout resultingRollout = rolloutRepository.findOne(rollout.getId()); final Rollout resultingRollout = rolloutRepository.findById(rollout.getId()).get();
assertThat(resultingRollout.getStatus()).isEqualTo(Rollout.RolloutStatus.READY); assertThat(resultingRollout.getStatus()).isEqualTo(Rollout.RolloutStatus.READY);
} }
@@ -1591,11 +1591,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
final String successCondition = "50"; final String successCondition = "50";
final String errorCondition = "80"; final String errorCondition = "80";
final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, final Rollout rollout = createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 5, successCondition,
5, successCondition, errorCondition); errorCondition);
assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL); assertThat(rollout.getStatus()).isEqualTo(Rollout.RolloutStatus.WAITING_FOR_APPROVAL);
rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.DENIED); rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.DENIED);
final Rollout resultingRollout = rolloutRepository.findOne(rollout.getId()); final Rollout resultingRollout = rolloutRepository.findById(rollout.getId()).get();
assertThat(resultingRollout.getStatus()).isEqualTo(RolloutStatus.APPROVAL_DENIED); assertThat(resultingRollout.getStatus()).isEqualTo(RolloutStatus.APPROVAL_DENIED);
} }
@@ -1622,8 +1622,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts(); rolloutManagement.handleRollouts();
// verify // verify
final JpaRollout deletedRollout = rolloutRepository.findOne(createdRollout.getId()); final Optional<JpaRollout> deletedRollout = rolloutRepository.findById(createdRollout.getId());
assertThat(deletedRollout).isNull(); assertThat(deletedRollout).isNotPresent();
assertThat(rolloutGroupRepository.count()).isZero(); assertThat(rolloutGroupRepository.count()).isZero();
assertThat(rolloutTargetGroupRepository.count()).isZero(); assertThat(rolloutTargetGroupRepository.count()).isZero();
} }
@@ -1663,7 +1663,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts(); rolloutManagement.handleRollouts();
// verify // verify
final JpaRollout deletedRollout = rolloutRepository.findOne(createdRollout.getId()); final JpaRollout deletedRollout = rolloutRepository.findById(createdRollout.getId()).get();
assertThat(deletedRollout).isNotNull(); assertThat(deletedRollout).isNotNull();
assertThat(deletedRollout.getStatus()).isEqualTo(RolloutStatus.DELETED); assertThat(deletedRollout.getStatus()).isEqualTo(RolloutStatus.DELETED);

View File

@@ -284,8 +284,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNull(artifact1, artifact2); assertArtifactNull(artifact1, artifact2);
// verify: meta data of artifact is deleted // verify: meta data of artifact is deleted
assertThat(artifactRepository.findOne(artifact1.getId())).isNull(); assertThat(artifactRepository.findById(artifact1.getId())).isNotPresent();
assertThat(artifactRepository.findOne(artifact2.getId())).isNull(); assertThat(artifactRepository.findById(artifact2.getId())).isNotPresent();
} }
@Test @Test
@@ -315,8 +315,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNull(artifact1, artifact2); assertArtifactNull(artifact1, artifact2);
// verify: artifact meta data is still available // verify: artifact meta data is still available
assertThat(artifactRepository.findOne(artifact1.getId())).isNotNull(); assertThat(artifactRepository.findById(artifact1.getId())).isNotNull();
assertThat(artifactRepository.findOne(artifact2.getId())).isNotNull(); assertThat(artifactRepository.findById(artifact2.getId())).isNotNull();
} }
@Test @Test
@@ -355,8 +355,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNull(artifact1, artifact2); assertArtifactNull(artifact1, artifact2);
// verify: artifact meta data is still available // verify: artifact meta data is still available
assertThat(artifactRepository.findOne(artifact1.getId())).isNotNull(); assertThat(artifactRepository.findById(artifact1.getId())).isNotNull();
assertThat(artifactRepository.findOne(artifact2.getId())).isNotNull(); assertThat(artifactRepository.findById(artifact2.getId())).isNotNull();
} }
@Test @Test
@@ -398,10 +398,11 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNotNull(artifactY); assertArtifactNotNull(artifactY);
// verify: meta data of artifactX is deleted // verify: meta data of artifactX is deleted
assertThat(artifactRepository.findOne(artifactX.getId())).isNull(); assertThat(artifactRepository.findById(artifactX.getId())).isNotPresent();
// verify: meta data of artifactY is not deleted // verify: meta data of artifactY is not deleted
assertThat(artifactRepository.findOne(artifactY.getId())).isNotNull(); assertThat(artifactRepository.findById(artifactY.getId())).isPresent();
} }
@Test @Test
@@ -459,7 +460,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNull(artifactX, artifactY); assertArtifactNull(artifactX, artifactY);
// verify: meta data of artifactX and artifactY is not deleted // verify: meta data of artifactX and artifactY is not deleted
assertThat(artifactRepository.findOne(artifactY.getId())).isNotNull(); assertThat(artifactRepository.findById(artifactY.getId())).isNotNull();
} }
private SoftwareModule createSoftwareModuleWithArtifacts(final SoftwareModuleType type, final String name, private SoftwareModule createSoftwareModuleWithArtifacts(final SoftwareModuleType type, final String name,
@@ -488,7 +489,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertArtifactNotNull(artifacts.toArray(new Artifact[artifacts.size()])); assertArtifactNotNull(artifacts.toArray(new Artifact[artifacts.size()]));
} }
artifacts.forEach(artifact -> assertThat(artifactRepository.findOne(artifact.getId())).isNotNull()); artifacts.forEach(artifact -> assertThat(artifactRepository.findById(artifact.getId())).isNotNull());
return softwareModule; return softwareModule;
} }
@@ -791,13 +792,15 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
ah = softwareModuleManagement.get(ah.getId()).get(); ah = softwareModuleManagement.get(ah.getId()).get();
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId()) assertThat(
.getContent()).as("Contains the created metadata element") softwareModuleManagement.findMetaDataBySoftwareModuleId(PageRequest.of(0, 10), ah.getId()).getContent())
.as("Contains the created metadata element")
.containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1)); .containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1));
softwareModuleManagement.deleteMetaData(ah.getId(), knownKey1); softwareModuleManagement.deleteMetaData(ah.getId(), knownKey1);
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId()) assertThat(
.getContent()).as("Metadata elemenets are").isEmpty(); softwareModuleManagement.findMetaDataBySoftwareModuleId(PageRequest.of(0, 10), ah.getId()).getContent())
.as("Metadata elemenets are").isEmpty();
} }
@Test @Test
@@ -835,10 +838,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
} }
Page<SoftwareModuleMetadata> metadataSw1 = softwareModuleManagement Page<SoftwareModuleMetadata> metadataSw1 = softwareModuleManagement
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw1.getId()); .findMetaDataBySoftwareModuleId(PageRequest.of(0, 100), sw1.getId());
Page<SoftwareModuleMetadata> metadataSw2 = softwareModuleManagement Page<SoftwareModuleMetadata> metadataSw2 = softwareModuleManagement
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw2.getId()); .findMetaDataBySoftwareModuleId(PageRequest.of(0, 100), sw2.getId());
assertThat(metadataSw1.getNumberOfElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1.getNumberOfElements()).isEqualTo(metadataCountSw1);
assertThat(metadataSw1.getTotalElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1.getTotalElements()).isEqualTo(metadataCountSw1);
@@ -846,10 +849,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertThat(metadataSw2.getNumberOfElements()).isEqualTo(metadataCountSw2); assertThat(metadataSw2.getNumberOfElements()).isEqualTo(metadataCountSw2);
assertThat(metadataSw2.getTotalElements()).isEqualTo(metadataCountSw2); assertThat(metadataSw2.getTotalElements()).isEqualTo(metadataCountSw2);
metadataSw1 = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(new PageRequest(0, 100), metadataSw1 = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(PageRequest.of(0, 100),
sw1.getId()); sw1.getId());
metadataSw2 = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(new PageRequest(0, 100), metadataSw2 = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(PageRequest.of(0, 100),
sw2.getId()); sw2.getId());
assertThat(metadataSw1.getNumberOfElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1.getNumberOfElements()).isEqualTo(metadataCountSw1);

View File

@@ -49,20 +49,18 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
+ " by means of throwing EntityNotFoundException.") + " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) }) @ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() { public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL), "SoftwareModuleType");
"SoftwareModuleType");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> softwareModuleTypeManagement () -> softwareModuleTypeManagement.update(entityFactory.softwareModuleType().update(NOT_EXIST_IDL)),
.update(entityFactory.softwareModuleType().update(1234L)),
"SoftwareModuleType"); "SoftwareModuleType");
} }
@Test @Test
@Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.") @Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.")
public void updateNothingResultsInUnchangedRepositoryForType() { public void updateNothingResultsInUnchangedRepositoryForType() {
final SoftwareModuleType created = softwareModuleTypeManagement.create( final SoftwareModuleType created = softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("test-key").name("test-name")); .create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
final SoftwareModuleType updated = softwareModuleTypeManagement final SoftwareModuleType updated = softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(created.getId())); .update(entityFactory.softwareModuleType().update(created.getId()));
@@ -75,8 +73,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Calling update for changed fields results in change in the repository.") @Description("Calling update for changed fields results in change in the repository.")
public void updateSoftareModuleTypeFieldsToNewValue() { public void updateSoftareModuleTypeFieldsToNewValue() {
final SoftwareModuleType created = softwareModuleTypeManagement.create( final SoftwareModuleType created = softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("test-key").name("test-name")); .create(entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
final SoftwareModuleType updated = softwareModuleTypeManagement.update( final SoftwareModuleType updated = softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(created.getId()).description("changed").colour("changed")); entityFactory.softwareModuleType().update(created.getId()).description("changed").colour("changed"));
@@ -106,39 +104,34 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).") @Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
public void deleteAssignedAndUnassignedSoftwareModuleTypes() { public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
runtimeType, appType);
SoftwareModuleType type = softwareModuleTypeManagement.create( SoftwareModuleType type = softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle")); .create(entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle"));
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
runtimeType, appType, type);
// delete unassigned // delete unassigned
softwareModuleTypeManagement.delete(type.getId()); softwareModuleTypeManagement.delete(type.getId());
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
runtimeType, appType);
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType, assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType); (JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType);
type = softwareModuleTypeManagement.create( type = softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2")); .create(entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2"));
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType, runtimeType, appType, type);
runtimeType, appType, type);
softwareModuleManagement.create( softwareModuleManagement
entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0")); .create(entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0"));
// delete assigned // delete assigned
softwareModuleTypeManagement.delete(type.getId()); softwareModuleTypeManagement.delete(type.getId());
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
runtimeType, appType);
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType, assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType, (JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType,
softwareModuleTypeRepository.findOne(type.getId())); softwareModuleTypeRepository.findById(type.getId()).get());
} }
@Test @Test
@@ -147,21 +140,19 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
testdataFactory.createSoftwareModuleOs(); testdataFactory.createSoftwareModuleOs();
final SoftwareModuleType found = softwareModuleTypeManagement final SoftwareModuleType found = softwareModuleTypeManagement
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename")); .create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
softwareModuleTypeManagement.create( softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("thetype2").name("anothername")); .create(entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
assertThat(softwareModuleTypeManagement.getByName("thename").get()) assertThat(softwareModuleTypeManagement.getByName("thename").get()).as("Type with given name").isEqualTo(found);
.as("Type with given name").isEqualTo(found);
} }
@Test @Test
@Description("Verfies that it is not possible to create a type that alrady exists.") @Description("Verfies that it is not possible to create a type that alrady exists.")
public void createSoftwareModuleTypeFailsWithExistingEntity() { public void createSoftwareModuleTypeFailsWithExistingEntity() {
softwareModuleTypeManagement softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try { try {
softwareModuleTypeManagement.create( softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("thetype").name("thename")); .create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
fail("should not have worked as module type already exists"); fail("should not have worked as module type already exists");
} catch (final EntityAlreadyExistsException e) { } catch (final EntityAlreadyExistsException e) {
@@ -172,11 +163,10 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verfies that it is not possible to create a list of types where one already exists.") @Description("Verfies that it is not possible to create a list of types where one already exists.")
public void createSoftwareModuleTypesFailsWithExistingEntity() { public void createSoftwareModuleTypesFailsWithExistingEntity() {
softwareModuleTypeManagement softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try { try {
softwareModuleTypeManagement.create( softwareModuleTypeManagement
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"), .create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
entityFactory.softwareModuleType().create().key("anothertype").name("anothername"))); entityFactory.softwareModuleType().create().key("anothertype").name("anothername")));
fail("should not have worked as module type already exists"); fail("should not have worked as module type already exists");
} catch (final EntityAlreadyExistsException e) { } catch (final EntityAlreadyExistsException e) {
@@ -188,8 +178,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Description("Verifies that the creation of a softwareModuleType is failing because of invalid max assignment") @Description("Verifies that the creation of a softwareModuleType is failing because of invalid max assignment")
public void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() { public void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
try { try {
softwareModuleTypeManagement.create( softwareModuleTypeManagement
entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0)); .create(entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0));
fail("should not have worked as max assignment is invalid. Should be greater than 0."); fail("should not have worked as max assignment is invalid. Should be greater than 0.");
} catch (final ConstraintViolationException e) { } catch (final ConstraintViolationException e) {
@@ -199,13 +189,12 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Verfies that multiple types are created as requested.") @Description("Verfies that multiple types are created as requested.")
public void createMultipleSoftwareModuleTypes() { public void createMultipleSoftwareModuleTypes() {
final List<SoftwareModuleType> created = softwareModuleTypeManagement.create( final List<SoftwareModuleType> created = softwareModuleTypeManagement
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"), .create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
entityFactory.softwareModuleType().create().key("thetype2").name("thename2"))); entityFactory.softwareModuleType().create().key("thetype2").name("thename2")));
assertThat(created.size()).as("Number of created types").isEqualTo(2); assertThat(created.size()).as("Number of created types").isEqualTo(2);
assertThat(softwareModuleTypeManagement.count()).as("Number of types in repository") assertThat(softwareModuleTypeManagement.count()).as("Number of types in repository").isEqualTo(5);
.isEqualTo(5);
} }
} }

View File

@@ -81,7 +81,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), () -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL),
"DistributionSet"); "DistributionSet");
verifyThrownExceptionBy(() -> targetFilterQueryManagement.updateAutoAssignDS(1234L, set.getId()), verifyThrownExceptionBy(() -> targetFilterQueryManagement.updateAutoAssignDS(NOT_EXIST_IDL, set.getId()),
"TargetFilterQuery"); "TargetFilterQuery");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), () -> targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL),
@@ -123,7 +123,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002")); entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
final List<TargetFilterQuery> results = targetFilterQueryManagement final List<TargetFilterQuery> results = targetFilterQueryManagement
.findByRsql(new PageRequest(0, 10), "name==" + filterName).getContent(); .findByRsql(PageRequest.of(0, 10), "name==" + filterName).getContent();
assertEquals("Search result should have 1 result", 1, results.size()); assertEquals("Search result should have 1 result", 1, results.size());
assertEquals("Retrieved newly created custom target filter", targetFilterQuery, results.get(0)); assertEquals("Retrieved newly created custom target filter", targetFilterQuery, results.get(0));
} }
@@ -132,7 +132,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
@Description("Test searching a target filter query with an invalid filter.") @Description("Test searching a target filter query with an invalid filter.")
public void searchTargetFilterQueryInvalidField() { public void searchTargetFilterQueryInvalidField() {
// Should throw an exception // Should throw an exception
targetFilterQueryManagement.findByRsql(new PageRequest(0, 10), "unknownField==testValue").getContent(); targetFilterQueryManagement.findByRsql(PageRequest.of(0, 10), "unknownField==testValue").getContent();
} }
@@ -316,7 +316,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
assertEquals(4L, targetFilterQueryManagement.count()); assertEquals(4L, targetFilterQueryManagement.count());
// check if find works // check if find works
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500), Page<TargetFilterQuery> tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(PageRequest.of(0, 500),
distributionSet.getId(), null); distributionSet.getId(), null);
assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements()); assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements());
@@ -325,22 +325,22 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
targetFilterQueryManagement.updateAutoAssignDS(tfq2.getId(), distributionSet.getId()); targetFilterQueryManagement.updateAutoAssignDS(tfq2.getId(), distributionSet.getId());
// check if find works for two // check if find works for two
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500), tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(PageRequest.of(0, 500), distributionSet.getId(),
distributionSet.getId(), null); null);
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements()); assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
Iterator<TargetFilterQuery> iterator = tfqList.iterator(); Iterator<TargetFilterQuery> iterator = tfqList.iterator();
assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId()); assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId());
assertEquals("Returns correct target filter query 2", tfq2.getId(), iterator.next().getId()); assertEquals("Returns correct target filter query 2", tfq2.getId(), iterator.next().getId());
// check if find works with name filter // check if find works with name filter
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500), tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(PageRequest.of(0, 500), distributionSet.getId(),
distributionSet.getId(), "name==" + filterName); "name==" + filterName);
assertThat(1L).as("Target filter query count").isEqualTo(tfqList.getTotalElements()); assertThat(1L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
assertEquals("Returns correct target filter query", tfq2.getId(), tfqList.iterator().next().getId()); assertEquals("Returns correct target filter query", tfq2.getId(), tfqList.iterator().next().getId());
// check if find works for all with auto assign DS // check if find works for all with auto assign DS
tfqList = targetFilterQueryManagement.findWithAutoAssignDS(new PageRequest(0, 500)); tfqList = targetFilterQueryManagement.findWithAutoAssignDS(PageRequest.of(0, 500));
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements()); assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
iterator = tfqList.iterator(); iterator = tfqList.iterator();
assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId()); assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId());

View File

@@ -419,8 +419,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
target = createTargetWithAttributes("4711"); target = createTargetWithAttributes("4711");
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1); assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
assertThat(targetManagement.existsByControllerId("4711")).isTrue();
targetManagement.delete(Collections.singletonList(target.getId())); targetManagement.delete(Collections.singletonList(target.getId()));
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0); assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
assertThat(targetManagement.existsByControllerId("4711")).isFalse();
final List<Long> targets = new ArrayList<>(); final List<Long> targets = new ArrayList<>();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
@@ -664,7 +666,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
targetManagement.delete(targetsIdsToDelete); targetManagement.delete(targetsIdsToDelete);
final List<Target> targetsLeft = targetManagement.findAll(new PageRequest(0, 200)).getContent(); final List<Target> targetsLeft = targetManagement.findAll(PageRequest.of(0, 200)).getContent();
assertThat(firstList.spliterator().getExactSizeIfKnown() - numberToDelete).as("Size of split list") assertThat(firstList.spliterator().getExactSizeIfKnown() - numberToDelete).as("Size of split list")
.isEqualTo(targetsLeft.spliterator().getExactSizeIfKnown()); .isEqualTo(targetsLeft.spliterator().getExactSizeIfKnown());
@@ -905,12 +907,18 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Verify that the flag for requesting controller attributes is set correctly.") @Description("Verify that the flag for requesting controller attributes is set correctly.")
public void verifyRequestControllerAttributes() { public void verifyRequestControllerAttributes() {
final String knownTargetId = "KnownControllerId"; final String knownControllerId = "KnownControllerId";
createTargetWithAttributes(knownTargetId); final Target target = createTargetWithAttributes(knownControllerId);
assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isFalse(); assertThat(targetManagement.findByControllerAttributesRequested(PAGE)).isEmpty();
targetManagement.requestControllerAttributes(knownTargetId); assertThat(targetManagement.isControllerAttributesRequested(knownControllerId)).isFalse();
assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue();
targetManagement.requestControllerAttributes(knownControllerId);
final Target updated = targetManagement.getByControllerID(knownControllerId).get();
assertThat(target.isRequestControllerAttributes()).isFalse();
assertThat(targetManagement.findByControllerAttributesRequested(PAGE).getContent()).contains(updated);
assertThat(targetManagement.isControllerAttributesRequested(knownControllerId)).isTrue();
} }

View File

@@ -245,7 +245,7 @@ public class TargetTagManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent()) assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent())
.doesNotContain(toDelete); .doesNotContain(toDelete);
} }
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull(); assertThat(targetTagRepository.findById(toDelete.getId())).as("No tag should be found").isNotPresent();
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19); assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
} }
@@ -262,9 +262,9 @@ public class TargetTagManagementTest extends AbstractJpaIntegrationTest {
// check data // check data
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size()); assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved") assertThat(targetTagRepository.findById(savedAssigned.getId()).get().getName()).as("wrong target tag is saved")
.isEqualTo("test123"); .isEqualTo("test123");
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()) assertThat(targetTagRepository.findById(savedAssigned.getId()).get().getOptLockRevision())
.as("wrong target tag is saved").isEqualTo(2); .as("wrong target tag is saved").isEqualTo(2);
} }

View File

@@ -34,7 +34,7 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
@@ -44,7 +44,7 @@ import io.qameta.allure.Story;
@Feature("Component Tests - Repository") @Feature("Component Tests - Repository")
@Story("Entity Events") @Story("Entity Events")
@SpringApplicationConfiguration(classes = RepositoryTestConfiguration.class) @SpringBootTest(classes = { RepositoryTestConfiguration.class })
public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
@Autowired @Autowired

View File

@@ -90,7 +90,7 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) { private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
final Slice<Action> findEnitity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(), final Slice<Action> findEnitity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(),
new PageRequest(0, 100)); PageRequest.of(0, 100));
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId()); final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId());
assertThat(findEnitity).isNotNull(); assertThat(findEnitity).isNotNull();
assertThat(countAllEntities).isEqualTo(expectedEntities); assertThat(countAllEntities).isEqualTo(expectedEntities);

Some files were not shown because too many files have changed in this diff Show More