diff --git a/.3rd-party/Release_0_2_0.md b/.3rd-party/Release_0_2_0.md index fefc42da5..d51261890 100644 --- a/.3rd-party/Release_0_2_0.md +++ b/.3rd-party/Release_0_2_0.md @@ -54,7 +54,7 @@ |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.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.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) | diff --git a/.3rd-party/Release_0_3_0.md b/.3rd-party/Release_0_3_0.md new file mode 100644 index 000000000..98eccef1e --- /dev/null +++ b/.3rd-party/Release_0_3_0.md @@ -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 | diff --git a/.3rd-party/compile.txt b/.3rd-party/compile.txt index 14566243f..ab6332c26 100644 --- a/.3rd-party/compile.txt +++ b/.3rd-party/compile.txt @@ -1,115 +1,117 @@ - aopalliance:aopalliance:jar:1.0:compile - ch.qos.logback:logback-classic:jar:1.1.11:compile - ch.qos.logback:logback-core:jar:1.1.11:compile - com.cronutils:cron-utils:jar:5.0.5:compile - com.fasterxml.jackson.core:jackson-annotations:jar:2.8.9:compile - com.fasterxml.jackson.core:jackson-core:jar:2.8.9:compile - com.fasterxml.jackson.core:jackson-databind:jar:2.8.9:compile - com.fasterxml:classmate:jar:1.3.3:compile - com.github.ben-manes.caffeine:caffeine:jar:2.3.5:compile - com.github.gwtd3:gwt-d3-api:jar:1.2.0:compile - com.github.gwtd3:gwt-d3-js:jar:3.5.11:compile - com.github.gwtd3:gwt-d3-js:jar:sources:3.5.11:compile - com.google.guava:guava:jar:25.0-jre:compile - com.h2database:h2:jar:1.4.195:compile - com.microsoft.sqlserver:mssql-jdbc:jar:6.4.0.jre8:compile - com.rabbitmq:amqp-client:jar:4.0.3:compile - com.rabbitmq:http-client:jar:1.3.1.RELEASE:compile - com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.9.vaadin2:compile - com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile - com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin6:compile - com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin6:compile - com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile - com.vaadin:vaadin-client:jar:7.7.13:compile - com.vaadin:vaadin-push:jar:7.7.13:compile - com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile - com.vaadin:vaadin-server:jar:7.7.13:compile - com.vaadin:vaadin-shared:jar:7.7.13:compile - com.vaadin:vaadin-spring-boot:jar:1.1.1:compile - com.vaadin:vaadin-spring:jar:1.1.1:compile - com.vaadin:vaadin-themes:jar:7.7.13:compile - commons-codec:commons-codec:jar:1.10:compile - commons-io:commons-io:jar:2.4:compile - cz.jirutka.rsql:rsql-parser:jar:2.1.0:compile - io.protostuff:protostuff-api:jar:1.5.6:compile - io.protostuff:protostuff-collectionschema:jar:1.5.6:compile - io.protostuff:protostuff-core:jar:1.5.6:compile - io.protostuff:protostuff-runtime:jar:1.5.6:compile - javax.annotation:javax.annotation-api:jar:1.2:compile - javax.servlet:javax.servlet-api:jar:3.1.0:compile - javax.transaction:javax.transaction-api:jar:1.2:compile - javax.validation:validation-api:jar:2.0.1.Final:compile - javax.validation:validation-api:jar:sources:1.0.0.GA:compile - javax.websocket:javax.websocket-api:jar:1.0:compile - org.apache.commons:commons-lang3:jar:3.4:compile - org.apache.httpcomponents:httpclient:jar:4.5.3:compile - org.apache.httpcomponents:httpcore:jar:4.4.6:compile - org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.28:compile - org.apache.tomcat:tomcat-jdbc:jar:8.0.28:compile - org.apache.tomcat:tomcat-juli:jar:8.0.28:compile - org.aspectj:aspectjweaver:jar:1.8.10:compile - org.flywaydb:flyway-core:jar:4.0.3:compile - org.glassfish:javax.json:jar:1.0.4:compile - org.hibernate.validator:hibernate-validator:jar:6.0.7.Final:compile - org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile - org.jsoup:jsoup:jar:1.8.3:compile - org.mortbay.jasper:apache-el:jar:8.0.33:compile - org.ow2.asm:asm-commons:jar:5.0.1:compile - org.ow2.asm:asm-tree:jar:5.0.1:compile - org.ow2.asm:asm:jar:5.0.1:compile - org.slf4j:jcl-over-slf4j:jar:1.7.25:compile - org.slf4j:jul-to-slf4j:jar:1.7.25:compile - org.slf4j:log4j-over-slf4j: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-rabbit:jar:1.7.6.RELEASE:compile - org.springframework.boot:spring-boot-actuator:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-autoconfigure:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-actuator:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-aop:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-jetty:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-logging:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-validation:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter-web:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot-starter:jar:1.4.7.RELEASE:compile - org.springframework.boot:spring-boot:jar:1.4.7.RELEASE:compile - org.springframework.cloud:spring-cloud-bus:jar:1.2.2.RELEASE:compile - org.springframework.cloud:spring-cloud-context:jar:1.1.8.RELEASE:compile - org.springframework.cloud:spring-cloud-stream:jar:1.1.2.RELEASE:compile - org.springframework.data:spring-data-commons:jar:1.12.11.RELEASE:compile - org.springframework.data:spring-data-jpa:jar:1.10.11.RELEASE:compile - org.springframework.hateoas:spring-hateoas:jar:0.23.0.RELEASE:compile - org.springframework.integration:spring-integration-core:jar:4.3.10.RELEASE:compile - org.springframework.integration:spring-integration-jmx:jar:4.3.10.RELEASE:compile - org.springframework.integration:spring-integration-tuple:jar:1.0.0.RELEASE:compile - org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile - org.springframework.retry:spring-retry:jar:1.1.5.RELEASE:compile - org.springframework.security:spring-security-aspects:jar:4.1.4.RELEASE:compile - org.springframework.security:spring-security-config:jar:4.1.4.RELEASE:compile - org.springframework.security:spring-security-core:jar:4.1.4.RELEASE:compile - org.springframework.security:spring-security-crypto:jar:4.1.4.RELEASE:compile - org.springframework.security:spring-security-web:jar:4.1.4.RELEASE:compile - org.springframework:spring-aop:jar:4.3.9.RELEASE:compile - org.springframework:spring-aspects:jar:4.3.9.RELEASE:compile - org.springframework:spring-beans:jar:4.3.9.RELEASE:compile - org.springframework:spring-context-support:jar:4.3.9.RELEASE:compile - org.springframework:spring-context:jar:4.3.9.RELEASE:compile - org.springframework:spring-core:jar:4.3.9.RELEASE:compile - org.springframework:spring-expression:jar:4.3.9.RELEASE:compile - org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile - org.springframework:spring-messaging:jar:4.3.9.RELEASE:compile - org.springframework:spring-orm:jar:4.3.9.RELEASE:compile - org.springframework:spring-tuple:jar:1.0.0.RELEASE:compile - org.springframework:spring-tx:jar:4.3.9.RELEASE:compile - org.springframework:spring-web:jar:4.3.9.RELEASE:compile - org.springframework:spring-webmvc:jar:4.3.9.RELEASE:compile - org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.6.1.3:compile - org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile - org.vaadin.addons:tokenfield:jar:7.0.1:compile - org.vaadin.alump.distributionbar:dbar-addon:jar:2.0.0:compile - org.vaadin.spring.addons:vaadin-spring-addon-eventbus:jar:0.0.6.RELEASE: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 +ch.qos.logback:logback-classic:jar:1.2.3:compile +ch.qos.logback:logback-core:jar:1.2.3:compile +com.cronutils:cron-utils:jar:5.0.5:compile +com.esotericsoftware:kryo-shaded:jar:3.0.3:compile +com.esotericsoftware:minlog:jar:1.3.0:compile +com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile +com.fasterxml.jackson.core:jackson-core:jar:2.9.8:compile +com.fasterxml.jackson.core:jackson-databind:jar:2.9.8:compile +com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.8:compile +com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.8:compile +com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.8:compile +com.fasterxml:classmate:jar:1.3.4:compile +com.github.ben-manes.caffeine:caffeine:jar:2.6.2:compile +com.github.gwtd3:gwt-d3-api:jar:1.2.0:compile +com.github.gwtd3:gwt-d3-js:jar:3.5.11:compile +com.github.gwtd3:gwt-d3-js:jar:sources:3.5.11:compile +com.google.guava:guava:jar:25.0-jre:compile +com.h2database:h2:jar:1.4.197:compile +com.microsoft.sqlserver:mssql-jdbc:jar:6.4.0.jre8:compile +com.rabbitmq:amqp-client:jar:5.4.3:compile +com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.9.vaadin2:compile +com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile +com.vaadin.external.gwt:gwt-elemental:jar:2.7.0.vaadin6:compile +com.vaadin.external.gwt:gwt-user:jar:2.7.0.vaadin6:compile +com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile +com.vaadin:vaadin-client:jar:7.7.13:compile +com.vaadin:vaadin-push:jar:7.7.13:compile +com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile +com.vaadin:vaadin-server:jar:7.7.13:compile +com.vaadin:vaadin-shared:jar:7.7.13:compile +com.vaadin:vaadin-spring-boot:jar:1.2.0:compile +com.vaadin:vaadin-spring:jar:1.2.0:compile +com.vaadin:vaadin-themes:jar:7.7.13:compile +com.zaxxer:HikariCP:jar:3.2.0:compile +commons-io:commons-io:jar:2.5:compile +cz.jirutka.rsql:rsql-parser:jar:2.1.0:compile +io.projectreactor:reactor-core:jar:3.2.5.RELEASE:compile +io.protostuff:protostuff-api:jar:1.5.6:compile +io.protostuff:protostuff-collectionschema:jar:1.5.6:compile +io.protostuff:protostuff-core:jar:1.5.6:compile +io.protostuff:protostuff-runtime:jar:1.5.6:compile +javax.annotation:javax.annotation-api:jar:1.3.2:compile +javax.json:javax.json-api:jar:1.1.4:compile +javax.servlet:javax.servlet-api:jar:4.0.1:compile +javax.transaction:javax.transaction-api:jar:1.3:compile +javax.validation:validation-api:jar:2.0.1.Final:compile +javax.validation:validation-api:jar:sources:1.0.0.GA:compile +javax.websocket:javax.websocket-api:jar:1.1:compile +org.apache.commons:commons-lang3:jar:3.7:compile +org.apache.logging.log4j:log4j-api:jar:2.11.1:compile +org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.1:compile +org.flywaydb:flyway-core:jar:5.2.4:compile +org.hibernate.validator:hibernate-validator:jar:6.0.14.Final:compile +org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile +org.jsoup:jsoup:jar:1.8.3:compile +org.mortbay.jasper:apache-el:jar:8.5.35.1:compile +org.ow2.asm:asm-analysis:jar:7.0:compile +org.ow2.asm:asm-commons:jar:7.0:compile +org.ow2.asm:asm-tree:jar:7.0:compile +org.ow2.asm:asm:jar:7.0:compile +org.reactivestreams:reactive-streams:jar:1.0.2:compile +org.slf4j:jul-to-slf4j:jar:1.7.25:compile +org.slf4j:slf4j-api:jar:1.7.25:compile +org.springframework.amqp:spring-amqp:jar:2.1.3.RELEASE:compile +org.springframework.amqp:spring-rabbit:jar:2.1.3.RELEASE:compile +org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-aop:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-data-jpa:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-jdbc:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-jetty:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-json:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-logging:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-validation:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter-web:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot-starter:jar:2.1.2.RELEASE:compile +org.springframework.boot:spring-boot:jar:2.1.2.RELEASE:compile +org.springframework.cloud:spring-cloud-bus:jar:2.1.0.RELEASE:compile +org.springframework.cloud:spring-cloud-commons:jar:2.1.0.RELEASE:compile +org.springframework.cloud:spring-cloud-context:jar:2.1.0.RELEASE:compile +org.springframework.cloud:spring-cloud-starter:jar:2.1.0.RELEASE:compile +org.springframework.cloud:spring-cloud-stream:jar:2.1.0.RELEASE:compile +org.springframework.data:spring-data-commons:jar:2.1.4.RELEASE:compile +org.springframework.data:spring-data-jpa:jar:2.1.4.RELEASE:compile +org.springframework.hateoas:spring-hateoas:jar:0.25.0.RELEASE:compile +org.springframework.integration:spring-integration-core:jar:5.1.2.RELEASE:compile +org.springframework.integration:spring-integration-jmx:jar:5.1.2.RELEASE:compile +org.springframework.integration:spring-integration-tuple:jar:1.0.0.RELEASE:compile +org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile +org.springframework.retry:spring-retry:jar:1.2.3.RELEASE:compile +org.springframework.security:spring-security-aspects:jar:5.1.3.RELEASE:compile +org.springframework.security:spring-security-config:jar:5.1.3.RELEASE:compile +org.springframework.security:spring-security-core:jar:5.1.3.RELEASE:compile +org.springframework.security:spring-security-crypto:jar:5.1.3.RELEASE:compile +org.springframework.security:spring-security-web:jar:5.1.3.RELEASE:compile +org.springframework:spring-aop:jar:5.1.4.RELEASE:compile +org.springframework:spring-aspects:jar:5.1.4.RELEASE:compile +org.springframework:spring-beans:jar:5.1.4.RELEASE:compile +org.springframework:spring-context-support:jar:5.1.4.RELEASE:compile +org.springframework:spring-context:jar:5.1.4.RELEASE:compile +org.springframework:spring-core:jar:5.1.4.RELEASE:compile +org.springframework:spring-expression:jar:5.1.4.RELEASE:compile +org.springframework:spring-jcl:jar:5.1.4.RELEASE:compile +org.springframework:spring-jdbc:jar:5.1.4.RELEASE:compile +org.springframework:spring-messaging:jar:5.1.4.RELEASE:compile +org.springframework:spring-orm:jar:5.1.4.RELEASE:compile +org.springframework:spring-tuple:jar:1.0.0.RELEASE:compile +org.springframework:spring-tx:jar:5.1.4.RELEASE:compile +org.springframework:spring-web:jar:5.1.4.RELEASE:compile +org.springframework:spring-webmvc:jar:5.1.4.RELEASE:compile +org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.6.1.3:compile +org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile +org.vaadin.addons:tokenfield:jar:7.0.1:compile +org.vaadin.alump.distributionbar:dbar-addon:jar:2.0.0:compile +org.vaadin.spring.addons:vaadin-spring-addon-eventbus:jar:0.0.6.RELEASE: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 diff --git a/.3rd-party/listDeps.sh b/.3rd-party/listDeps.sh index fb6b8be8c..3d39bfe19 100755 --- a/.3rd-party/listDeps.sh +++ b/.3rd-party/listDeps.sh @@ -10,13 +10,13 @@ cd .. # 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 -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 '.*:.*:provided'|sort|uniq > .3rd-party/provided.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'| 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'| tr -d '[:blank:]'| sed -e 's/(optional)//'|sort|uniq > .3rd-party/provided.txt # Test dependencies 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 find . -name dependencies.txt|while read i; do rm $i;done diff --git a/.3rd-party/provided.txt b/.3rd-party/provided.txt index 06770f23b..b45d413af 100644 --- a/.3rd-party/provided.txt +++ b/.3rd-party/provided.txt @@ -1 +1 @@ - javax.servlet:javax.servlet-api:jar:3.1.0:provided +javax.servlet:javax.servlet-api:jar:4.0.1:provided diff --git a/.3rd-party/test.txt b/.3rd-party/test.txt index f017d70cd..cbd806794 100644 --- a/.3rd-party/test.txt +++ b/.3rd-party/test.txt @@ -1,72 +1,78 @@ - ant:ant:jar:1.6.5:test - asm:asm:jar:3.3.1:test - cglib:cglib-nodep:jar:3.1:test - colt:colt:jar:1.2.0:test - com.esotericsoftware:kryo-shaded:jar:3.0.3:test - com.esotericsoftware:minlog:jar:1.3.0:test - com.google.code.gson:gson:jar:2.7:test - com.google.gwt.gwtmockito:gwtmockito:jar:1.1.8:test - com.google.gwt:gwt-dev:jar:2.8.0:test - com.google.gwt:gwt-user:jar:2.8.0:test - com.google.jsinterop:jsinterop-annotations:jar:1.0.1:test - com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.1:test - com.ibm.icu:icu4j:jar:50.1.1:test - com.jayway.awaitility:awaitility:jar:1.7.0:test - com.jayway.jsonpath:json-path:jar:2.0.0:test - commons-collections:commons-collections:jar:3.2.2:test - javax.el:javax.el-api:jar:2.2.4:test - junit:junit:jar:4.12:test - net._01001111:jlorem:jar:1.1:test - net.minidev:asm:jar:1.0.2:test - net.minidev:json-smart:jar:2.1.1:test - net.sourceforge.cssparser:cssparser:jar:0.9.18:test - net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:test - net.sourceforge.htmlunit:htmlunit:jar:2.21:test - net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:test - org.apache.httpcomponents:httpmime:jar:4.5.3:test - org.apache.tika:tika-core:jar:1.7:test - org.aspectj:aspectjrt:jar:1.8.10:test - org.assertj:assertj-core:jar:3.6.2:test - org.hamcrest:hamcrest-all:jar:1.3:test - org.hamcrest:hamcrest-core:jar:1.3:test - org.hamcrest:hamcrest-library:jar:1.3:test - org.javassist:javassist:jar:3.20.0-GA:test - org.json:json:jar:20141113:test - org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.9.3:test - org.mariadb.jdbc:mariadb-java-client:jar:2.0.2:test - org.mockito:mockito-core:jar:1.10.19:test - org.mortbay.jasper:apache-jsp:jar:8.0.33:test - org.objenesis:objenesis:jar:2.1:test - org.ow2.asm:asm-commons:jar:5.0.3:test - org.ow2.asm:asm-tree:jar:5.0.3:test - org.ow2.asm:asm-util:jar:5.0.3:test - org.ow2.asm:asm:jar:5.0.3:test - org.powermock:powermock-api-mockito-common:jar:1.6.5:test - org.powermock:powermock-api-mockito:jar:1.6.5:test - org.powermock:powermock-api-support:jar:1.6.5:test - org.powermock:powermock-core:jar:1.6.5:test - org.powermock:powermock-module-junit4-common:jar:1.6.5:test - org.powermock:powermock-module-junit4:jar:1.6.5:test - org.powermock:powermock-reflect:jar:1.6.5:test - org.skyscreamer:jsonassert:jar:1.3.0:test - org.springframework.amqp:spring-rabbit-junit:jar:1.7.6.RELEASE:test - org.springframework.amqp:spring-rabbit-test:jar:1.7.6.RELEASE:test - org.springframework.boot:spring-boot-starter-test:jar:1.4.7.RELEASE:test - org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.7.RELEASE:test - org.springframework.boot:spring-boot-test:jar:1.4.7.RELEASE:test - org.springframework.cloud:spring-cloud-stream-binder-test:jar:1.1.2.RELEASE:test - org.springframework.cloud:spring-cloud-stream-test-support:jar:1.1.2.RELEASE:test - org.springframework.integration:spring-integration-test:jar:4.3.10.RELEASE:test - org.springframework:spring-test:jar:4.3.9.RELEASE:test - org.yaml:snakeyaml:jar:1.17:test - ru.qatools.commons:properties:jar:2.0.RC5:test - ru.yandex.qatools.allure:allure-java-adaptor-api:jar:1.5.4:test - ru.yandex.qatools.allure:allure-java-annotations:jar:1.5.4:test - ru.yandex.qatools.allure:allure-java-aspects:jar:1.5.4:test - ru.yandex.qatools.allure:allure-junit-adaptor:jar:1.5.4:test - ru.yandex.qatools.allure:allure-model:jar:1.5.4: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.11.0:test - xml-apis:xml-apis:jar:1.4.01:test +ant:ant:jar:1.6.5:test +colt:colt:jar:1.2.0:test +com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.9.8:test +com.google.code.gson:gson:jar:2.8.5:test +com.google.gwt.gwtmockito:gwtmockito:jar:1.1.8:test +com.google.gwt:gwt-dev:jar:2.8.0:test +com.google.gwt:gwt-user:jar:2.8.0:test +com.google.jsinterop:jsinterop-annotations:jar:1.0.1:test +com.google.jsinterop:jsinterop-annotations:jar:sources:1.0.1:test +com.ibm.icu:icu4j:jar:50.1.1:test +com.jayway.jsonpath:json-path:jar:2.4.0:test +com.rabbitmq:http-client:jar:2.1.0.RELEASE:test +com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test +commons-codec:commons-codec:jar:1.11:test +commons-collections:commons-collections:jar:3.2.2:test +commons-net:commons-net:jar:3.6:test +io.qameta.allure:allure-java-commons:jar:2.7.0:test +io.qameta.allure:allure-junit4:jar:2.7.0:test +io.qameta.allure:allure2-model-api:jar:1.0.0:test +io.qameta.allure:allure2-model-jackson:jar:1.0.0:test +io.qameta.allure:allure2-model-pojo:jar:1.0.0:test +javax.el:javax.el-api:jar:2.2.4:test +junit:junit:jar:4.12:test +net._01001111:jlorem:jar:1.1:test +net.bytebuddy:byte-buddy-agent:jar:1.9.7:test +net.bytebuddy:byte-buddy:jar:1.9.7:test +net.minidev:accessors-smart:jar:1.2:test +net.minidev:json-smart:jar:2.3:test +net.sourceforge.htmlunit:htmlunit-core-js:jar:2.33:test +net.sourceforge.htmlunit:htmlunit-cssparser:jar:1.2.0:test +net.sourceforge.htmlunit:htmlunit:jar:2.33:test +net.sourceforge.htmlunit:neko-htmlunit:jar:2.33:test +org.apache.commons:commons-text:jar:1.4:test +org.apache.httpcomponents:httpclient:jar:4.5.6:test +org.apache.httpcomponents:httpcore:jar:4.4.10:test +org.apache.httpcomponents:httpmime:jar:4.5.6:test +org.apache.tika:tika-core:jar:1.14:test +org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.14:test +org.aspectj:aspectjrt:jar:1.9.2:test +org.aspectj:aspectjweaver:jar:1.9.2:test +org.assertj:assertj-core:jar:3.11.1:test +org.awaitility:awaitility:jar:3.1.2:test +org.hamcrest:hamcrest-all:jar:1.3:test +org.hamcrest:hamcrest-core:jar:1.3:test +org.hamcrest:hamcrest-library:jar:1.3:test +org.javassist:javassist:jar:3.22.0-GA:test +org.jooq:joor-java-8:jar:0.9.9:test +org.mariadb.jdbc:mariadb-java-client:jar:2.3.0:test +org.mockito:mockito-core:jar:2.23.4:test +org.mortbay.jasper:apache-jsp:jar:8.5.33.1:test +org.objenesis:objenesis:jar:2.6:test +org.ow2.asm:asm-commons:jar:5.0.3:test +org.ow2.asm:asm-tree:jar:5.0.3:test +org.ow2.asm:asm-util:jar:5.0.3:test +org.ow2.asm:asm:jar:5.0.3:test +org.ow2.asm:asm:jar:5.0.4:test +org.skyscreamer:jsonassert:jar:1.5.0:test +org.springframework.amqp:spring-rabbit-junit:jar:2.1.3.RELEASE:test +org.springframework.amqp:spring-rabbit-test:jar:2.1.3.RELEASE:test +org.springframework.boot:spring-boot-starter-test:jar:2.1.2.RELEASE:test +org.springframework.boot:spring-boot-test-autoconfigure:jar:2.1.2.RELEASE:test +org.springframework.boot:spring-boot-test:jar:2.1.2.RELEASE:test +org.springframework.cloud:spring-cloud-function-context:jar:2.0.0.RELEASE:test +org.springframework.cloud:spring-cloud-function-core:jar:2.0.0.RELEASE:test +org.springframework.cloud:spring-cloud-stream-binder-test:jar:2.1.0.RELEASE:test +org.springframework.cloud:spring-cloud-stream-test-support:jar:2.1.0.RELEASE:test +org.springframework.integration:spring-integration-test-support:jar:5.1.2.RELEASE:test +org.springframework.integration:spring-integration-test:jar:5.1.2.RELEASE:test +org.springframework.restdocs:spring-restdocs-core:jar:2.0.3.RELEASE:test +org.springframework.restdocs:spring-restdocs-mockmvc:jar:2.0.3.RELEASE:test +org.springframework:spring-test:jar:5.1.4.RELEASE: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 diff --git a/.circleci/config.yml b/.circleci/config.yml index 9038d03f0..eeb90a975 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,4 +56,4 @@ jobs: notify: webhooks: # Gitter hook - - url: https://webhooks.gitter.im/e/a20a6bc2bda5a8a77d39 + - url: https://webhooks.gitter.im/e/a20a6bc2bda5a8a77d39 \ No newline at end of file diff --git a/README.md b/README.md index 9bdadf588..2132c0d9a 100644 --- a/README.md +++ b/README.md @@ -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: - [Bosch IoT Rollouts](https://www.bosch-iot-suite.com/rollouts/) +- [Kynetics Update Factory](https://www.kynetics.com/iot-platform-update-factory) # Device Integration diff --git a/docs/content/guides/runhawkbit.md b/docs/content/guides/runhawkbit.md index ba58a5df6..918ed60d4 100644 --- a/docs/content/guides/runhawkbit.md +++ b/docs/content/guides/runhawkbit.md @@ -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. - + {{% 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. {{% /note %}} ## System Architecture + 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). - [MariaDB](https://mariadb.org) for the repository. - [RabbitMQ](https://www.rabbitmq.com) for DMF communication. - For testing and demonstration purposes we will also use: - - [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 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). ## Prerequisites + - 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). @@ -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. ### 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 org.mariadb.jdbc mariadb-java-client compile -``` +``` + ### 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.datasource.url=jdbc:mysql://localhost:3306/YOUR_SCHEMA 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: -``` +```properties spring.rabbitmq.username=guest spring.rabbitmq.password=guest 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. Adapt `application.properties` in this case: -``` + +```properties hawkbit.url=localhost:8080 ``` + or provide the parameter on command line: -``` + +```properties hawkbit-example-mgmt-simulator-##VERSION##.jar --hawkbit.url=YOUR_HOST:PORT ``` ## 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) -### 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). 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) -# 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) diff --git a/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java b/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java index 9d526348c..60a808282 100644 --- a/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java +++ b/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java @@ -11,13 +11,21 @@ package org.eclipse.hawkbit.artifact.repository; import static org.assertj.core.api.Assertions.assertThat; import java.io.ByteArrayInputStream; +import java.io.File; import java.io.IOException; import java.util.Random; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.assertj.core.api.Assertions; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; +import org.junit.AfterClass; +import org.junit.BeforeClass; 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.Feature; @@ -26,12 +34,32 @@ import io.qameta.allure.Story; @Feature("Unit Tests - Artifact File System Repository") @Story("Test storing artifact binaries in the file-system") public class ArtifactFilesystemRepositoryTest { + private static final Logger LOG = LoggerFactory.getLogger(ArtifactFilesystemRepositoryTest.class); + private static final String TENANT = "test_tenant"; - private final ArtifactFilesystemProperties artifactResourceProperties = new ArtifactFilesystemProperties(); + private static ArtifactFilesystemProperties artifactResourceProperties; - private final ArtifactFilesystemRepository artifactFilesystemRepository = new ArtifactFilesystemRepository( - artifactResourceProperties); + private static ArtifactFilesystemRepository artifactFilesystemRepository; + + @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 @Description("Verfies that an artifact can be successfully stored in the file-system repository") diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java index b6ab87055..d34d69fe9 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/PropertyHostnameResolverAutoConfiguration.java @@ -41,7 +41,7 @@ public class PropertyHostnameResolverAutoConfiguration { */ @Bean @ConditionalOnMissingBean(value = HostnameResolver.class) - public HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) { + HostnameResolver hostnameResolver(final HawkbitServerProperties serverProperties) { return () -> { try { return new URL(serverProperties.getUrl()); @@ -58,7 +58,7 @@ public class PropertyHostnameResolverAutoConfiguration { */ @Bean @ConditionalOnMissingBean(ArtifactUrlHandler.class) - public PropertyBasedArtifactUrlHandler propertyBasedArtifactUrlHandler( + PropertyBasedArtifactUrlHandler propertyBasedArtifactUrlHandler( final ArtifactUrlHandlerProperties urlHandlerProperties) { return new PropertyBasedArtifactUrlHandler(urlHandlerProperties); } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java index 47745a194..4f371792d 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java @@ -8,28 +8,20 @@ */ 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.TenantAwareCacheManager; import org.eclipse.hawkbit.tenancy.TenantAware; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.guava.GuavaCacheManager; -import org.springframework.cache.interceptor.CacheOperationInvocationContext; -import org.springframework.cache.interceptor.SimpleCacheResolver; +import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; 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 @@ -43,13 +35,6 @@ import com.google.common.cache.CacheBuilder; @EnableCaching 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 * existing. @@ -57,7 +42,8 @@ public class CacheAutoConfiguration { @Bean @ConditionalOnMissingBean @Primary - public TenancyCacheManager cacheManager() { + TenancyCacheManager cacheManager(@Qualifier("directCacheManager") final CacheManager directCacheManager, + final TenantAware tenantAware) { return new TenantAwareCacheManager(directCacheManager, tenantAware); } @@ -70,9 +56,6 @@ public class CacheAutoConfiguration { @EnableConfigurationProperties(CacheProperties.class) static class DirectCacheManagerConfiguration { - @Autowired - private CacheProperties cacheProperties; - /** * @return the direct cache manager to access without tenant aware * check, cause in sometimes it's necessary to access the cache @@ -81,143 +64,17 @@ public class CacheAutoConfiguration { */ @Bean(name = "directCacheManager") @ConditionalOnMissingBean(name = "directCacheManager") - public CacheManager directCacheManager() { - final GuavaCacheManager cacheManager = new GuavaCacheManager(); + public CacheManager directCacheManager(final CacheProperties cacheProperties) { + final CaffeineCacheManager cacheManager = new CaffeineCacheManager(); if (cacheProperties.getTtl() > 0) { - final CacheBuilder cacheBuilder = CacheBuilder.newBuilder() + final Caffeine cacheBuilder = Caffeine.newBuilder() .expireAfterWrite(cacheProperties.getTtl(), cacheProperties.getTtlUnit()); - cacheManager.setCacheBuilder(cacheBuilder); + cacheManager.setCaffeine(cacheBuilder); } 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 resolveCaches(final CacheOperationInvocationContext context) { - return super.resolveCaches(context).stream().map(TenantCacheWrapper::new).collect(Collectors.toList()); - } - - @Override - protected Collection 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 get(final Object key, final Class 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 get(final Object key, final Callable valueLoader) { - return delegate.get(key, valueLoader); - } - - } - } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java index 144135b94..55000fc36 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.autoconfigure.cache; import org.eclipse.hawkbit.cache.DefaultDownloadIdCache; import org.eclipse.hawkbit.cache.DownloadIdCache; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.cache.CacheManager; import org.springframework.context.annotation.Bean; @@ -24,9 +23,6 @@ import org.springframework.context.annotation.Configuration; @Configuration public class DownloadIdCacheAutoConfiguration { - @Autowired - private CacheManager cacheManager; - /** * Bean for the downloadId cache that returns the DefaultDownloadIdCache. * The DefaultDownloadIdCache cannot be used within a cluster because the @@ -38,7 +34,7 @@ public class DownloadIdCacheAutoConfiguration { */ @Bean @ConditionalOnMissingBean - public DownloadIdCache downloadIdCache() { + public DownloadIdCache downloadIdCache(final CacheManager cacheManager) { return new DefaultDownloadIdCache(cacheManager); } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java index a76e5ff38..7ded8ba85 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/repository/event/EventPublisherAutoConfiguration.java @@ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.cloud.bus.ConditionalOnBusEnabled; import org.springframework.cloud.bus.ServiceMatcher; import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan; +import org.springframework.cloud.stream.annotation.StreamMessageConverter; import org.springframework.context.ApplicationEvent; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -43,14 +44,6 @@ import io.protostuff.Schema; @RemoteApplicationEventScan(basePackages = "org.eclipse.hawkbit.repository.event.remote") @PropertySource("classpath:/hawkbit-eventbus-defaults.properties") public class EventPublisherAutoConfiguration { - - @Autowired - @Qualifier("asyncExecutor") - private Executor executor; - - @Autowired - private TenantAware tenantAware; - /** * Server internal event publisher that allows parallel event processing if * the event listener is marked as so. @@ -58,7 +51,8 @@ public class EventPublisherAutoConfiguration { * @return publisher bean */ @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( tenantAware, applicationEventFilter()); simpleApplicationEventMulticaster.setTaskExecutor(executor); @@ -72,7 +66,7 @@ public class EventPublisherAutoConfiguration { * @return the singleton instance of the {@link EventPublisherHolder} */ @Bean - public EventPublisherHolder eventBusHolder() { + EventPublisherHolder eventBusHolder() { return EventPublisherHolder.getInstance(); } @@ -82,7 +76,7 @@ public class EventPublisherAutoConfiguration { */ @Bean @ConditionalOnMissingBean - public ApplicationEventFilter applicationEventFilter() { + ApplicationEventFilter applicationEventFilter() { return e -> false; } @@ -144,6 +138,7 @@ public class EventPublisherAutoConfiguration { * @return the protostuff io message converter */ @Bean + @StreamMessageConverter public MessageConverter busProtoBufConverter() { return new BusProtoStuffMessageConverter(); } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/InMemoryUserManagementAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/InMemoryUserManagementAutoConfiguration.java index c8b71b8e9..0beff46ca 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/InMemoryUserManagementAutoConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/InMemoryUserManagementAutoConfiguration.java @@ -14,7 +14,6 @@ import org.eclipse.hawkbit.im.authentication.MultitenancyIndicator; import org.eclipse.hawkbit.im.authentication.PermissionUtils; import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails; 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.security.SecurityProperties; 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.dao.DaoAuthenticationProvider; 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.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; @@ -37,8 +36,11 @@ import org.springframework.security.provisioning.InMemoryUserDetailsManager; @ConditionalOnMissingBean(UserDetailsService.class) public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticationConfigurerAdapter { - @Autowired - private SecurityProperties securityProperties; + private final SecurityProperties securityProperties; + + InMemoryUserManagementAutoConfiguration(final SecurityProperties securityProperties) { + this.securityProperties = securityProperties; + } @Override public void configure(final AuthenticationManagerBuilder auth) throws Exception { @@ -52,7 +54,7 @@ public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticatio */ @Bean @ConditionalOnMissingBean - public UserDetailsService userDetailsService() { + UserDetailsService userDetailsService() { final InMemoryUserDetailsManager inMemoryUserDetailsManager = new InMemoryUserPrincipalDetailsManager(); inMemoryUserDetailsManager.setAuthenticationManager(null); inMemoryUserDetailsManager.createUser(new User(securityProperties.getUser().getName(), @@ -65,7 +67,7 @@ public class InMemoryUserManagementAutoConfiguration extends GlobalAuthenticatio */ @Bean @ConditionalOnMissingBean - public MultitenancyIndicator multiTenancyIndicator() { + MultitenancyIndicator multiTenancyIndicator() { return () -> false; } diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 43d22652e..7bf2a2786 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -52,7 +52,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 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.ServletListenerRegistrationBean; import org.springframework.context.annotation.AdviceMode; @@ -108,9 +107,6 @@ public class SecurityManagedConfiguration { private static final int DOS_FILTER_ORDER = -200; - @Autowired - private AuthenticationConfiguration configuration; - /** * @return the {@link UserAuthenticationFilter} to include into the hawkBit * security configuration. @@ -122,7 +118,8 @@ public class SecurityManagedConfiguration { @ConditionalOnMissingBean // Exception squid:S00112 - Is aspectJ proxy @SuppressWarnings({ "squid:S00112" }) - public UserAuthenticationFilter userAuthenticationFilter() throws Exception { + UserAuthenticationFilter userAuthenticationFilter(final AuthenticationConfiguration configuration) + throws Exception { return new UserAuthenticationFilterBasicAuth(configuration.getAuthenticationManager()); } @@ -154,19 +151,19 @@ public class SecurityManagedConfiguration { private final TenantConfigurationManagement tenantConfigurationManagement; private final TenantAware tenantAware; private final DdiSecurityProperties ddiSecurityConfiguration; - private final SecurityProperties springSecurityProperties; + private final HawkbitSecurityProperties securityProperties; private final SystemSecurityContext systemSecurityContext; @Autowired ControllerSecurityConfigurationAdapter(final ControllerManagement controllerManagement, final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware, - final DdiSecurityProperties ddiSecurityConfiguration, final SecurityProperties springSecurityProperties, - final SystemSecurityContext systemSecurityContext) { + final DdiSecurityProperties ddiSecurityConfiguration, + final HawkbitSecurityProperties securityProperties, final SystemSecurityContext systemSecurityContext) { this.controllerManagement = controllerManagement; this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantAware = tenantAware; this.ddiSecurityConfiguration = ddiSecurityConfiguration; - this.springSecurityProperties = springSecurityProperties; + this.securityProperties = securityProperties; this.systemSecurityContext = systemSecurityContext; } @@ -219,7 +216,7 @@ public class SecurityManagedConfiguration { HttpSecurity httpSec = http.csrf().disable(); - if (springSecurityProperties.isRequireSsl()) { + if (securityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } @@ -270,19 +267,19 @@ public class SecurityManagedConfiguration { private final TenantConfigurationManagement tenantConfigurationManagement; private final TenantAware tenantAware; private final DdiSecurityProperties ddiSecurityConfiguration; - private final SecurityProperties springSecurityProperties; + private final HawkbitSecurityProperties securityProperties; private final SystemSecurityContext systemSecurityContext; @Autowired ControllerDownloadSecurityConfigurationAdapter(final ControllerManagement controllerManagement, final TenantConfigurationManagement tenantConfigurationManagement, final TenantAware tenantAware, - final DdiSecurityProperties ddiSecurityConfiguration, final SecurityProperties springSecurityProperties, - final SystemSecurityContext systemSecurityContext) { + final DdiSecurityProperties ddiSecurityConfiguration, + final HawkbitSecurityProperties securityProperties, final SystemSecurityContext systemSecurityContext) { this.controllerManagement = controllerManagement; this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantAware = tenantAware; this.ddiSecurityConfiguration = ddiSecurityConfiguration; - this.springSecurityProperties = springSecurityProperties; + this.securityProperties = securityProperties; this.systemSecurityContext = systemSecurityContext; } @@ -341,7 +338,7 @@ public class SecurityManagedConfiguration { HttpSecurity httpSec = http.csrf().disable(); - if (springSecurityProperties.isRequireSsl()) { + if (securityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } @@ -465,7 +462,7 @@ public class SecurityManagedConfiguration { private SystemManagement systemManagement; @Autowired - private SecurityProperties springSecurityProperties; + private HawkbitSecurityProperties securityProperties; @Autowired private SystemSecurityContext systemSecurityContext; @@ -497,10 +494,10 @@ public class SecurityManagedConfiguration { protected void configure(final HttpSecurity http) throws Exception { final BasicAuthenticationEntryPoint basicAuthEntryPoint = new BasicAuthenticationEntryPoint(); - basicAuthEntryPoint.setRealmName(springSecurityProperties.getBasic().getRealm()); + basicAuthEntryPoint.setRealmName(securityProperties.getBasicRealm()); HttpSecurity httpSec = http.regexMatcher("\\/rest.*|\\/system/admin.*").csrf().disable(); - if (springSecurityProperties.isRequireSsl()) { + if (securityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } @@ -545,9 +542,6 @@ public class SecurityManagedConfiguration { @Autowired private VaadinSecurityContext vaadinSecurityContext; - @Autowired - private SecurityProperties springSecurityProperties; - @Autowired private HawkbitSecurityProperties hawkbitSecurityProperties; @@ -635,7 +629,7 @@ public class SecurityManagedConfiguration { // disable as CSRF is handled by Vaadin .csrf().disable(); - if (springSecurityProperties.isRequireSsl()) { + if (hawkbitSecurityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } else { diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties index 20e120cf7..6b94c1003 100644 --- a/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties +++ b/hawkbit-autoconfigure/src/main/resources/hawkbit-security-defaults.properties @@ -7,12 +7,9 @@ # http://www.eclipse.org/legal/epl-v10.html # -# Displayed basic auth realm -security.basic.realm=HawkBit - # User Security -security.user.name=admin -security.user.password=admin +spring.security.user.name=admin +spring.security.user.password={noop}admin # DDI and download security hawkbit.server.ddi.security.authentication.header.enabled=false diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/TenantAware.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/TenantAware.java index 689f5b01a..d7d0ef70c 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/TenantAware.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/TenantAware.java @@ -10,10 +10,6 @@ package org.eclipse.hawkbit.tenancy; /** * Interface for components that are aware of the application's current tenant. - * - * - * - * */ public interface TenantAware { diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml b/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml index 3c14b94ac..fd11410eb 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml +++ b/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml @@ -59,9 +59,9 @@ spring-boot - com.fasterxml.jackson.core - jackson-databind - + org.springframework.boot + spring-boot-starter-json + com.google.guava guava diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java index 5a7e3e083..5f06b3619 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java @@ -20,7 +20,7 @@ import com.google.common.collect.Maps; * Bean which holds the necessary properties for configuring the AMQP deadletter * queue. */ -@ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter") +@ConfigurationProperties("hawkbit.dmf.rabbitmq.dead-letter") public class AmqpDeadletterProperties { private static final int THREE_WEEKS = 21; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java index 3cbb824df..080c29303 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java @@ -35,8 +35,8 @@ import org.eclipse.hawkbit.repository.SoftwareModuleManagement; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TargetManagement; 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.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; @@ -140,7 +140,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { .forEach( module -> modules.put(module, softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( - new PageRequest(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()) + PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()) .getContent())); targetManagement.getByControllerID(assignedEvent.getActions().keySet()) diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java index 493597a1e..69eb3a848 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java @@ -9,11 +9,9 @@ package org.eclipse.hawkbit.amqp; import java.net.URI; -import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; @@ -43,7 +41,6 @@ import org.springframework.amqp.AmqpRejectAndDontRequeueException; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.messaging.converter.MessageConversionException; import org.springframework.messaging.handler.annotation.Header; import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.core.Authentication; @@ -271,7 +268,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { if (isCorrelationIdNotEmpty(message)) { messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message correlation-id " - + convertCorrelationId(message)); + + message.getMessageProperties().getCorrelationId()); } final Status status = mapStatus(message, actionUpdateStatus, action); @@ -287,8 +284,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService { } private static boolean isCorrelationIdNotEmpty(final Message message) { - return message.getMessageProperties().getCorrelationId() != null - && message.getMessageProperties().getCorrelationId().length > 0; + return StringUtils.hasLength(message.getMessageProperties().getCorrelationId()); } // Exception squid:MethodCyclomaticComplexity - false positive, is a simple @@ -341,10 +337,6 @@ public class AmqpMessageHandlerService extends BaseAmqpService { 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) { if (Status.CANCELED.equals(status)) { return controllerManagement.addCancelActionStatus(actionStatus); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/ConfigurableRabbitListenerContainerFactory.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/ConfigurableRabbitListenerContainerFactory.java index e0610e274..d5dc8d204 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/ConfigurableRabbitListenerContainerFactory.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/ConfigurableRabbitListenerContainerFactory.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory; +import org.springframework.amqp.rabbit.listener.RabbitListenerEndpoint; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.util.ErrorHandler; @@ -44,8 +45,9 @@ public class ConfigurableRabbitListenerContainerFactory extends SimpleRabbitList // Exception squid:UnusedProtectedMethod - called by // AbstractRabbitListenerContainerFactory @SuppressWarnings("squid:UnusedProtectedMethod") - protected void initializeContainer(final SimpleMessageListenerContainer instance) { - super.initializeContainer(instance); + protected void initializeContainer(final SimpleMessageListenerContainer instance, + final RabbitListenerEndpoint endpoint) { + super.initializeContainer(instance, endpoint); instance.setDeclarationRetries(declarationRetries); } } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpMessageSenderService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpMessageSenderService.java index 3b60bc8d5..22e6dd528 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpMessageSenderService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpMessageSenderService.java @@ -9,15 +9,15 @@ package org.eclipse.hawkbit.amqp; import java.net.URI; -import java.nio.charset.StandardCharsets; import java.util.UUID; import org.eclipse.hawkbit.util.IpUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.support.CorrelationData; +import org.springframework.util.StringUtils; /** * 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(); if (isCorrelationIdEmpty(message)) { - message.getMessageProperties().setCorrelationId(correlationId.getBytes(StandardCharsets.UTF_8)); + message.getMessageProperties().setCorrelationId(correlationId); } if (LOGGER.isTraceEnabled()) { @@ -60,8 +60,7 @@ public class DefaultAmqpMessageSenderService extends BaseAmqpService implements } protected static boolean isCorrelationIdEmpty(final Message message) { - return message.getMessageProperties().getCorrelationId() == null - || message.getMessageProperties().getCorrelationId().length <= 0; + return !StringUtils.hasLength(message.getMessageProperties().getCorrelationId()); } } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java index 7596f0cbb..5b36ceff9 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthenticationTest.java @@ -10,9 +10,9 @@ package org.eclipse.hawkbit.amqp; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -51,7 +51,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; 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.MessageProperties; 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, new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null); - when(artifactManagementMock.loadArtifactBinary(SHA1)).thenReturn(Optional.of(artifact)); amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, mock(AmqpMessageDispatcherService.class), controllerManagementMock, new JpaEntityFactory()); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index c37e870e3..b9db0f2d6 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -12,9 +12,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; 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.support.converter.AbstractJavaTypeMapper; 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 io.qameta.allure.Description; @@ -69,7 +69,7 @@ import io.qameta.allure.Story; @ActiveProfiles({ "test" }) @Feature("Component Tests - Device Management Federation API") @Story("AmqpMessage Dispatcher Service Test") -@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class }) +@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }) public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { private static final String TENANT = "default"; @@ -214,7 +214,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { }); } } - + @Test @Description("Verifies that sending update controller attributes event works.") public void sendUpdateAttributesRequest() { diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index ac092af1d..a289756cf 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -10,10 +10,10 @@ package org.eclipse.hawkbit.amqp; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; 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.builder.ActionStatusBuilder; 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.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; @@ -60,7 +59,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.amqp.AmqpRejectAndDontRequeueException; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; @@ -392,8 +391,6 @@ public class AmqpMessageHandlerServiceTest { final Artifact localArtifactMock = mock(Artifact.class); when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock)); - when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyString(), anyLong())) - .thenThrow(EntityNotFoundException.class); // test final Message onMessage = amqpAuthenticationMessageHandlerService.onAuthenticationRequest(message); @@ -515,15 +512,11 @@ public class AmqpMessageHandlerServiceTest { final Target targetMock = mock(Target.class); final DistributionSet distributionSetMock = mock(DistributionSet.class); - when(distributionSetMock.getId()).thenReturn(1L); when(actionMock.getDistributionSet()).thenReturn(distributionSetMock); when(actionMock.getId()).thenReturn(targetId); - when(actionMock.getStatus()).thenReturn(status); when(actionMock.getTenant()).thenReturn("DEFAULT"); when(actionMock.getTarget()).thenReturn(targetMock); when(targetMock.getControllerId()).thenReturn("target1"); - when(targetMock.getSecurityToken()).thenReturn("securityToken"); - when(targetMock.getAddress()).thenReturn(null); return actionMock; } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java similarity index 95% rename from hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java rename to hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java index c3baeb155..21d50b68f 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AbstractAmqpServiceIntegrationTest.java @@ -39,6 +39,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; 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.util.IpUtil; 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.test.RabbitListenerTestHarness; 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; @@ -58,9 +60,10 @@ import io.qameta.allure.Step; * Common class for {@link AmqpMessageHandlerServiceIntegrationTest} and * {@link AmqpMessageDispatcherServiceIntegrationTest}. */ -@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, - DmfApiConfiguration.class, DmfTestConfiguration.class }) -public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest { +@ContextConfiguration(classes = { DmfApiConfiguration.class, DmfTestConfiguration.class, + RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class, + TestSupportBinderAutoConfiguration.class }) +public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest { protected static final String TENANT_EXIST = "DEFAULT"; 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) { - createConditionFactory().until(() -> { + createConditionFactory().untilAsserted(() -> { Mockito.verify(getDeadletterListener(), Mockito.times(expectedMessages)).handleMessage(Mockito.any()); }); } @@ -165,8 +168,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration final Map headers = replyMessage.getMessageProperties().getHeaders(); assertThat(headers.get(MessageHeaderKey.TENANT)).isEqualTo(TENANT_EXIST); - assertThat(correlationId) - .isEqualTo(new String(replyMessage.getMessageProperties().getCorrelationId(), StandardCharsets.UTF_8)); + assertThat(correlationId).isEqualTo(replyMessage.getMessageProperties().getCorrelationId()); assertThat(headers.get(MessageHeaderKey.TYPE)).isEqualTo(MessageType.PING_RESPONSE.toString()); assertThat(Long.valueOf(new String(replyMessage.getBody(), StandardCharsets.UTF_8))) .isLessThanOrEqualTo(System.currentTimeMillis()); @@ -213,7 +215,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration } protected void verifyReplyToListener() { - createConditionFactory().until(() -> { + createConditionFactory().untilAsserted(() -> { 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) { final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant); messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.PING.toString()); - messageProperties.setCorrelationId(correlationId.getBytes()); + messageProperties.setCorrelationId(correlationId); messageProperties.setReplyTo(DmfTestConfiguration.REPLY_TO_EXCHANGE); return createMessage(null, messageProperties); @@ -354,7 +356,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration protected void assertUpdateAttributes(final String controllerId, final Map attributes) { waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId)); - createConditionFactory().until(() -> { + createConditionFactory().untilAsserted(() -> { try { final Map controllerAttributes = securityRule .runAsPrivileged(() -> targetManagement.getControllerAttributes(controllerId)); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java index 80948d754..4a868ceb4 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpAuthenticationMessageHandlerIntegrationTest.java @@ -19,8 +19,6 @@ import org.eclipse.hawkbit.amqp.DmfApiConfiguration; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.json.model.DmfDownloadResponse; 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.DistributionSet; 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.rabbit.core.RabbitAdmin; 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.util.StringUtils; @@ -45,8 +43,7 @@ import io.qameta.allure.Story; @Feature("Component Tests - Device Management Federation API") @Story("Amqp Authentication Message Handler") -@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, - DmfApiConfiguration.class }) +@SpringBootTest(classes = { DmfApiConfiguration.class }) public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmqpIntegrationTest { private static final String TARGET_SECRUITY_TOKEN = "12345"; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java index 35c2f4bff..be8da4674 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java @@ -40,7 +40,7 @@ import io.qameta.allure.Story; @Feature("Component Tests - Device Management Federation API") @Story("Amqp Message Dispatcher Service") -public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceIntegrationTest { +public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest { private static final String TARGET_PREFIX = "Dmf_disp_"; @Test diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java index e099030ad..1ce6b9d41 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java @@ -58,7 +58,7 @@ import io.qameta.allure.Story; @Feature("Component Tests - Device Management Federation API") @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 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) { - createConditionFactory().await().until(() -> { + createConditionFactory().await().untilAsserted(() -> { try { securityRule.runAsPrivileged(() -> { final List actionStatusList = deploymentManagement @@ -870,7 +870,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra final MessageProperties messageProperties = createMessagePropertiesWithTenant(tenant); messageProperties.getHeaders().put(MessageHeaderKey.TYPE, MessageType.EVENT.toString()); messageProperties.getHeaders().put(MessageHeaderKey.TOPIC, eventTopic.toString()); - messageProperties.setCorrelationId(CORRELATION_ID.getBytes()); + messageProperties.setCorrelationId(CORRELATION_ID); return createMessage(payload, messageProperties); } @@ -896,7 +896,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AmqpServiceIntegra private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) { assertEmptyReceiverQueueCount(); - createConditionFactory().until(() -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)) - .handleMessage(Mockito.any())); + createConditionFactory().untilAsserted(() -> Mockito + .verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any())); } } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/listener/ReplyToListener.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/listener/ReplyToListener.java index 3367912c7..6218789c2 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/listener/ReplyToListener.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/listener/ReplyToListener.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.integration.listener; import static org.junit.Assert.fail; -import java.nio.charset.StandardCharsets; import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -53,9 +52,7 @@ public class ReplyToListener implements TestRabbitListener { } if (messageType == MessageType.PING_RESPONSE) { - final String correlationId = new String(message.getMessageProperties().getCorrelationId(), - StandardCharsets.UTF_8); - pingResponseMessages.put(correlationId, message); + pingResponseMessages.put(message.getMessageProperties().getCorrelationId(), message); return; } diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/pom.xml b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/pom.xml index 12c91dee1..ed11d6f3e 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/pom.xml +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/pom.xml @@ -9,58 +9,74 @@ --> - - 4.0.0 - - org.eclipse.hawkbit - hawkbit-dmf-parent - 0.3.0-SNAPSHOT - - hawkbit-dmf-rabbitmq-test - hawkBit :: DMF :: RabbitMq Test module + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-dmf-parent + 0.3.0-SNAPSHOT + + hawkbit-dmf-rabbitmq-test + hawkBit :: DMF :: RabbitMq Test module - - - org.eclipse.hawkbit - hawkbit-repository-api - ${project.version} - - - org.eclipse.hawkbit - hawkbit-repository-core - ${project.version} - - - org.eclipse.hawkbit - hawkbit-repository-jpa - ${project.version} - - - org.eclipse.hawkbit - hawkbit-dmf-api - ${project.version} - - - com.google.guava - guava - - - org.springframework.amqp - spring-rabbit-junit - compile - - - org.springframework.amqp - spring-rabbit-test - compile - - - org.eclipse.hawkbit - hawkbit-repository-test - ${project.version} - compile - - + + + org.eclipse.hawkbit + hawkbit-repository-api + ${project.version} + + + org.eclipse.hawkbit + hawkbit-repository-core + ${project.version} + + + org.eclipse.hawkbit + hawkbit-repository-jpa + ${project.version} + + + org.eclipse.hawkbit + hawkbit-dmf-api + ${project.version} + + + com.google.guava + guava + + + org.springframework.amqp + spring-rabbit-junit + compile + + + com.rabbitmq + http-client + compile + + + org.springframework + spring-web + compile + + + org.apache.httpcomponents + httpclient + compile + + + org.springframework.amqp + spring-rabbit-test + compile + + + org.eclipse.hawkbit + hawkbit-repository-test + ${project.version} + compile + + \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java index 8f8dd5a5a..4a82da78f 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java @@ -8,9 +8,13 @@ */ package org.eclipse.hawkbit.rabbitmq.test; +import java.time.Duration; 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.test.TestConfiguration; import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.junit.Before; 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.support.converter.Jackson2JsonMessageConverter; 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.ClassMode; +import org.springframework.test.context.ContextConfiguration; -import com.jayway.awaitility.Awaitility; -import com.jayway.awaitility.core.ConditionFactory; - -@SpringApplicationConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class }) +@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, + TestConfiguration.class, TestSupportBinderAutoConfiguration.class }) // Dirty context is necessary to create a new vhost and recreate all necessary // beans after every test class. @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest { + private static final Duration TIMEOUT = Duration.ofSeconds(5); @Rule @Autowired @@ -59,7 +63,7 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes } 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) { diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java index 60dd1bb2b..b6f9dcc40 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java @@ -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 * available. * - * */ +// exception squid:S2068 - Test instance passwd +@SuppressWarnings("squid:S2068") public class RabbitMqSetupService { private static final String GUEST = "guest"; @@ -44,7 +45,7 @@ public class RabbitMqSetupService { private String password; - public RabbitMqSetupService(RabbitProperties properties) { + public RabbitMqSetupService(final RabbitProperties properties) { hostname = properties.getHost(); username = properties.getUsername(); if (StringUtils.isEmpty(username)) { @@ -118,7 +119,7 @@ public class RabbitMqSetupService { static class AlivenessException extends RuntimeException { private static final long serialVersionUID = 1L; - public AlivenessException(String hostname) { + public AlivenessException(final String hostname) { super("Aliveness test failed for " + hostname + ":15672 guest/quest; rabbit mq management api not available"); } diff --git a/hawkbit-repository/hawkbit-repository-api/pom.xml b/hawkbit-repository/hawkbit-repository-api/pom.xml index 34454a7b8..620aa7f56 100644 --- a/hawkbit-repository/hawkbit-repository-api/pom.xml +++ b/hawkbit-repository/hawkbit-repository-api/pom.xml @@ -42,8 +42,20 @@ spring-boot-starter-tomcat - com.esotericsoftware - kryo-shaded + org.springframework.security + spring-security-rsa + + + org.objenesis + objenesis + + + org.apache.tomcat.embed + tomcat-embed-el + + + org.springframework.cloud + spring-cloud-function-context diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 77a4745c8..4142425ae 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -24,8 +24,8 @@ import org.eclipse.hawkbit.repository.builder.ActionStatusCreate; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; 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.QuotaExceededException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; 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 - * be possible that the controller will continue to work on the cancelation. - * The controller needs to acknowledge or reject the cancelation using - * {@link DdiRootController#postCancelActionFeedback}. + * be possible that the controller will continue to work on the + * cancellation. The controller needs to acknowledge or reject the + * cancellation using {@link DdiRootController#postCancelActionFeedback}. * * @param actionId * to be canceled diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java index 2617f292e..a0b4ccc3b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java @@ -21,7 +21,7 @@ import org.springframework.data.domain.Sort; public final class OffsetBasedPageRequest extends PageRequest { private static final long serialVersionUID = 1L; - private final int offset; + private final long offset; /** * Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed, @@ -32,8 +32,8 @@ public final class OffsetBasedPageRequest extends PageRequest { * @param limit * the limit of the page to be returned. */ - public OffsetBasedPageRequest(final int offset, final int limit) { - this(offset, limit, null); + public OffsetBasedPageRequest(final long offset, final int limit) { + this(offset, limit, Sort.unsorted()); } /** @@ -47,13 +47,13 @@ public final class OffsetBasedPageRequest extends PageRequest { * @param sort * 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); this.offset = offset; } @Override - public int getOffset() { + public long getOffset() { return offset; } @@ -67,7 +67,7 @@ public final class OffsetBasedPageRequest extends PageRequest { public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + offset; + result = prime * result + (int) (offset ^ (offset >>> 32)); return result; } @@ -79,11 +79,14 @@ public final class OffsetBasedPageRequest extends PageRequest { if (!super.equals(obj)) { return false; } - if (!(obj instanceof OffsetBasedPageRequest)) { + if (getClass() != obj.getClass()) { return false; } final OffsetBasedPageRequest other = (OffsetBasedPageRequest) obj; - return offset == other.offset; + if (offset != other.offset) { + return false; + } + return true; } } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index b8c77a18c..b11098cc7 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -631,6 +631,7 @@ public interface TargetManagement { * @throws EntityNotFoundException * if target with given ID does not exist */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) Map getControllerAttributes(@NotEmpty String controllerId); /** @@ -642,6 +643,7 @@ public interface TargetManagement { * @throws EntityNotFoundException * if target with given ID does not exist */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) void requestControllerAttributes(@NotEmpty String controllerId); /** @@ -652,8 +654,33 @@ public interface TargetManagement { * @return {@code true}: update of controller attributes triggered. * {@code false}: update of controller attributes not requested. */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) 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 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. * diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEvent.java index 0539f05b0..968a0aba7 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEvent.java @@ -40,7 +40,7 @@ public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements Te * the applicationId */ public RemoteTenantAwareEvent(final Object source, final String tenant, final String applicationId) { - super(source, applicationId, "**"); + super(source, applicationId); this.tenant = tenant; } diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactBinaryNotFoundException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactBinaryNotFoundException.java index 3ddea09ed..a1ad2ee41 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactBinaryNotFoundException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactBinaryNotFoundException.java @@ -25,7 +25,7 @@ public final class ArtifactBinaryNotFoundException extends AbstractServerRtExcep /** * Creates a new FileUploadFailedException with - * {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. + * {@link SpServerError#SP_ARTIFACT_LOAD_FAILED} error. */ public ArtifactBinaryNotFoundException() { super(SpServerError.SP_ARTIFACT_LOAD_FAILED); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java index c6ca45258..b4c76c1bf 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java @@ -26,7 +26,7 @@ public final class ArtifactDeleteFailedException extends AbstractServerRtExcepti /** * Creates a new FileUploadFailedException with - * {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. + * {@link SpServerError#SP_ARTIFACT_DELETE_FAILED} error. */ public ArtifactDeleteFailedException() { super(SpServerError.SP_ARTIFACT_DELETE_FAILED); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java index 268d31612..96331e400 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java @@ -22,7 +22,7 @@ public final class ArtifactUploadFailedException extends AbstractServerRtExcepti /** * Creates a new FileUploadFailedException with - * {@link SpServerError#SP_REST_BODY_NOT_READABLE} error. + * {@link SpServerError#SP_ARTIFACT_UPLOAD_FAILED} error. */ public ArtifactUploadFailedException() { super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED); diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyReplacer.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyReplacer.java index abdc671f7..366e61ec3 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyReplacer.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyReplacer.java @@ -8,13 +8,15 @@ */ package org.eclipse.hawkbit.repository.rsql; +import java.io.Serializable; + /** * Implementations map a placeholder to the associated value. *

* This is used in context of string replacement. */ @FunctionalInterface -public interface VirtualPropertyReplacer { +public interface VirtualPropertyReplacer extends Serializable { /** * Looks up a placeholders and replaces them diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/model/helper/EventPublisherHolder.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/model/helper/EventPublisherHolder.java index 5a5037ac6..f407916db 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/model/helper/EventPublisherHolder.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/model/helper/EventPublisherHolder.java @@ -9,7 +9,7 @@ package org.eclipse.hawkbit.repository.model.helper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; /** @@ -26,7 +26,7 @@ public final class EventPublisherHolder { private ApplicationEventPublisher eventPublisher; @Autowired - private ApplicationContext applicationContext; + private BusProperties bus; private EventPublisherHolder() { @@ -47,7 +47,7 @@ public final class EventPublisherHolder { } public String getApplicationId() { - return applicationContext.getId(); + return bus.getId(); } } diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyResolver.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyResolver.java index 63853895a..f924de103 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyResolver.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/rsql/VirtualPropertyResolver.java @@ -42,10 +42,12 @@ import org.eclipse.hawkbit.repository.TimestampCalculator; */ public class VirtualPropertyResolver extends StrLookup implements VirtualPropertyReplacer { - private StrSubstitutor substitutor; + private static final long serialVersionUID = 1L; + + private transient StrSubstitutor substitutor; @Override - public String lookup(String rhs) { + public String lookup(final String rhs) { String resolved = null; if ("now_ts".equalsIgnoreCase(rhs)) { @@ -57,7 +59,7 @@ public class VirtualPropertyResolver extends StrLookup implements Virtua } @Override - public String replace(String input) { + public String replace(final String input) { if (substitutor == null) { substitutor = new StrSubstitutor(this, StrSubstitutor.DEFAULT_PREFIX, StrSubstitutor.DEFAULT_SUFFIX, StrSubstitutor.DEFAULT_ESCAPE); diff --git a/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java b/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java index e4e90ad0d..db5643290 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java +++ b/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java @@ -21,7 +21,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cloud.bus.event.RemoteApplicationEvent; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/hawkbit-repository/hawkbit-repository-jpa/pom.xml b/hawkbit-repository/hawkbit-repository-jpa/pom.xml index b1bc5d747..87b4bc0ec 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/pom.xml +++ b/hawkbit-repository/hawkbit-repository-jpa/pom.xml @@ -103,16 +103,6 @@ allure-junit4 test - - org.powermock - powermock-module-junit4 - test - - - org.powermock - powermock-api-mockito - test - @@ -121,7 +111,7 @@ com.ethlo.persistence.tools eclipselink-maven-plugin - 2.7.0 + 2.7.1.1 modelgen diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/AbstractDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/AbstractDsAssignmentStrategy.java index 46c320966..a88c9adbd 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/AbstractDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/AbstractDsAssignmentStrategy.java @@ -34,7 +34,7 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; import org.springframework.util.CollectionUtils; @@ -50,19 +50,19 @@ public abstract class AbstractDsAssignmentStrategy { protected final TargetRepository targetRepository; protected final AfterTransactionCommitExecutor afterCommit; protected final ApplicationEventPublisher eventPublisher; - protected final ApplicationContext applicationContext; + protected final BusProperties bus; private final ActionRepository actionRepository; private final ActionStatusRepository actionStatusRepository; private final QuotaManagement quotaManagement; AbstractDsAssignmentStrategy(final TargetRepository targetRepository, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final ActionRepository actionRepository, + final BusProperties bus, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { this.targetRepository = targetRepository; this.afterCommit = afterCommit; this.eventPublisher = eventPublisher; - this.applicationContext = applicationContext; + this.bus = bus; this.actionRepository = actionRepository; this.actionStatusRepository = actionStatusRepository; this.quotaManagement = quotaManagement; @@ -138,14 +138,12 @@ public abstract class AbstractDsAssignmentStrategy { return; } - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, distributionSetId, - actions, applicationContext.getId(), actions.get(0).isMaintenanceWindowAvailable()))); + afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, + distributionSetId, actions, bus.getId(), actions.get(0).isMaintenanceWindowAvailable()))); } protected void sendTargetUpdatedEvent(final JpaTarget target) { - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId()))); + afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId()))); } /** @@ -216,8 +214,8 @@ public abstract class AbstractDsAssignmentStrategy { * the action id of the assignment */ void cancelAssignDistributionSetEvent(final Target target, final Long actionId) { - afterCommit.afterCommit(() -> eventPublisher - .publishEvent(new CancelTargetAssignmentEvent(target, actionId, applicationContext.getId()))); + afterCommit.afterCommit( + () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId()))); } JpaAction createTargetAction(final Map targetsWithActionMap, final JpaTarget target, diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetRepository.java index f8edc6c8f..50573b298 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetRepository.java @@ -147,7 +147,7 @@ public interface DistributionSetRepository @Override // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 @Query("SELECT d FROM JpaDistributionSet d WHERE d.id IN ?1") - List findAll(Iterable ids); + List findAllById(Iterable ids); /** * Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTagRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTagRepository.java index 2c319bfa6..e7d35eef3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTagRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTagRepository.java @@ -86,5 +86,5 @@ public interface DistributionSetTagRepository @Override // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 @Query("SELECT d FROM JpaDistributionSetTag d WHERE d.id IN ?1") - List findAll(Iterable ids); + List findAllById(Iterable ids); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTypeRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTypeRepository.java index 5eb3c8c10..65ca4e3d8 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTypeRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DistributionSetTypeRepository.java @@ -93,7 +93,7 @@ public interface DistributionSetTypeRepository */ @Override @Query("SELECT d FROM JpaDistributionSetType d WHERE d.id IN ?1") - List findAll(Iterable ids); + List findAllById(Iterable ids); /** * Counts the {@link SoftwareModuleType}s which are associated with the diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java index 06da6f156..e3568cd96 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaArtifactManagement.java @@ -193,12 +193,12 @@ public class JpaArtifactManagement implements ArtifactManagement { ((JpaSoftwareModule) existing.getSoftwareModule()).removeArtifact(existing); softwareModuleRepository.save((JpaSoftwareModule) existing.getSoftwareModule()); - localArtifactRepository.delete(id); + localArtifactRepository.deleteById(id); } @Override public Optional get(final long id) { - return Optional.ofNullable(localArtifactRepository.findOne(id)); + return Optional.ofNullable(localArtifactRepository.findById(id).orElse(null)); } @Override @@ -226,7 +226,7 @@ public class JpaArtifactManagement implements ArtifactManagement { } private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) { - if (!softwareModuleRepository.exists(swId)) { + if (!softwareModuleRepository.existsById(swId)) { throw new EntityNotFoundException(SoftwareModule.class, swId); } } @@ -256,13 +256,8 @@ public class JpaArtifactManagement implements ArtifactManagement { } private SoftwareModule getModuleAndThrowExceptionIfThatFails(final Long moduleId) { - final SoftwareModule softwareModule = softwareModuleRepository.findOne(moduleId); - - if (softwareModule == null) { - LOG.debug("no software module with ID {} exists", moduleId); - throw new EntityNotFoundException(SoftwareModule.class, moduleId); - } - return softwareModule; + return softwareModuleRepository.findById(moduleId) + .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index 81858c11c..e914c0a3c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -40,10 +40,10 @@ import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper; import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.RepositoryConstants; import org.eclipse.hawkbit.repository.RepositoryProperties; -import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.UpdateMode; 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.entity.CancelTargetAssignmentEvent; 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.LoggerFactory; 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.dao.ConcurrencyFailureException; 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.validation.annotation.Validated; -import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -119,9 +118,6 @@ public class JpaControllerManagement implements ControllerManagement { @Autowired private TargetRepository targetRepository; - @Autowired - private TargetManagement targetManagement; - @Autowired private SoftwareModuleRepository softwareModuleRepository; @@ -144,7 +140,7 @@ public class JpaControllerManagement implements ControllerManagement { private ApplicationEventPublisher eventPublisher; @Autowired - private ApplicationContext applicationContext; + private BusProperties bus; @Autowired private AfterTransactionCommitExecutor afterCommit; @@ -215,7 +211,7 @@ public class JpaControllerManagement implements ControllerManagement { return getPollingTime(); } - return (new EventTimer(getPollingTime(), getMinPollingTime(), ChronoUnit.SECONDS)) + return new EventTimer(getPollingTime(), getMinPollingTime(), ChronoUnit.SECONDS) .timeToNextEvent(getMaintenanceWindowPollCount(), action.getMaintenanceWindowStartTime().orElse(null)); } @@ -324,13 +320,13 @@ public class JpaControllerManagement implements ControllerManagement { } private void throwExceptionIfTargetDoesNotExist(final Long targetId) { - if (!targetRepository.exists(targetId)) { + if (!targetRepository.existsById(targetId)) { throw new EntityNotFoundException(Target.class, targetId); } } private void throwExceptionIfSoftwareModuleDoesNotExist(final Long moduleId) { - if (!softwareModuleRepository.exists(moduleId)) { + if (!softwareModuleRepository.existsById(moduleId)) { throw new EntityNotFoundException(SoftwareModule.class, moduleId); } } @@ -372,21 +368,20 @@ public class JpaControllerManagement implements ControllerManagement { final Specification spec = (targetRoot, query, cb) -> cb .equal(targetRoot.get(JpaTarget_.controllerId), controllerId); - final JpaTarget target = targetRepository.findOne(spec); + final Optional target = targetRepository.findOne(spec); - if (target == null) { + if (!target.isPresent()) { final Target result = targetRepository.save((JpaTarget) entityFactory.target().create() .controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId) .status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis()) .address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build()); - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new TargetPollEvent(result, applicationContext.getId()))); + afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(result, bus.getId()))); return result; } - return updateTargetStatus(target, address); + return updateTargetStatus(target.get(), address); } /** @@ -433,8 +428,8 @@ public class JpaControllerManagement implements ControllerManagement { pollChunks.forEach(chunk -> { setLastTargetQuery(tenant, System.currentTimeMillis(), chunk); - chunk.forEach(controllerId -> afterCommit.afterCommit(() -> eventPublisher - .publishEvent(new TargetPollEvent(controllerId, tenant, applicationContext.getId())))); + chunk.forEach(controllerId -> afterCommit.afterCommit( + () -> eventPublisher.publishEvent(new TargetPollEvent(controllerId, tenant, bus.getId())))); }); return null; @@ -468,7 +463,7 @@ public class JpaControllerManagement implements ControllerManagement { } private static String formatQueryInStatementParams(final Collection paramNames) { - return "#" + Joiner.on(",#").join(paramNames); + return "#" + String.join(",#", paramNames); } /** @@ -488,8 +483,7 @@ public class JpaControllerManagement implements ControllerManagement { toUpdate.setAddress(address.toString()); toUpdate.setLastTargetQuery(System.currentTimeMillis()); - afterCommit.afterCommit( - () -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, applicationContext.getId()))); + afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(toUpdate, bus.getId()))); return targetRepository.save(toUpdate); } @@ -583,7 +577,7 @@ public class JpaControllerManagement implements ControllerManagement { private boolean actionIsNotActiveButIntermediateFeedbackStillAllowed(final ActionStatus actionStatus, final boolean actionActive) { 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); if (controllerId != null) { - targetManagement.requestControllerAttributes(controllerId); + requestControllerAttributes(controllerId); } 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) { mergedAction.setActive(false); mergedAction.setStatus(Status.ERROR); @@ -823,12 +828,12 @@ public class JpaControllerManagement implements ControllerManagement { @Override public Optional get(final long targetId) { - return Optional.ofNullable(targetRepository.findOne(targetId)); + return targetRepository.findById(targetId).map(t -> (Target) t); } @Override public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { - if (!actionRepository.exists(actionId)) { + if (!actionRepository.existsById(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -848,7 +853,7 @@ public class JpaControllerManagement implements ControllerManagement { ? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT : 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 messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId, RepositoryConstants.SERVER_MESSAGE_PREFIX + "%"); @@ -860,7 +865,7 @@ public class JpaControllerManagement implements ControllerManagement { @Override public Optional getSoftwareModule(final long id) { - return Optional.ofNullable(softwareModuleRepository.findOne(id)); + return softwareModuleRepository.findById(id).map(s -> (SoftwareModule) s); } @Override @@ -868,7 +873,7 @@ public class JpaControllerManagement implements ControllerManagement { final Collection moduleId) { return softwareModuleMetadataRepository - .findBySoftwareModuleIdInAndTargetVisible(new PageRequest(0, RepositoryConstants.MAX_META_DATA_COUNT), + .findBySoftwareModuleIdInAndTargetVisible(PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), moduleId, true) .getContent().stream().collect(Collectors.groupingBy(o -> (Long) o[0], Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList()))); @@ -896,8 +901,8 @@ public class JpaControllerManagement implements ControllerManagement { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((controllerId == null) ? 0 : controllerId.hashCode()); - result = prime * result + ((tenant == null) ? 0 : tenant.hashCode()); + result = prime * result + (controllerId == null ? 0 : controllerId.hashCode()); + result = prime * result + (tenant == null ? 0 : tenant.hashCode()); return result; } @@ -980,7 +985,7 @@ public class JpaControllerManagement implements ControllerManagement { } private void cancelAssignDistributionSetEvent(final JpaTarget target, final Long actionId) { - afterCommit.afterCommit(() -> eventPublisher - .publishEvent(new CancelTargetAssignmentEvent(target, actionId, applicationContext.getId()))); + afterCommit.afterCommit( + () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId()))); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java index 2dad441cb..3a154b338 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDeploymentManagement.java @@ -69,7 +69,7 @@ import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; import org.springframework.dao.ConcurrencyFailureException; import org.springframework.data.domain.AuditorAware; @@ -88,7 +88,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; -import com.google.common.base.Joiner; import com.google.common.collect.Lists; /** @@ -125,7 +124,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { private final TargetManagement targetManagement; private final AuditorAware auditorProvider; private final ApplicationEventPublisher eventPublisher; - private final ApplicationContext applicationContext; + private final BusProperties bus; private final AfterTransactionCommitExecutor afterCommit; private final VirtualPropertyReplacer virtualPropertyReplacer; private final PlatformTransactionManager txManager; @@ -141,7 +140,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { final DistributionSetRepository distributionSetRepository, final TargetRepository targetRepository, final ActionStatusRepository actionStatusRepository, final TargetManagement targetManagement, final AuditorAware auditorProvider, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final AfterTransactionCommitExecutor afterCommit, + final BusProperties bus, final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final Database database) { @@ -153,14 +152,14 @@ public class JpaDeploymentManagement implements DeploymentManagement { this.targetManagement = targetManagement; this.auditorProvider = auditorProvider; this.eventPublisher = eventPublisher; - this.applicationContext = applicationContext; + this.bus = bus; this.afterCommit = afterCommit; this.virtualPropertyReplacer = virtualPropertyReplacer; this.txManager = txManager; - onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, - applicationContext, actionRepository, actionStatusRepository, quotaManagement); + onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, bus, + actionRepository, actionStatusRepository, quotaManagement); offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisher, - applicationContext, actionRepository, actionStatusRepository, quotaManagement); + bus, actionRepository, actionStatusRepository, quotaManagement); this.tenantConfigurationManagement = tenantConfigurationManagement; this.quotaManagement = quotaManagement; this.systemSecurityContext = systemSecurityContext; @@ -367,7 +366,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { private void setAssignedDistributionSetAndTargetUpdateStatus(final AbstractDsAssignmentStrategy assignmentStrategy, final JpaDistributionSet set, final List> targetIdsChunks) { - final String currentUser = auditorProvider != null ? auditorProvider.getCurrentAuditor() : null; + final String currentUser = auditorProvider.getCurrentAuditor().orElse(null); assignmentStrategy.updateTargetStatus(set, targetIdsChunks, currentUser); } @@ -385,7 +384,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { private void createActionsStatus(final Collection actions, final AbstractDsAssignmentStrategy assignmentStrategy, final String actionMessage) { actionStatusRepository - .save(actions.stream().map(action -> assignmentStrategy.createActionStatus(action, actionMessage)) + .saveAll(actions.stream().map(action -> assignmentStrategy.createActionStatus(action, actionMessage)) .collect(Collectors.toList())); } @@ -493,7 +492,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { if (!CollectionUtils.isEmpty(targetAssignments)) { afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, - distributionSetId, targetAssignments, applicationContext.getId(), maintenanceWindowAvailable))); + distributionSetId, targetAssignments, bus.getId(), maintenanceWindowAvailable))); } return rolloutGroupActions.getTotalElements(); @@ -503,7 +502,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { private Page findActionsByRolloutAndRolloutGroupParent(final Long rolloutId, final Long rolloutGroupParentId, final int limit) { - final PageRequest pageRequest = new PageRequest(0, limit); + final PageRequest pageRequest = PageRequest.of(0, limit); if (rolloutGroupParentId == null) { return actionRepository.findByRolloutIdAndRolloutGroupParentIsNullAndStatus(pageRequest, rolloutId, Action.Status.SCHEDULED); @@ -577,7 +576,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Override public Optional findAction(final long actionId) { - return Optional.ofNullable(actionRepository.findOne(actionId)); + return actionRepository.findById(actionId).map(a -> (Action) a); } @Override @@ -644,7 +643,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } private void throwExceptionIfDistributionSetDoesNotExist(final Long dsId) { - if (!distributionSetRepository.exists(dsId)) { + if (!distributionSetRepository.existsById(dsId)) { throw new EntityNotFoundException(DistributionSet.class, dsId); } } @@ -666,7 +665,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { @Override public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { - if (!actionRepository.exists(actionId)) { + if (!actionRepository.existsById(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -690,7 +689,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { final CriteriaQuery selMsgQuery = msgQuery.select(join); selMsgQuery.where(cb.equal(as.get(JpaActionStatus_.id), actionStatusId)); - final List result = entityManager.createQuery(selMsgQuery).setFirstResult(pageable.getOffset()) + final List result = entityManager.createQuery(selMsgQuery).setFirstResult((int) pageable.getOffset()) .setMaxResults(pageable.getPageSize()).getResultList().stream().collect(Collectors.toList()); return new PageImpl<>(result, pageable, totalCount); @@ -777,7 +776,7 @@ public class JpaDeploymentManagement implements DeploymentManagement { } private static String formatInClause(final Collection elements) { - return "#" + Joiner.on(",#").join(elements); + return "#" + String.join(",#", elements); } protected ActionRepository getActionRepository() { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java index c7852f80e..76a96efa8 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetManagement.java @@ -57,7 +57,7 @@ import org.eclipse.hawkbit.repository.model.MetaData; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; 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.dao.ConcurrencyFailureException; import org.springframework.data.domain.Page; @@ -105,7 +105,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { private final ApplicationEventPublisher eventPublisher; - private final ApplicationContext applicationContext; + private final BusProperties bus; private final TenantAware tenantAware; @@ -126,7 +126,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { final DistributionSetMetadataRepository distributionSetMetadataRepository, final TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository, final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final TenantAware tenantAware, + final BusProperties bus, final TenantAware tenantAware, final VirtualPropertyReplacer virtualPropertyReplacer, final SoftwareModuleRepository softwareModuleRepository, final DistributionSetTagRepository distributionSetTagRepository, @@ -142,7 +142,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { this.actionRepository = actionRepository; this.criteriaNoCountDao = criteriaNoCountDao; this.eventPublisher = eventPublisher; - this.applicationContext = applicationContext; + this.bus = bus; this.tenantAware = tenantAware; this.virtualPropertyReplacer = virtualPropertyReplacer; this.softwareModuleRepository = softwareModuleRepository; @@ -153,7 +153,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Override public Optional getWithDetails(final long distid) { - return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid))); + return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)) + .map(d -> (DistributionSet) d); } @Override @@ -242,7 +243,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } private JpaSoftwareModule findSoftwareModuleAndThrowExceptionIfNotFound(final Long moduleId) { - return Optional.ofNullable(softwareModuleRepository.findOne(moduleId)) + return softwareModuleRepository.findById(moduleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)); } @@ -282,7 +283,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { afterCommit.afterCommit(() -> distributionSetIDs.forEach( dsId -> eventPublisher.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), - dsId, JpaDistributionSet.class.getName(), applicationContext.getId())))); + dsId, JpaDistributionSet.class.getName(), bus.getId())))); } @Override @@ -370,12 +371,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { * @return a single DistributionSet which is either installed or assigned to * a specific target or {@code null}. */ - private DistributionSet findDistributionSetsByFiltersAndInstalledOrAssignedTarget( + private Optional findDistributionSetsByFiltersAndInstalledOrAssignedTarget( final DistributionSetFilter distributionSetFilter) { final List> specList = buildDistributionSetSpecifications( distributionSetFilter); if (CollectionUtils.isEmpty(specList)) { - return null; + return Optional.empty(); } return distributionSetRepository.findOne(SpecificationsBuilder.combineWithAnd(specList)); } @@ -400,12 +401,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder .setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build(); - final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( + final Optional installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( filterWithInstalledTargets); final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null) .setAssignedTargetId(assignedOrInstalled).build(); - final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( + final Optional assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( filterWithAssignedTargets); final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null) @@ -417,20 +418,20 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { final List resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent()); int orderIndex = 0; - if (installedDS != null) { - final boolean remove = resultSet.remove(installedDS); + if (installedDS.isPresent()) { + final boolean remove = resultSet.remove(installedDS.get()); if (!remove) { resultSet.remove(resultSet.size() - 1); } - resultSet.add(orderIndex, installedDS); + resultSet.add(orderIndex, installedDS.get()); orderIndex++; } - if (assignedDS != null && !assignedDS.equals(installedDS)) { - final boolean remove = resultSet.remove(assignedDS); + if (assignedDS.isPresent() && !assignedDS.equals(installedDS)) { + final boolean remove = resultSet.remove(assignedDS.get()); if (!remove) { resultSet.remove(resultSet.size() - 1); } - resultSet.add(orderIndex, assignedDS); + resultSet.add(orderIndex, assignedDS.get()); } return new PageImpl<>(resultSet, pageable, findDistributionSetsByFilters.getTotalElements()); @@ -440,7 +441,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { public Optional getByNameAndVersion(final String distributionName, final String version) { final Specification spec = DistributionSetSpecification .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)); touch(metadata.getDistributionSet()); - distributionSetMetadataRepository.delete(metadata.getId()); + distributionSetMetadataRepository.deleteById(metadata.getId()); } /** @@ -579,12 +580,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { public Optional getMetaDataByDistributionSetId(final long setId, final String key) { throwExceptionIfDistributionSetDoesNotExist(setId); - return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key))); + return distributionSetMetadataRepository.findById(new DsMetadataCompositeKey(setId, key)) + .map(dmd -> (DistributionSetMetadata) dmd); } @Override public Optional getByAction(final long actionId) { - if (!actionRepository.exists(actionId)) { + if (!actionRepository.existsById(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } @@ -676,7 +678,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } private void checkAndThrowIfDistributionSetMetadataAlreadyExists(final DsMetadataCompositeKey metadataId) { - if (distributionSetMetadataRepository.exists(metadataId)) { + if (distributionSetMetadataRepository.existsById(metadataId)) { throw new EntityAlreadyExistsException( "Metadata entry with key '" + metadataId.getKey() + "' already exists"); } @@ -738,14 +740,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) { - if (!distributionSetRepository.exists(setId)) { + if (!distributionSetRepository.existsById(setId)) { throw new EntityNotFoundException(DistributionSet.class, setId); } } @Override public List get(final Collection ids) { - return Collections.unmodifiableList(distributionSetRepository.findAll(ids)); + return Collections.unmodifiableList(distributionSetRepository.findAllById(ids)); } @Override @@ -757,7 +759,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } private void throwEntityNotFoundExceptionIfDsTagDoesNotExist(final Long tagId) { - if (!distributionSetTagRepository.exists(tagId)) { + if (!distributionSetTagRepository.existsById(tagId)) { throw new EntityNotFoundException(DistributionSetTag.class, tagId); } } @@ -791,12 +793,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { @Override public Optional get(final long id) { - return Optional.ofNullable(distributionSetRepository.findOne(id)); + return distributionSetRepository.findById(id).map(d -> (DistributionSet) d); } @Override public boolean exists(final long id) { - return distributionSetRepository.exists(id); + return distributionSetRepository.existsById(id); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java index 2b7cb8fe0..37344deee 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTagManagement.java @@ -142,7 +142,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage @Override public Page findByDistributionSet(final Pageable pageable, final long setId) { - if (!distributionSetRepository.exists(setId)) { + if (!distributionSetRepository.existsById(setId)) { throw new EntityNotFoundException(DistributionSet.class, setId); } @@ -165,24 +165,24 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection ids) { - final List setsFound = distributionSetTagRepository.findAll(ids); + final List setsFound = distributionSetTagRepository.findAllById(ids); if (setsFound.size() < ids.size()) { throw new EntityNotFoundException(DistributionSetTag.class, ids, setsFound.stream().map(DistributionSetTag::getId).collect(Collectors.toList())); } - distributionSetTagRepository.delete(setsFound); + distributionSetTagRepository.deleteAll(setsFound); } @Override public List get(final Collection ids) { - return Collections.unmodifiableList(distributionSetTagRepository.findAll(ids)); + return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids)); } @Override public Optional get(final long id) { - return Optional.ofNullable(distributionSetTagRepository.findOne(id)); + return distributionSetTagRepository.findById(id).map(dst -> (DistributionSetTag) dst); } @Override @@ -190,12 +190,12 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final long id) { - distributionSetTagRepository.delete(id); + distributionSetTagRepository.deleteById(id); } @Override public boolean exists(final long id) { - return distributionSetTagRepository.exists(id); + return distributionSetTagRepository.existsById(id); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java index 668bdf6fe..0e2c968fa 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaDistributionSetTypeManagement.java @@ -99,9 +99,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId()); update.getMandatory().ifPresent( - mand -> softwareModuleTypeRepository.findAll(mand).forEach(type::addMandatoryModuleType)); - update.getOptional() - .ifPresent(opt -> softwareModuleTypeRepository.findAll(opt).forEach(type::addOptionalModuleType)); + mand -> softwareModuleTypeRepository.findAllById(mand).forEach(type::addMandatoryModuleType)); + update.getOptional().ifPresent( + opt -> softwareModuleTypeRepository.findAllById(opt).forEach(type::addOptionalModuleType)); } 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)) public DistributionSetType assignMandatorySoftwareModuleTypes(final long dsTypeId, final Collection softwareModulesTypeIds) { - final Collection modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); + final Collection modules = softwareModuleTypeRepository + .findAllById(softwareModulesTypeIds); if (modules.size() < softwareModulesTypeIds.size()) { throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds, @@ -136,7 +137,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana public DistributionSetType assignOptionalSoftwareModuleTypes(final long dsTypeId, final Collection softwareModulesTypeIds) { - final Collection modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds); + final Collection modules = softwareModuleTypeRepository + .findAllById(softwareModulesTypeIds); if (modules.size() < softwareModulesTypeIds.size()) { throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds, @@ -206,13 +208,14 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Override public Optional getByName(final String name) { - return Optional - .ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name))); + return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)) + .map(dst -> (DistributionSetType) dst); } @Override public Optional getByKey(final String key) { - return Optional.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key))); + return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)) + .map(dst -> (DistributionSetType) dst); } @Override @@ -238,7 +241,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana toDelete.setDeleted(true); distributionSetTypeRepository.save(toDelete); } else { - distributionSetTypeRepository.delete(typeId); + distributionSetTypeRepository.deleteById(typeId); } } @@ -291,29 +294,29 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection ids) { - final List setsFound = distributionSetTypeRepository.findAll(ids); + final List setsFound = distributionSetTypeRepository.findAllById(ids); if (setsFound.size() < ids.size()) { throw new EntityNotFoundException(DistributionSetType.class, ids, setsFound.stream().map(DistributionSetType::getId).collect(Collectors.toList())); } - distributionSetTypeRepository.delete(setsFound); + distributionSetTypeRepository.deleteAll(setsFound); } @Override public List get(final Collection ids) { - return Collections.unmodifiableList(distributionSetTypeRepository.findAll(ids)); + return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids)); } @Override public Optional get(final long id) { - return Optional.ofNullable(distributionSetTypeRepository.findOne(id)); + return distributionSetTypeRepository.findById(id).map(dst -> (DistributionSetType) dst); } @Override public boolean exists(final long id) { - return distributionSetTypeRepository.exists(id); + return distributionSetTypeRepository.existsById(id); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java index d09239897..0b9bc171e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutGroupManagement.java @@ -96,7 +96,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { @Override public Optional get(final long rolloutGroupId) { - return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId)); + return rolloutGroupRepository.findById(rolloutGroupId).map(rg -> (RolloutGroup) rg); } @Override @@ -128,7 +128,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } private void throwEntityNotFoundExceptionIfRolloutDoesNotExist(final Long rolloutId) { - if (!rolloutRepository.exists(rolloutId)) { + if (!rolloutRepository.existsById(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), rolloutGroupId)); final List 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])) .collect(Collectors.toList()); @@ -285,7 +285,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } private void throwExceptionIfRolloutGroupDoesNotExist(final Long rolloutGroupId) { - if (!rolloutGroupRepository.exists(rolloutGroupId)) { + if (!rolloutGroupRepository.existsById(rolloutGroupId)) { throw new EntityNotFoundException(RolloutGroup.class, rolloutGroupId); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java index c116c0b83..15e8c5296 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java @@ -77,6 +77,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEventPublisher; import org.springframework.dao.ConcurrencyFailureException; @@ -149,20 +150,21 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Autowired private RolloutStatusCache rolloutStatusCache; - @Autowired - private ApplicationContext applicationContext; + private final BusProperties bus; private final Database database; JpaRolloutManagement(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement, final DistributionSetManagement distributionSetManagement, final ApplicationContext context, - final ApplicationEventPublisher eventPublisher, final VirtualPropertyReplacer virtualPropertyReplacer, - final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry, - final Database database, final RolloutApprovalStrategy rolloutApprovalStrategy) { + final BusProperties bus, final ApplicationEventPublisher eventPublisher, + final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, + final TenantAware tenantAware, final LockRegistry lockRegistry, final Database database, + final RolloutApprovalStrategy rolloutApprovalStrategy) { super(targetManagement, deploymentManagement, rolloutGroupManagement, distributionSetManagement, context, eventPublisher, virtualPropertyReplacer, txManager, tenantAware, lockRegistry, rolloutApprovalStrategy); this.database = database; + this.bus = bus; } @Override @@ -194,7 +196,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Override public Optional get(final long rolloutId) { - return Optional.ofNullable(rolloutRepository.findOne(rolloutId)); + return rolloutRepository.findById(rolloutId).map(r -> (Rollout) r); } @Override @@ -337,7 +339,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId()); final List 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(); int readyGroups = 0; @@ -431,7 +433,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { final String targetFilter, final long limit) { 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 readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(), RolloutGroupStatus.READY, group); final Page 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) { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> { - final PageRequest pageRequest = new PageRequest(0, limit); - final Rollout rollout = rolloutRepository.findOne(rolloutId); - final RolloutGroup group = rolloutGroupRepository.findOne(groupId); + final PageRequest pageRequest = PageRequest.of(0, limit); + final Rollout rollout = rolloutRepository.findById(rolloutId) + .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId)); + final RolloutGroup group = rolloutGroupRepository.findById(groupId) + .orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, groupId)); final DistributionSet distributionSet = rollout.getDistributionSet(); 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); - final JpaRollout rollout = rolloutRepository.findOne(rolloutId); + final JpaRollout rollout = rolloutRepository.findById(rolloutId) + .orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId)); switch (rollout.getStatus()) { case CREATING: @@ -882,7 +887,8 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) 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) { throw new EntityNotFoundException(Rollout.class, rolloutId); @@ -945,7 +951,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, - JpaRolloutGroup.class.getName(), applicationContext.getId())))); + JpaRolloutGroup.class.getName(), bus.getId())))); } private void hardDeleteRollout(final JpaRollout rollout) { @@ -971,7 +977,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { } private Slice 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); } @@ -1071,7 +1077,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement { @Override public boolean exists(final long rolloutId) { - return rolloutRepository.exists(rolloutId); + return rolloutRepository.existsById(rolloutId); } private Map> getStatusCountItemForRollout(final List rollouts) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java index 5fb339b18..9c4434ea1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleManagement.java @@ -180,7 +180,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) { - if (!softwareModuleTypeRepository.exists(typeId)) { + if (!softwareModuleTypeRepository.existsById(typeId)) { throw new EntityNotFoundException(SoftwareModuleType.class, typeId); } } @@ -201,7 +201,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Override public Optional get(final long id) { - return Optional.ofNullable(softwareModuleRepository.findOne(id)); + return softwareModuleRepository.findById(id).map(sm -> (SoftwareModule) sm); } @Override @@ -252,7 +252,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { deleteGridFsArtifacts(swModule); if (isUnassigned(swModule.getId())) { - softwareModuleRepository.delete(swModule.getId()); + softwareModuleRepository.deleteById(swModule.getId()); } else { assignedModuleIds.add(swModule.getId()); } @@ -261,7 +261,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { if (!assignedModuleIds.isEmpty()) { String currentUser = null; if (auditorProvider != null) { - currentUser = auditorProvider.getCurrentAuditor(); + currentUser = auditorProvider.getCurrentAuditor().orElse(null); } softwareModuleRepository.deleteSoftwareModule(System.currentTimeMillis(), currentUser, assignedModuleIds.toArray(new Long[0])); @@ -374,7 +374,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { // map result if (pageable.getOffset() < assignedSoftwareModules.size()) { 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))); } @@ -401,7 +402,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { unassignedQuery.orderBy(cb.asc(unassignedRoot.get(JpaSoftwareModule_.name)), cb.asc(unassignedRoot.get(JpaSoftwareModule_.version))); final List unassignedSoftwareModules = entityManager.createQuery(unassignedQuery) - .setFirstResult(Math.max(0, pageable.getOffset() - assignedSoftwareModules.size())) + .setFirstResult((int) Math.max(0, pageable.getOffset() - assignedSoftwareModules.size())) .setMaxResults(pageSize).getResultList(); // map result unassignedSoftwareModules.forEach(sw -> resultList.add(new AssignedSoftwareModule(sw, false))); @@ -456,7 +457,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Override public Page findByAssignedTo(final Pageable pageable, final long setId) { - if (!distributionSetRepository.exists(setId)) { + if (!distributionSetRepository.existsById(setId)) { throw new EntityNotFoundException(DistributionSet.class, setId); } @@ -527,7 +528,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { private void assertSoftwareModuleMetadataDoesNotExist(final Long moduleId, final JpaSoftwareModuleMetadataCreate md) { - if (softwareModuleMetadataRepository.exists(new SwMetadataCompositeKey(moduleId, md.getKey()))) { + if (softwareModuleMetadataRepository.existsById(new SwMetadataCompositeKey(moduleId, md.getKey()))) { throwMetadataKeyAlreadyExists(md.getKey()); } } @@ -607,11 +608,11 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key)); touch(metadata.getSoftwareModule()); - softwareModuleMetadataRepository.delete(metadata.getId()); + softwareModuleMetadataRepository.deleteById(metadata.getId()); } private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) { - if (!softwareModuleRepository.exists(swId)) { + if (!softwareModuleRepository.existsById(swId)) { throw new EntityNotFoundException(SoftwareModule.class, swId); } } @@ -654,7 +655,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { public Optional getMetaDataBySoftwareModuleId(final long moduleId, final String key) { 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) { @@ -671,7 +673,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { @Override public boolean exists(final long id) { - return softwareModuleRepository.exists(id); + return softwareModuleRepository.existsById(id); } @Override @@ -680,7 +682,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { throwExceptionIfSoftwareModuleDoesNotExist(moduleId); 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); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java index 8f28fab6a..59fd17988 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSoftwareModuleTypeManagement.java @@ -168,29 +168,29 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection ids) { - final List setsFound = softwareModuleTypeRepository.findAll(ids); + final List setsFound = softwareModuleTypeRepository.findAllById(ids); if (setsFound.size() < ids.size()) { throw new EntityNotFoundException(SoftwareModuleType.class, ids, setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList())); } - softwareModuleTypeRepository.delete(setsFound); + softwareModuleTypeRepository.deleteAll(setsFound); } @Override public List get(final Collection ids) { - return Collections.unmodifiableList(softwareModuleTypeRepository.findAll(ids)); + return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids)); } @Override public Optional get(final long id) { - return Optional.ofNullable(softwareModuleTypeRepository.findOne(id)); + return softwareModuleTypeRepository.findById(id).map(smt -> (SoftwareModuleType) smt); } @Override public boolean exists(final long id) { - return softwareModuleTypeRepository.exists(id); + return softwareModuleTypeRepository.existsById(id); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java index 861c8bc24..ca4ff02d1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaSystemManagement.java @@ -20,6 +20,7 @@ import org.eclipse.hawkbit.cache.TenancyCacheManager; import org.eclipse.hawkbit.repository.RolloutStatusCache; import org.eclipse.hawkbit.repository.SystemManagement; 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.MultiTenantJpaTransactionManager; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType; @@ -160,7 +161,7 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst } private void usageStatsPerTenant(final SystemUsageReportWithTenants report) { - final List tenants = findTenants(new PageRequest(0, MAX_TENANTS_QUERY)).getContent(); + final List tenants = findTenants(PageRequest.of(0, MAX_TENANTS_QUERY)).getContent(); tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> { report.addTenantData(systemStatsManagement.getStatsOfTenant()); @@ -276,7 +277,8 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst public TenantMetaData updateTenantMetadata(final long defaultDsType) { 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); } @@ -312,15 +314,19 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst @Override public TenantMetaData getTenantMetadata(final long tenantId) { - return tenantMetaDataRepository.findOne(tenantId); + return tenantMetaDataRepository.findById(tenantId) + .orElseThrow(() -> new EntityNotFoundException(TenantMetaData.class, tenantId)); } @Override @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 consumer) { Page tenants; - Pageable query = new PageRequest(0, MAX_TENANTS_QUERY); + Pageable query = PageRequest.of(0, MAX_TENANTS_QUERY); do { tenants = findTenants(query); tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java index a82e8c003..7a11ed34e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetFilterQueryManagement.java @@ -39,7 +39,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; import org.springframework.orm.jpa.vendor.Database; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; @@ -99,11 +98,11 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final long targetFilterQueryId) { - if (!targetFilterQueryRepository.exists(targetFilterQueryId)) { + if (!targetFilterQueryRepository.existsById(targetFilterQueryId)) { throw new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId); } - targetFilterQueryRepository.delete(targetFilterQueryId); + targetFilterQueryRepository.deleteById(targetFilterQueryId); } @Override @@ -178,7 +177,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme return targetFilterQueryRepository.findAll(pageable); } - final Specifications specs = SpecificationsBuilder.combineWithAnd(specList); + final Specification specs = SpecificationsBuilder.combineWithAnd(specList); return targetFilterQueryRepository.findAll(specs, pageable); } @@ -189,7 +188,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme @Override public Optional get(final long targetFilterQueryId) { - return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId)); + return targetFilterQueryRepository.findById(targetFilterQueryId).map(tfq -> (TargetFilterQuery) tfq); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java index 4144258df..35f154348 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetManagement.java @@ -64,7 +64,7 @@ import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; 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.dao.ConcurrencyFailureException; import org.springframework.data.domain.Page; @@ -111,7 +111,7 @@ public class JpaTargetManagement implements TargetManagement { private final ApplicationEventPublisher eventPublisher; - private final ApplicationContext applicationContext; + private final BusProperties bus; private final TenantAware tenantAware; @@ -127,9 +127,9 @@ public class JpaTargetManagement implements TargetManagement { final DistributionSetRepository distributionSetRepository, final TargetFilterQueryRepository targetFilterQueryRepository, final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao, - final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, - final TenantAware tenantAware, final AfterTransactionCommitExecutor afterCommit, - final VirtualPropertyReplacer virtualPropertyReplacer, final Database database) { + final ApplicationEventPublisher eventPublisher, final BusProperties bus, final TenantAware tenantAware, + final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer, + final Database database) { this.entityManager = entityManager; this.quotaManagement = quotaManagement; this.targetRepository = targetRepository; @@ -140,7 +140,7 @@ public class JpaTargetManagement implements TargetManagement { this.targetTagRepository = targetTagRepository; this.criteriaNoCountDao = criteriaNoCountDao; this.eventPublisher = eventPublisher; - this.applicationContext = applicationContext; + this.bus = bus; this.tenantAware = tenantAware; this.afterCommit = afterCommit; this.virtualPropertyReplacer = virtualPropertyReplacer; @@ -190,13 +190,13 @@ public class JpaTargetManagement implements TargetManagement { // TargetUpdatedEvent is not sent within the touch() method due to the // "lastModifiedAt" field being ignored in JpaTarget - eventPublisher.publishEvent(new TargetUpdatedEvent(updatedTarget, applicationContext.getId())); + eventPublisher.publishEvent(new TargetUpdatedEvent(updatedTarget, bus.getId())); return createdMetadata; } private void checkAndThrowIfTargetMetadataAlreadyExists(final TargetMetadataCompositeKey metadataId) { - if (targetMetadataRepository.exists(metadataId)) { + if (targetMetadataRepository.existsById(metadataId)) { throw new EntityAlreadyExistsException( "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 final JpaTargetMetadata updatedMetadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, - md.getKey()) - .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, md.getKey())); + md.getKey()).orElseThrow( + () -> new EntityNotFoundException(TargetMetadata.class, controllerId, md.getKey())); updatedMetadata.setValue(md.getValue()); // touch it to update the lock revision because we are modifying the // target indirectly @@ -239,7 +239,7 @@ public class JpaTargetManagement implements TargetManagement { final JpaTargetMetadata matadata = targetMetadataRepository.save(updatedMetadata); // target update event is set to ignore "lastModifiedAt" field so it is // not send automatically within the touch() method - eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId())); + eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId())); return matadata; } @@ -252,10 +252,10 @@ public class JpaTargetManagement implements TargetManagement { .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key)); 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 // not send automatically within the touch() method - eventPublisher.publishEvent(new TargetUpdatedEvent(target, applicationContext.getId())); + eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId())); } @Override @@ -294,7 +294,8 @@ public class JpaTargetManagement implements TargetManagement { public Optional getMetaDataByControllerId(final String controllerId, final String key) { 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 @@ -344,7 +345,7 @@ public class JpaTargetManagement implements TargetManagement { @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection targetIDs) { - final List targets = targetRepository.findAll(targetIDs); + final List targets = targetRepository.findAllById(targetIDs); if (targets.size() < targetIDs.size()) { throw new EntityNotFoundException(Target.class, targetIDs, @@ -356,7 +357,7 @@ public class JpaTargetManagement implements TargetManagement { afterCommit.afterCommit(() -> targets.forEach(target -> eventPublisher.publishEvent( new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null), - JpaTarget.class.getName(), applicationContext.getId())))); + JpaTarget.class.getName(), bus.getId())))); } @Override @@ -366,7 +367,7 @@ public class JpaTargetManagement implements TargetManagement { public void deleteByControllerID(final String controllerID) { final Target target = getByControllerIdAndThrowIfNotFound(controllerID); - targetRepository.delete(target.getId()); + targetRepository.deleteById(target.getId()); } @Override @@ -394,7 +395,7 @@ public class JpaTargetManagement implements TargetManagement { } private void throwEntityNotFoundIfDsDoesNotExist(final Long distributionSetID) { - if (!distributionSetRepository.exists(distributionSetID)) { + if (!distributionSetRepository.existsById(distributionSetID)) { throw new EntityNotFoundException(DistributionSet.class, distributionSetID); } } @@ -452,7 +453,7 @@ public class JpaTargetManagement implements TargetManagement { private List> buildSpecificationList(final FilterParams filterParams) { final List> specList = new ArrayList<>(); - if (filterParams.getFilterByStatus() != null && !filterParams.getFilterByStatus().isEmpty()) { + if ((filterParams.getFilterByStatus() != null) && !filterParams.getFilterByStatus().isEmpty()) { specList.add(TargetSpecifications.hasTargetUpdateStatus(filterParams.getFilterByStatus())); } if (filterParams.getOverdueState() != null) { @@ -475,8 +476,8 @@ public class JpaTargetManagement implements TargetManagement { } private static boolean isHasTagsFilterActive(final FilterParams filterParams) { - return filterParams.getSelectTargetWithNoTag() != null && (filterParams.getSelectTargetWithNoTag() - || (filterParams.getFilterByTagNames() != null && filterParams.getFilterByTagNames().length > 0)); + return ((filterParams.getSelectTargetWithNoTag() != null) && filterParams.getSelectTargetWithNoTag()) + || ((filterParams.getFilterByTagNames() != null) && (filterParams.getFilterByTagNames().length > 0)); } private Slice findByCriteriaAPI(final Pageable pageable, final List> specList) { @@ -617,7 +618,7 @@ public class JpaTargetManagement implements TargetManagement { // index of the array and // the 2nd contains the selectCase int value. final int pageSize = pageable.getPageSize(); - final List resultList = entityManager.createQuery(query).setFirstResult(pageable.getOffset()) + final List resultList = entityManager.createQuery(query).setFirstResult((int) pageable.getOffset()) .setMaxResults(pageSize + 1).getResultList(); final boolean hasNext = resultList.size() > pageSize; return new SliceImpl<>(Collections.unmodifiableList(resultList), pageable, hasNext); @@ -676,7 +677,7 @@ public class JpaTargetManagement implements TargetManagement { @Override public Page findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) { - if (!rolloutGroupRepository.exists(group)) { + if (!rolloutGroupRepository.existsById(group)) { throw new EntityNotFoundException(RolloutGroup.class, group); } @@ -733,7 +734,7 @@ public class JpaTargetManagement implements TargetManagement { } private void throwEntityNotFoundExceptionIfTagDoesNotExist(final Long tagId) { - if (!targetTagRepository.exists(tagId)) { + if (!targetTagRepository.existsById(tagId)) { throw new EntityNotFoundException(TargetTag.class, tagId); } } @@ -773,12 +774,12 @@ public class JpaTargetManagement implements TargetManagement { @Override public Optional get(final long id) { - return Optional.ofNullable(targetRepository.findOne(id)); + return targetRepository.findById(id).map(t -> (Target) t); } @Override public List get(final Collection ids) { - return Collections.unmodifiableList(targetRepository.findAll(ids)); + return Collections.unmodifiableList(targetRepository.findAllById(ids)); } @Override @@ -796,7 +797,7 @@ public class JpaTargetManagement implements TargetManagement { eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, - JpaTarget.class.getName(), applicationContext.getId())); + JpaTarget.class.getName(), bus.getId())); } @Override @@ -806,4 +807,14 @@ public class JpaTargetManagement implements TargetManagement { return target.isRequestControllerAttributes(); } + @Override + public boolean existsByControllerId(final String controllerId) { + return targetRepository.existsByControllerId(controllerId); + } + + @Override + public Page findByControllerAttributesRequested(final Pageable pageReq) { + return targetRepository.findByRequestControllerAttributesIsTrue(pageReq); + } + } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java index bfb079622..6366ef1ec 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaTargetTagManagement.java @@ -138,7 +138,7 @@ public class JpaTargetTagManagement implements TargetTagManagement { @Override public Optional get(final long id) { - return Optional.ofNullable(targetTagRepository.findOne(id)); + return targetTagRepository.findById(id).map(tt -> (TargetTag) tt); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/NoCountPagingRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/NoCountPagingRepository.java index c0f8b89ff..40713e173 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/NoCountPagingRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/NoCountPagingRepository.java @@ -103,7 +103,7 @@ public class NoCountPagingRepository { @Override protected Page readPage(final TypedQuery query, final Pageable pageable, final Specification spec) { - query.setFirstResult(pageable.getOffset()); + query.setFirstResult((int) pageable.getOffset()); query.setMaxResults(pageable.getPageSize()); final List content = query.getResultList(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OfflineDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OfflineDsAssignmentStrategy.java index 6992c544f..af07c185f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OfflineDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OfflineDsAssignmentStrategy.java @@ -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.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetWithActionType; -import org.springframework.context.ApplicationContext; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; import com.google.common.collect.Lists; @@ -43,10 +43,10 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy { OfflineDsAssignmentStrategy(final TargetRepository targetRepository, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final ActionRepository actionRepository, + final BusProperties bus, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { - super(targetRepository, afterCommit, eventPublisher, applicationContext, actionRepository, - actionStatusRepository, quotaManagement); + super(targetRepository, afterCommit, eventPublisher, bus, actionRepository, actionStatusRepository, + quotaManagement); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java index 1e10223be..43b73f3db 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java @@ -28,7 +28,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetWithActionType; -import org.springframework.context.ApplicationContext; +import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; import com.google.common.collect.Lists; @@ -41,10 +41,10 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy { OnlineDsAssignmentStrategy(final TargetRepository targetRepository, final AfterTransactionCommitExecutor afterCommit, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final ActionRepository actionRepository, + final BusProperties bus, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final QuotaManagement quotaManagement) { - super(targetRepository, afterCommit, eventPublisher, applicationContext, actionRepository, - actionStatusRepository, quotaManagement); + super(targetRepository, afterCommit, eventPublisher, bus, actionRepository, actionStatusRepository, + quotaManagement); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java index 4d22a3fb7..033755fca 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java @@ -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.configuration.MultiTenantJpaTransactionManager; 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.model.helper.AfterTransactionCommitExecutorHolder; 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.TenantAwareHolder; 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.model.DistributionSet; 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.persistence.config.PersistenceUnitProperties; 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.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.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.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.Import; @@ -123,23 +130,71 @@ import com.google.common.collect.Maps; * General configuration for hawkBit's Repository. * */ -@EnableJpaRepositories(basePackages = { "org.eclipse.hawkbit.repository.jpa" }) +@EnableJpaRepositories("org.eclipse.hawkbit.repository.jpa") @EnableTransactionManagement @EnableJpaAuditing @EnableAspectJAutoProxy @Configuration -@ComponentScan @EnableScheduling @EnableRetry @EntityScan("org.eclipse.hawkbit.repository.jpa.model") @PropertySource("classpath:/hawkbit-jpa-defaults.properties") -@Import({ RepositoryDefaultConfiguration.class }) +@Import({ RepositoryDefaultConfiguration.class, DataSourceAutoConfiguration.class, + SystemManagementCacheKeyGenerator.class }) +@AutoConfigureAfter(DataSourceAutoConfiguration.class) public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { - @Autowired - RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties jpaProperties, - final ObjectProvider jtaTransactionManagerProvider) { - super(dataSource, jpaProperties, jtaTransactionManagerProvider); + protected RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties properties, + final ObjectProvider jtaTransactionManagerProvider, + final ObjectProvider transactionManagerCustomizers) { + 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 @@ -163,7 +218,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { @Bean @ConditionalOnMissingBean 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 TargetFilterQueryRepository targetFilterQueryRepository, final ActionRepository actionRepository, final NoCountPagingRepository criteriaNoCountDao, final ApplicationEventPublisher eventPublisher, - final ApplicationContext applicationContext, final TenantAware tenantAware, + final BusProperties bus, final TenantAware tenantAware, final VirtualPropertyReplacer virtualPropertyReplacer, final SoftwareModuleRepository softwareModuleRepository, final DistributionSetTagRepository distributionSetTagRepository, final AfterTransactionCommitExecutor afterCommit, final JpaProperties properties) { return new JpaDistributionSetManagement(entityManager, distributionSetRepository, distributionSetTagManagement, systemManagement, distributionSetTypeManagement, quotaManagement, distributionSetMetadataRepository, - targetFilterQueryRepository, actionRepository, criteriaNoCountDao, eventPublisher, applicationContext, - tenantAware, virtualPropertyReplacer, softwareModuleRepository, distributionSetTagRepository, - afterCommit, properties.getDatabase()); + targetFilterQueryRepository, actionRepository, criteriaNoCountDao, eventPublisher, bus, tenantAware, + virtualPropertyReplacer, softwareModuleRepository, distributionSetTagRepository, afterCommit, + properties.getDatabase()); } @@ -455,13 +510,13 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { final DistributionSetRepository distributionSetRepository, final TargetFilterQueryRepository targetFilterQueryRepository, final TargetTagRepository targetTagRepository, final NoCountPagingRepository criteriaNoCountDao, - final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, - final TenantAware tenantAware, final AfterTransactionCommitExecutor afterCommit, - final VirtualPropertyReplacer virtualPropertyReplacer, final JpaProperties properties) { + final ApplicationEventPublisher eventPublisher, final BusProperties bus, final TenantAware tenantAware, + final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer, + final JpaProperties properties) { return new JpaTargetManagement(entityManager, quotaManagement, targetRepository, targetMetadataRepository, rolloutGroupRepository, distributionSetRepository, targetFilterQueryRepository, targetTagRepository, - criteriaNoCountDao, eventPublisher, applicationContext, tenantAware, afterCommit, - virtualPropertyReplacer, properties.getDatabase()); + criteriaNoCountDao, eventPublisher, bus, tenantAware, afterCommit, virtualPropertyReplacer, + properties.getDatabase()); } /** @@ -565,12 +620,13 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { RolloutManagement rolloutManagement(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement, final DistributionSetManagement distributionSetManagement, final ApplicationContext context, - final ApplicationEventPublisher eventPublisher, final VirtualPropertyReplacer virtualPropertyReplacer, - final PlatformTransactionManager txManager, final TenantAware tenantAware, final LockRegistry lockRegistry, - final JpaProperties properties, final RolloutApprovalStrategy rolloutApprovalStrategy) { + final BusProperties bus, final ApplicationEventPublisher eventPublisher, + final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, + final TenantAware tenantAware, final LockRegistry lockRegistry, final JpaProperties properties, + final RolloutApprovalStrategy rolloutApprovalStrategy) { return new JpaRolloutManagement(targetManagement, deploymentManagement, rolloutGroupManagement, - distributionSetManagement, context, eventPublisher, virtualPropertyReplacer, txManager, tenantAware, - lockRegistry, properties.getDatabase(), rolloutApprovalStrategy); + distributionSetManagement, context, bus, eventPublisher, virtualPropertyReplacer, txManager, + tenantAware, lockRegistry, properties.getDatabase(), rolloutApprovalStrategy); } /** @@ -614,15 +670,15 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { final ActionRepository actionRepository, final DistributionSetRepository distributionSetRepository, final TargetRepository targetRepository, final ActionStatusRepository actionStatusRepository, final TargetManagement targetManagement, final AuditorAware auditorProvider, - final ApplicationEventPublisher eventPublisher, final ApplicationContext applicationContext, + final ApplicationEventPublisher eventPublisher, final BusProperties bus, final AfterTransactionCommitExecutor afterCommit, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final JpaProperties properties) { return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetRepository, targetRepository, - actionStatusRepository, targetManagement, auditorProvider, eventPublisher, applicationContext, - afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement, quotaManagement, + actionStatusRepository, targetManagement, auditorProvider, eventPublisher, bus, afterCommit, + virtualPropertyReplacer, txManager, tenantConfigurationManagement, quotaManagement, systemSecurityContext, tenantAware, properties.getDatabase()); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareModuleTypeRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareModuleTypeRepository.java index dffce476c..417a99803 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareModuleTypeRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SoftwareModuleTypeRepository.java @@ -84,5 +84,5 @@ public interface SoftwareModuleTypeRepository @Override // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 @Query("SELECT d FROM JpaSoftwareModuleType d WHERE d.id IN ?1") - List findAll(Iterable ids); + List findAllById(Iterable ids); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagementCacheKeyGenerator.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagementCacheKeyGenerator.java index 2bed4aeff..753bb01ef 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagementCacheKeyGenerator.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/SystemManagementCacheKeyGenerator.java @@ -15,13 +15,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKeyGenerator; import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Service; /** * Implementation of {@link CurrentTenantCacheKeyGenerator}. * */ -@Service public class SystemManagementCacheKeyGenerator implements CurrentTenantCacheKeyGenerator { @Autowired diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetRepository.java index 556e47c73..6bc0d2dac 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/TargetRepository.java @@ -177,6 +177,18 @@ public interface TargetRepository extends BaseEntityRepository, */ Page findByAssignedDistributionSetId(Pageable pageable, Long setID); + /** + * retrieves {@link Target}s where + * {@link JpaTarget#isRequestControllerAttributes()}. + * + * @param pageReq + * page parameter + * + * @return the found {@link Target}s + * + */ + Page findByRequestControllerAttributesIsTrue(Pageable pageable); + /** * Counts number of targets with given distribution set Id. * @@ -209,7 +221,7 @@ public interface TargetRepository extends BaseEntityRepository, @Override // Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 @Query("SELECT t FROM JpaTarget t WHERE t.id IN ?1") - List findAll(Iterable ids); + List findAllById(Iterable ids); /** * diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java index a2fdff410..a0c1c080e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java @@ -102,7 +102,7 @@ public class AutoAssignChecker { public void check() { LOGGER.debug("Auto assigned check call"); - final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE); + final PageRequest pageRequest = PageRequest.of(0, PAGE_SIZE); final Page filterQueries = targetFilterQueryManagement .findWithAutoAssignDS(pageRequest); @@ -176,7 +176,7 @@ public class AutoAssignChecker { private List getTargetsWithActionType(final String targetFilterQuery, final Long dsId, final int count) { final Page 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(), Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList()); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java index 6c58a0207..c711b1747 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/executor/AfterTransactionCommitDefaultServiceExecutor.java @@ -13,7 +13,6 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; import org.springframework.transaction.support.TransactionSynchronizationAdapter; 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 * successful spring transaction commit.The class is thread safe. */ -@Service public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements AfterTransactionCommitExecutor { private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java index b1269f7d7..d964a8c42 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaTenantMetaData.java @@ -77,8 +77,8 @@ public class JpaTenantMetaData extends AbstractJpaBaseEntity implements TenantMe return defaultDsType; } - public void setDefaultDsType(final DistributionSetType defaultDsType) { - this.defaultDsType = (JpaDistributionSetType) defaultDsType; + public void setDefaultDsType(final JpaDistributionSetType defaultDsType) { + this.defaultDsType = defaultDsType; } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/PauseRolloutGroupAction.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/PauseRolloutGroupAction.java index 6257e4e6f..96011c12d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/PauseRolloutGroupAction.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/PauseRolloutGroupAction.java @@ -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.RolloutGroupStatus; 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 * current {@link RolloutGroup} to error. */ -@Component("pauseRolloutGroupAction") public class PauseRolloutGroupAction implements RolloutGroupActionEvaluator { - @Autowired - private RolloutManagement rolloutManagement; + private final RolloutManagement rolloutManagement; - @Autowired - private RolloutGroupRepository rolloutGroupRepository; + private final RolloutGroupRepository rolloutGroupRepository; - @Autowired - private SystemSecurityContext systemSecurityContext; + private final SystemSecurityContext systemSecurityContext; + + public PauseRolloutGroupAction(final RolloutManagement rolloutManagement, + final RolloutGroupRepository rolloutGroupRepository, final SystemSecurityContext systemSecurityContext) { + this.rolloutManagement = rolloutManagement; + this.rolloutGroupRepository = rolloutGroupRepository; + this.systemSecurityContext = systemSecurityContext; + } @Override public boolean verifyExpression(final String expression) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java index 420787582..4cb42f16e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/StartNextGroupRolloutGroupSuccessAction.java @@ -19,25 +19,26 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.security.SystemSecurityContext; import org.slf4j.Logger; 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}. */ -@Component("startNextRolloutGroupAction") public class StartNextGroupRolloutGroupSuccessAction implements RolloutGroupActionEvaluator { private static final Logger logger = LoggerFactory.getLogger(StartNextGroupRolloutGroupSuccessAction.class); - @Autowired - private RolloutGroupRepository rolloutGroupRepository; + private final RolloutGroupRepository rolloutGroupRepository; - @Autowired - private DeploymentManagement deploymentManagement; + private final DeploymentManagement deploymentManagement; - @Autowired - private SystemSecurityContext systemSecurityContext; + private final SystemSecurityContext systemSecurityContext; + + public StartNextGroupRolloutGroupSuccessAction(final RolloutGroupRepository rolloutGroupRepository, + final DeploymentManagement deploymentManagement, final SystemSecurityContext systemSecurityContext) { + this.rolloutGroupRepository = rolloutGroupRepository; + this.deploymentManagement = deploymentManagement; + this.systemSecurityContext = systemSecurityContext; + } @Override public boolean verifyExpression(final String expression) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupErrorCondition.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupErrorCondition.java index cba134402..797611c8a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupErrorCondition.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupErrorCondition.java @@ -16,19 +16,19 @@ import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; /** * */ -@Component("thresholdRolloutGroupErrorCondition") public class ThresholdRolloutGroupErrorCondition implements RolloutGroupConditionEvaluator { private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupErrorCondition.class); - @Autowired - private ActionRepository actionRepository; + private final ActionRepository actionRepository; + + public ThresholdRolloutGroupErrorCondition(final ActionRepository actionRepository) { + this.actionRepository = actionRepository; + } @Override public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupSuccessCondition.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupSuccessCondition.java index 1a8c50ade..f4e7fdef6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupSuccessCondition.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rollout/condition/ThresholdRolloutGroupSuccessCondition.java @@ -14,19 +14,19 @@ import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.slf4j.Logger; 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 * next rollout group can get started. */ -@Component("thresholdRolloutGroupSuccessCondition") public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupConditionEvaluator { private static final Logger LOGGER = LoggerFactory.getLogger(ThresholdRolloutGroupSuccessCondition.class); - @Autowired - private ActionRepository actionRepository; + private final ActionRepository actionRepository; + + public ThresholdRolloutGroupSuccessCondition(final ActionRepository actionRepository) { + this.actionRepository = actionRepository; + } @Override public boolean eval(final Rollout rollout, final RolloutGroup rolloutGroup, final String expression) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtility.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtility.java index 0831dc2f6..94bbf7845 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtility.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtility.java @@ -159,6 +159,8 @@ public final class RSQLUtility { private static final class RSQLSpecification & FieldNameProvider, T> implements Specification { + private static final long serialVersionUID = 1L; + private final String rsql; private final Class enumType; private final VirtualPropertyReplacer virtualPropertyReplacer; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RsqlParserValidationOracle.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RsqlParserValidationOracle.java index 3642a20b5..0c43cfbf6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RsqlParserValidationOracle.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/RsqlParserValidationOracle.java @@ -76,7 +76,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle { context.setSyntaxErrorContext(errorContext); try { - targetManagement.findByRsql(new PageRequest(0, 1), rsqlQuery); + targetManagement.findByRsql(PageRequest.of(0, 1), rsqlQuery); context.setSyntaxError(false); suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery)); } catch (final RSQLParameterSyntaxException | RSQLParserException ex) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilder.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilder.java index 095269622..8600b2c52 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilder.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilder.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository.jpa.specifications; import java.util.List; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; /** * Helper class to easily combine {@link Specification} instances. @@ -31,11 +30,11 @@ public final class SpecificationsBuilder { * all specification which will combine * @return if the given specification list is empty */ - public static Specifications combineWithAnd(final List> specList) { + public static Specification combineWithAnd(final List> specList) { if (specList.isEmpty()) { return null; } - Specifications specs = Specifications.where(specList.get(0)); + Specification specs = Specification.where(specList.get(0)); for (final Specification specification : specList.subList(1, specList.size())) { specs = specs.and(specification); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties index 47910214b..3adf8567f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties @@ -7,6 +7,8 @@ # http://www.eclipse.org/legal/epl-v10.html # +spring.main.allow-bean-definition-overriding=true + ### JPA / Datasource - START spring.jpa.database=H2 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.cache.shared.default=false # Flyway DDL -flyway.enabled=true -flyway.initOnMigrate=true -flyway.cleanDisabled=true -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql +spring.flyway.enabled=true +spring.flyway.init-on-migrate=true +spring.flyway.clean-disabled=true +spring.flyway.sql-migration-suffixes=${spring.jpa.database}.sql +spring.flyway.table=schema_version ### JPA / Datasource - END diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java index cb811ba04..082d26c3c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java @@ -47,7 +47,7 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest @Before public void setup() throws Exception { final BusJacksonAutoConfiguration autoConfiguration = new BusJacksonAutoConfiguration(); - this.jacksonMessageConverter = autoConfiguration.busJsonConverter(); + this.jacksonMessageConverter = autoConfiguration.busJsonConverter(null); ReflectionTestUtils.setField(jacksonMessageConverter, "packagesToScan", new String[] { "org.eclipse.hawkbit.repository.event.remote", ClassUtils.getPackageName(RemoteApplicationEvent.class) }); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java index baef4ace8..04a9b4668 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractJpaIntegrationTest.java @@ -26,23 +26,25 @@ import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; 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.RolloutTestApprovalStrategy; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; 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.transaction.annotation.Transactional; import com.google.common.collect.Lists; -@SpringApplicationConfiguration(classes = { - org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration.class }) +@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class, + TestSupportBinderAutoConfiguration.class }) @TestPropertySource(locations = "classpath:/jpa-test.properties") public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest { protected static final String INVALID_TEXT_HTML = "