From 26466c7d6a240b5a740f1731869325c954854fbc Mon Sep 17 00:00:00 2001 From: SirWayne Date: Wed, 30 Mar 2016 13:05:11 +0200 Subject: [PATCH 01/14] Before sending a message check if the uri is a amqp uri. Signed-off-by: SirWayne --- .../java/org/eclipse/hawkbit/amqp/AmqpSenderService.java | 4 ++-- .../eclipse/hawkbit/amqp/DefaultAmqpSenderService.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpSenderService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpSenderService.java index 6cb3dd9be..f44e2e9bb 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpSenderService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpSenderService.java @@ -24,10 +24,10 @@ public interface AmqpSenderService { * * @param message * the amqp message - * @param uri + * @param replyTo * the reply to uri */ - void sendMessage(Message message, URI uri); + void sendMessage(Message message, URI replyTo); /** * Extract the exchange from the uri. Default implementation removes the diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpSenderService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpSenderService.java index 9586633bf..244544b64 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpSenderService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/DefaultAmqpSenderService.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp; import java.net.URI; +import org.eclipse.hawkbit.util.IpUtil; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -33,8 +34,12 @@ public class DefaultAmqpSenderService implements AmqpSenderService { } @Override - public void sendMessage(final Message message, final URI uri) { - internalAmqpTemplate.send(extractExchange(uri), null, message); + public void sendMessage(final Message message, final URI replyTo) { + if (!IpUtil.isAmqpUri(replyTo)) { + return; + } + + internalAmqpTemplate.send(extractExchange(replyTo), null, message); } } From 2b4b715472f7c5961e557541a93a0c9e06982339 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 30 Mar 2016 14:31:03 +0200 Subject: [PATCH 02/14] Created another hawkBit app example that demonstrates theme custimization. Signed-off-by: Kai Zimmermann --- .../hawkbit-custom-theme-example/README.md | 1 + examples/hawkbit-custom-theme-example/pom.xml | 112 ++++++++++++++++++ .../org/eclipse/hawkbit/app/MyLoginUI.java | 34 ++++++ .../java/org/eclipse/hawkbit/app/MyUI.java | 45 +++++++ .../java/org/eclipse/hawkbit/app/Start.java | 36 ++++++ .../VAADIN/themes/exampletheme/.gitignore | 2 + .../customstyles/examplevariables.scss | 24 ++++ .../exampletheme/images/profile-pic-57px.jpg | Bin 0 -> 1189 bytes .../themes/exampletheme/layouts/footer.html | 29 +++++ .../VAADIN/themes/exampletheme/styles.scss | 10 ++ .../src/main/resources/application.properties | 16 +++ hawkbit-repository/pom.xml | 4 + hawkbit-rest-api/pom.xml | 1 - .../hawkbit/images/profile-pic-300px.jpg | Bin 1793 -> 0 bytes pom.xml | 6 + 15 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 examples/hawkbit-custom-theme-example/README.md create mode 100644 examples/hawkbit-custom-theme-example/pom.xml create mode 100644 examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java create mode 100644 examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyUI.java create mode 100644 examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/Start.java create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/.gitignore create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/customstyles/examplevariables.scss create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/images/profile-pic-57px.jpg create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/layouts/footer.html create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss create mode 100644 examples/hawkbit-custom-theme-example/src/main/resources/application.properties delete mode 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg diff --git a/examples/hawkbit-custom-theme-example/README.md b/examples/hawkbit-custom-theme-example/README.md new file mode 100644 index 000000000..5a6a571c8 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/README.md @@ -0,0 +1 @@ +Theme customization example for Eclipse hawkBit. See wiki for the theme customization guide. \ No newline at end of file diff --git a/examples/hawkbit-custom-theme-example/pom.xml b/examples/hawkbit-custom-theme-example/pom.xml new file mode 100644 index 000000000..7caa99ba2 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-examples-parent + 0.2.0-SNAPSHOT + + hawkbit-custom-theme-example + hawkBit :: Custom Theme Example App + + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.plugin.version} + + src/main/resources + + + + + update-theme + compile-theme + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + ${baseDir} + false + org.eclipse.hawkbit.app.Start + JAR + + + + + + + + + + + org.eclipse.hawkbit + hawkbit-autoconfigure + ${project.version} + + + org.eclipse.hawkbit + hawkbit-ui + ${project.version} + + + org.eclipse.hawkbit + hawkbit-security-integration + ${project.version} + + + org.eclipse.hawkbit + hawkbit-http-security + ${project.version} + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.springframework.security + spring-security-aspects + + + com.h2database + h2 + + + + diff --git a/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java new file mode 100644 index 000000000..c31086a70 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.app; + +import org.eclipse.hawkbit.ui.login.HawkbitLoginUI; +import org.eclipse.hawkbit.ui.themes.HawkbitTheme; + +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.Title; +import com.vaadin.spring.annotation.SpringUI; + +/** + * Example hawkBit login UI implementation. + * + * A {@link SpringUI} annotated class must be present in the classpath for the + * login path. The easiest way to get an hawkBit login UI running is to extend + * the {@link HawkbitLoginUI} and to annotated it with {@link SpringUI} as in + * this example to the defined {@link HawkbitTheme#LOGIN_UI_PATH}. + * + */ +@SpringUI(path = HawkbitTheme.LOGIN_UI_PATH) +@Title("hawkBit Theme example") +@Theme(value = "exampletheme") +public class MyLoginUI extends HawkbitLoginUI { + + private static final long serialVersionUID = 1L; + +} diff --git a/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyUI.java b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyUI.java new file mode 100644 index 000000000..5ef632d10 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/MyUI.java @@ -0,0 +1,45 @@ +package org.eclipse.hawkbit.app; +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +import org.eclipse.hawkbit.ui.HawkbitUI; +import org.eclipse.hawkbit.ui.UIEventProvider; +import org.eclipse.hawkbit.ui.push.DelayedEventBusPushStrategy; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.eventbus.EventBus; +import com.vaadin.annotations.Push; +import com.vaadin.annotations.Theme; +import com.vaadin.annotations.Title; +import com.vaadin.shared.communication.PushMode; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.spring.annotation.SpringUI; + +/** + * Example hawkBit UI implementation. + * + * A {@link SpringUI} annotated class must be present in the classpath. The + * easiest way to get an hawkBit UI running is to extend the {@link HawkbitUI} + * and to annotated it with {@link SpringUI} as in this example. + * + */ +@SpringUI +@Push(value = PushMode.AUTOMATIC, transport = Transport.WEBSOCKET) +@Title("hawkBit Theme example") +@Theme(value = "exampletheme") +public class MyUI extends HawkbitUI { + + private static final long serialVersionUID = 1L; + + @Autowired + public MyUI(final EventBus systemEventBus, final org.vaadin.spring.events.EventBus.SessionEventBus eventBus, + final UIEventProvider provider) { + super(new DelayedEventBusPushStrategy(eventBus, systemEventBus, provider)); + } +} diff --git a/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/Start.java b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/Start.java new file mode 100644 index 000000000..1c4c5d32d --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/java/org/eclipse/hawkbit/app/Start.java @@ -0,0 +1,36 @@ +package org.eclipse.hawkbit.app; +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +import org.eclipse.hawkbit.RepositoryApplicationConfiguration; +import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Import; + +/** + * A {@link SpringBootApplication} annotated class with a main method to start. + * The minimal configuration for the stand alone hawkBit server. + * + */ +@SpringBootApplication +@Import({ RepositoryApplicationConfiguration.class }) +@EnableHawkbitManagedSecurityConfiguration +public class Start { + + /** + * Main method to start the spring-boot application. + * + * @param args + * the VM arguments. + */ + public static void main(final String[] args) { + SpringApplication.run(Start.class, args); + } +} diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/.gitignore b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/.gitignore new file mode 100644 index 000000000..1cdd02b74 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/.gitignore @@ -0,0 +1,2 @@ +/addons.scss +/styles.css diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/customstyles/examplevariables.scss b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/customstyles/examplevariables.scss new file mode 100644 index 000000000..6bf201f9c --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/customstyles/examplevariables.scss @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + +$dark-gray: #848484; + +//Example color change +$hawkbit-primary-color: $dark-gray; +$hawkbit-primary-color-light: #D8D8D8; +$app-selection-item-selection-color: $dark-gray; +$app-focus-color: $dark-gray; +$app-selection-color: $dark-gray; +$tag-text-color: $dark-gray; +$tab-sheet-caption-color: $dark-gray; +$table-details-tab-font-color: $dark-gray; +$widget-caption-color: $dark-gray; +$accordion-action-history-title-color: $dark-gray; +$menu-title-bg-color: $dark-gray; +$button-icon-color: $dark-gray; \ No newline at end of file diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/images/profile-pic-57px.jpg b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/images/profile-pic-57px.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d730cb5f67e12741e3e50df31315a81d0e1ceab6 GIT binary patch literal 1189 zcmex=3RdL56^| zgLDBA4+lF3NCj!&{{aR;4hBmGOJ+tT1|~s9W31L-*^|&n?(5RLW_pFY_v2QRTR`%g#5e%KD%Fx+cp| z%lOc~qbj~fDSorx%7U9`_q6CNmaRB%9~eFL^ZCZK>Uyb6U&+I@t4tqX*uefpZC~30 zrY;RI=AZXZ!Ed{q`PIna(@Za~%RP87|H$Vb*KEuFGsxJe$~CV)UMtf&JtV!%X@6nc zozL&*To-f@|D(U6SN+H|bD!PUI4_?1)!1Ph} z=vFUf5D9c;5D6E4biVgjU9-)!ZyQh67D{S)&E2?~@8G`VU(}!zx_ + + + + diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss new file mode 100644 index 000000000..2407a73fb --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss @@ -0,0 +1,10 @@ +@import "../hawkbit/customstyles/hawkbitvariables"; +@import "customstyles/examplevariables"; +@import "../hawkbit/hawkbittheme"; +@import "addons"; + +// This file prefixes all rules with the theme name to avoid causing conflicts with other themes. +.exampletheme { + @include addons; + @include hawkbittheme; +} diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/application.properties b/examples/hawkbit-custom-theme-example/src/main/resources/application.properties new file mode 100644 index 000000000..3ffb51bd0 --- /dev/null +++ b/examples/hawkbit-custom-theme-example/src/main/resources/application.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2015 Bosch Software Innovations GmbH and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# + +# UI demo account +hawkbit.server.ui.demo.password=admin +hawkbit.server.ui.demo.user=admin +hawkbit.server.ui.demo.tenant=DEFAULT + +# UI help links +hawkbit.server.ui.links.documentation.root=https://github.com/eclipse/hawkbit diff --git a/hawkbit-repository/pom.xml b/hawkbit-repository/pom.xml index 7259262de..b70e00f28 100644 --- a/hawkbit-repository/pom.xml +++ b/hawkbit-repository/pom.xml @@ -67,6 +67,10 @@ org.hibernate hibernate-validator + + javax.validation + validation-api + com.google.guava guava diff --git a/hawkbit-rest-api/pom.xml b/hawkbit-rest-api/pom.xml index be9abafac..703d6caf3 100644 --- a/hawkbit-rest-api/pom.xml +++ b/hawkbit-rest-api/pom.xml @@ -24,7 +24,6 @@ javax.validation validation-api - 1.1.0.Final org.springframework.hateoas diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg deleted file mode 100644 index 664afaa35aa45a62b717447b59410f333706503d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1793 zcmb_ddoRSq&;=X}yY29#D&UApL?S_nKu{*Bl9fpm5`jQg zBU7j}I-O2bQP)tTX{gfZv=t`^8m_@$@mMULrc6+#{cDo9016H`PGgP`&9VSrnme!u^t4FHmnho3*xDW<_BE>lnq#Wi9anc%dL0sz`j z2sAI20ze-f2SyS$02@tRKwcjdI>wq%i5v(qNCWuy>j5AR1F+fS$tpxDgOGBUB-E4u zLd=o?=~^6wq>6#27;drcMl}d^Z2};FfQ{6^)cW+WKX^m@x|;~BkqWqoF#*C@&>gYT z5UH9^0$}^w8<@&s06-M~V!ml5G@-7t=T!{Vm-FEo#mNv-3Y3 zUGR6=AU0rG#<3*A#D08*P1n>dc)6gxF=RU1?M3R_ zC=Rn>bN{hg->hbGXU?G-d_@53iB}_|I6Lj7ov0?NL1OASrD-Lu-C#$o9mDavN`qo{ zA88iuo1W_0Z|;WANWAy5*sMzEppjAE8`c$u86Iubx~=6gx;XpW`QpZzicso3kF8E} zkb|3P8(3s5T|dICV>yNUzHxYFnzDADVKH3$l=H@^t=cm97SF~z+%L=LIe*$~jy5DC z2)LQDpK?VD_UDV9F@tQ3wNrmcotT|}_#-|2&SqJP$-B#i6AQ`oy#Z8Nnoev><&ZG2 zEB#gI_5Pw@R#97lvwEFX_sMG67ZOL^(ZGh-h_q_Y*li*$lBoBfkAfZEtNlWu?;k`K zI4ql|?=gruQl?^K+|8>^KW!#5mfbH*?3fe4z0T+pbL!*idsQ=MoDB4OU&QVcYgzcm zqZJ#brgPn=QxBwsL~j%fi|VjtCF~w0;tqG+Af}J*ffxV_;Mg<#JB7sEHbF zFo!%SVY(KQ10Fm@seP-ID{#&!?6h_8*-?Bq#(3~GpPG7gGLY+DR}om=IAC6MGQrFG zaqAe4$H+RNsd;I4937_}mKD__$dDG8pHuZqQLnHwDCLIES?QGT8uxOuHPzd4M)gag zbDu(qk#2FnJ)``RQa}VV=FO=tu{7-dfNSiyciEk|sO7e>zC{kH=H}g+t0}Wm+qHO= zGkR0XUhRGk+@?^;#POzMh0@N3kiH0_z4IClS1_)#yonUww$| z#M)e;@>qN3T}uLwM>DAbghv%7>HP5C&MR4JC)9gWj|KbXzVy=X)R%*!kBh9L?Uo(} z)P5b+{LR4xp{%7-A<{>5d6{ + 1.1.0.Final 1.4 2.0M10 1.4.22 @@ -419,6 +420,11 @@ + + javax.validation + validation-api + ${validation-api.version} + javax.el javax.el-api From 5ec84288af6f54556f8b7bd89575fc0873a85892 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 30 Mar 2016 14:35:14 +0200 Subject: [PATCH 03/14] Added new example to overview README. Signed-off-by: Kai Zimmermann --- examples/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/README.md b/examples/README.md index 3ad5ecf66..0d6e0c18a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,7 +1,9 @@ # Examples -Example projects that show how hawkBit can be used to create, run or access an hawkBit empowered update server. +Example projects that show how _hawkBit_ can be used to create, run or access an _hawkBit_ empowered update server. + +- `hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options. +- `hawkbit-example-app` : Allows you to run a Spring Boot and hawkBit based update server. Includes all _hawkBit_ interfaces, i.e. DDI, DMF, Mgmt-API, Mgmt-UI. +- `hawkbit-custom-theme-example` : Example for a customized theme for Management UI. +- `hawkbit-mgmt-api-client` : Example client for the _hawkBit_ Management API. -`hawkbit-device-simulator` : Simulates device software updates, leveraging the hawkBit device integration options. -`hawkbit-example-app` : Allows you to run a Spring Boot and hawkBit based update server. -`hawkbit-mgmt-api-client` : Example client for the hawkBit management API. From d0dff39932072e7bd275a0f7d4f6aca910b620d4 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 30 Mar 2016 15:14:20 +0200 Subject: [PATCH 04/14] Added license header. Signed-off-by: Kai Zimmermann --- .../resources/VAADIN/themes/exampletheme/styles.scss | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss index 2407a73fb..4b3f29814 100644 --- a/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss +++ b/examples/hawkbit-custom-theme-example/src/main/resources/VAADIN/themes/exampletheme/styles.scss @@ -1,3 +1,12 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ + @import "../hawkbit/customstyles/hawkbitvariables"; @import "customstyles/examplevariables"; @import "../hawkbit/hawkbittheme"; From 413bb9d814961d1db2d9abe6deb68e2b8b298bda Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Wed, 30 Mar 2016 17:10:47 +0200 Subject: [PATCH 05/14] Reduced log severity of invalid incoming messages to warning. Signed-off-by: Kai Zimmermann --- .../src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java index 8a054165b..4662c8d39 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java @@ -105,7 +105,7 @@ public class BaseAmqpService { } protected final void logAndThrowMessageError(final Message message, final String error) { - LOGGER.error("Error \"{}\" reported by message {}", error, message.getMessageProperties().getMessageId()); + LOGGER.warn("Error \"{}\" reported by message {}", error, message.getMessageProperties().getMessageId()); throw new IllegalArgumentException(error); } From 52cc957cfb7cbef93b04d9e4fd48e66fe0a76f37 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 09:31:47 +0200 Subject: [PATCH 06/14] Consolidated equals and hashcode for all BaseEntities. --- .../hawkbit/repository/model/Action.java | 30 +----- .../repository/model/ActionStatus.java | 20 ---- .../hawkbit/repository/model/Artifact.java | 20 ---- .../hawkbit/repository/model/BaseEntity.java | 8 +- .../repository/model/DistributionSet.java | 20 ---- .../repository/model/DistributionSetType.java | 20 ---- .../model/ExternalArtifactProvider.java | 20 ---- .../hawkbit/repository/model/NamedEntity.java | 20 ---- .../model/NamedVersionedEntity.java | 21 ----- .../hawkbit/repository/model/Rollout.java | 20 ---- .../repository/model/RolloutGroup.java | 21 ----- .../repository/model/SoftwareModule.java | 20 ---- .../repository/model/SoftwareModuleType.java | 20 ---- .../eclipse/hawkbit/repository/model/Tag.java | 20 ---- .../hawkbit/repository/model/Target.java | 33 ------- .../repository/model/TargetFilterQuery.java | 20 ---- .../model/TenantAwareBaseEntity.java | 3 - .../repository/model/TenantConfiguration.java | 34 ------- .../repository/DeploymentManagementTest.java | 11 ++- .../TargetManagementSearchTest.java | 36 ++++++-- .../model/ModelEqualsHashcodeTest.java | 92 +++++++++++++++++++ 21 files changed, 137 insertions(+), 372 deletions(-) create mode 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java index afc6998ad..eedb36037 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java @@ -52,7 +52,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete; @NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"), @NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet"))) }) @Entity -public class Action extends TenantAwareBaseEntity implements Comparable { +public class Action extends TenantAwareBaseEntity { private static final long serialVersionUID = 1L; /** @@ -198,14 +198,6 @@ public class Action extends TenantAwareBaseEntity implements Comparable this.rollout = rollout; } - @Override - public int compareTo(final Action o) { - if (super.getId() == null || o == null || o.getId() == null) { - return 0; - } - return super.getId().compareTo(o.getId()); - } - /** * checks if the {@link #forcedTime} is hit by the given * {@code hitTimeMillis}, by means if the given milliseconds are greater @@ -254,26 +246,6 @@ public class Action extends TenantAwareBaseEntity implements Comparable return "Action [distributionSet=" + distributionSet + ", getId()=" + getId() + "]"; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof Action)) { - return false; - } - - return true; - } - /** * Action status as reported by the controller. * diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java index f67229b69..c8d320abd 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java @@ -140,24 +140,4 @@ public class ActionStatus extends TenantAwareBaseEntity { this.status = status; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ActionStatus)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java index 709635095..b384a3100 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java @@ -53,24 +53,4 @@ public abstract class Artifact extends TenantAwareBaseEntity { public void setSize(final Long size) { this.size = size; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof Artifact)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java index d0289acee..65300c6c4 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java @@ -108,6 +108,11 @@ public abstract class BaseEntity implements Serializable, Identifiable { return optLockRevision; } + // for test purposes only + void setOptLockRevision(final long optLockRevision) { + this.optLockRevision = optLockRevision; + } + @Override public Long getId() { return id; @@ -135,6 +140,7 @@ public abstract class BaseEntity implements Serializable, Identifiable { int result = 1; result = prime * result + (id == null ? 0 : id.hashCode()); result = prime * result + (int) (optLockRevision ^ optLockRevision >>> 32); + result = prime * result + this.getClass().getName().hashCode(); return result; } @@ -154,7 +160,7 @@ public abstract class BaseEntity implements Serializable, Identifiable { if (obj == null) { return false; } - if (!(obj instanceof BaseEntity)) { + if (!(this.getClass().isInstance(obj))) { return false; } final BaseEntity other = (BaseEntity) obj; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java index 51b5e8074..a9d390284 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java @@ -150,26 +150,6 @@ public class DistributionSet extends NamedVersionedEntity { return actions; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof DistributionSet)) { - return false; - } - - return true; - } - public boolean isRequiredMigrationStep() { return requiredMigrationStep; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java index f7dc791a4..61d2fc58c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java @@ -285,24 +285,4 @@ public class DistributionSetType extends NamedEntity { return "DistributionSetType [key=" + key + ", isDeleted()=" + isDeleted() + ", getId()=" + getId() + "]"; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof DistributionSetType)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java index d52e60e46..9fa8714ac 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java @@ -73,24 +73,4 @@ public class ExternalArtifactProvider extends NamedEntity { this.defaultSuffix = defaultSuffix; } - @Override - public int hashCode() { // NOSONAR - as this is generated - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { // NOSONAR - as this is generated - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ExternalArtifactProvider)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java index d055c113e..e14d88161 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java @@ -60,24 +60,4 @@ public abstract class NamedEntity extends TenantAwareBaseEntity { public void setName(final String name) { this.name = name; } - - @Override - public int hashCode() { // NOSONAR - as this is generated - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { // NOSONAR - as this is generated - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof NamedEntity)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java index 2b126c72f..fa56da197 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java @@ -47,25 +47,4 @@ public abstract class NamedVersionedEntity extends NamedEntity { public void setVersion(final String version) { this.version = version; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof NamedVersionedEntity)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java index a596d10a9..a7f9b10cb 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Rollout.java @@ -231,24 +231,4 @@ public class Rollout extends NamedEntity { */ ERROR_STARTING; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof Rollout)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java index 97191b4f1..5aa30126c 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutGroup.java @@ -476,25 +476,4 @@ public class RolloutGroup extends NamedEntity { return this; } } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof RolloutGroup)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java index 8b58c5e3b..327bff3db 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java @@ -233,26 +233,6 @@ public class SoftwareModule extends NamedVersionedEntity { + ", revision=" + getOptLockRevision() + ", Id=" + getId() + ", type=" + getType().getName() + "]"; } - @Override - public int hashCode() { // NOSONAR - as this is generated - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { // NOSONAR - as this is generated - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof SoftwareModule)) { - return false; - } - - return true; - } - /** * @return the assignedTo */ diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java index 59246d92e..f31b74ff6 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java @@ -114,24 +114,4 @@ public class SoftwareModuleType extends NamedEntity { public String toString() { return "SoftwareModuleType [key=" + key + ", getName()=" + getName() + ", getId()=" + getId() + "]"; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof SoftwareModuleType)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java index 8d5f5b832..23489ea12 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java @@ -56,24 +56,4 @@ public abstract class Tag extends NamedEntity implements Identifiable { public String toString() { return "Tag [getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + "]"; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof Tag)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java index f9e29118f..5f37fb653 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java @@ -131,31 +131,6 @@ public class Target extends NamedEntity implements Persistable { securityToken = null; } - /** - * Note: For Target we extended the general strategy by adding controllerId - * as well. - * - * @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object) - */ - @Override - public boolean equals(final Object obj) {// NOSONAR - as this is generated - if (obj == null) { - return false; - } - if (!(obj instanceof Target)) { - return false; - } - final Target other = (Target) obj; - if (controllerId == null) { - if (other.controllerId != null) { - return false; - } - } else if (!controllerId.equals(other.controllerId)) { - return false; - } - return true; - } - public DistributionSet getAssignedDistributionSet() { return assignedDistributionSet; } @@ -168,14 +143,6 @@ public class Target extends NamedEntity implements Persistable { return tags; } - @Override - public int hashCode() { // NOSONAR - as this is generated - final int prime = 31; - int result = 1; - result = prime * result + (controllerId == null ? 0 : controllerId.hashCode()); - return result; - } - public void setAssignedDistributionSet(final DistributionSet assignedDistributionSet) { this.assignedDistributionSet = assignedDistributionSet; } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java index c4e6fb1fe..021b9ca7f 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java @@ -55,24 +55,4 @@ public class TargetFilterQuery extends TenantAwareBaseEntity { public void setQuery(final String query) { this.query = query; } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof TargetFilterQuery)) { - return false; - } - - return true; - } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java index 97d757fb5..d03a4938a 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantAwareBaseEntity.java @@ -99,9 +99,6 @@ public abstract class TenantAwareBaseEntity extends BaseEntity { if (!super.equals(obj)) { return false; } - if (!(obj instanceof TenantAwareBaseEntity)) { - return false; - } final TenantAwareBaseEntity other = (TenantAwareBaseEntity) obj; if (tenant == null) { if (other.tenant != null) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java index efc82747a..5a938563b 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java @@ -52,54 +52,20 @@ public class TenantConfiguration extends TenantAwareBaseEntity implements Serial } - /** - * @return the key - */ public String getKey() { return key; } - /** - * @param key - * the key to set - */ public void setKey(final String key) { this.key = key; } - /** - * @return the value - */ public String getValue() { return value; } - /** - * @param value - * the value to set - */ public void setValue(final String value) { this.value = value; } - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + this.getClass().getName().hashCode(); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof TenantConfiguration)) { - return false; - } - - return true; - } - } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index dd674d3a3..035866ab9 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -18,6 +18,7 @@ import java.util.LinkedList; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.Constants; @@ -386,7 +387,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { .createTargets(TestDataUtil.buildTargetFixtures(10, myCtrlIDPref, "first description")); final String myDeployedCtrlIDPref = "myDeployedCtrlID"; - final List savedDeployedTargets = targetManagement + List savedDeployedTargets = targetManagement .createTargets(TestDataUtil.buildTargetFixtures(20, myDeployedCtrlIDPref, "first description")); final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement, @@ -399,6 +400,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Iterable allFoundTargets = targetManagement.findTargetsAll(pageReq).getContent(); + // get final updated version of targets + savedDeployedTargets = targetManagement.findTargetByControllerID( + savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets) .containsAll(savedNakedTargets); assertThat(savedDeployedTargets).as("saved target are wrong") @@ -602,6 +607,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { .assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets(); actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1); + // get final updated version of targets + final List deployResWithDsBTargets = targetManagement.findTargetByControllerID(deployResWithDsB + .getDeployedTargets().stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsB.getDeployedTargets()); assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsB.getDeployedTargets()); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java index 0438ac512..0c33a651f 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java @@ -109,6 +109,14 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { both.add(TargetUpdateStatus.UNKNOWN); both.add(TargetUpdateStatus.PENDING); + // get final updated version of targets + targAs = targetManagement.findTargetByControllerID( + targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + targBs = targetManagement.findTargetByControllerID( + targBs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + targCs = targetManagement.findTargetByControllerID( + targCs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + // try to find several targets with different filter settings verifyThatRepositoryContains400Targets(); verifyThat200TargetsHaveTagD(targTagW, concat(targBs, targCs)); @@ -708,11 +716,14 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final DistributionSet assignedSet = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned")); - final List assignedtargets = targetManagement - .createTargets(TestDataUtil.generateTargets(10, "assigned")); + List assignedtargets = targetManagement.createTargets(TestDataUtil.generateTargets(10, "assigned")); deploymentManagement.assignDistributionSet(assignedSet, assignedtargets); + // get final updated version of targets + assignedtargets = targetManagement.findTargetByControllerID( + assignedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), pageReq)) .as("Contains the assigned targets").containsAll(assignedtargets) .as("and that means the following expected amount").hasSize(10); @@ -727,8 +738,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement, distributionSetManagement); targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned")); - final List assignedtargets = targetManagement - .createTargets(TestDataUtil.generateTargets(10, "assigned")); + List assignedtargets = targetManagement.createTargets(TestDataUtil.generateTargets(10, "assigned")); // set on installed and assign another one deploymentManagement.assignDistributionSet(installedSet, assignedtargets).getActions().forEach(actionId -> { @@ -739,11 +749,13 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { }); deploymentManagement.assignDistributionSet(assignedSet, assignedtargets); + assignedtargets = targetManagement.findTargetByControllerID( + assignedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), TargetSpecifications.hasInstalledDistributionSet(installedSet.getId()), pageReq)) .as("Contains the assigned targets").containsAll(assignedtargets) .as("and that means the following expected amount").hasSize(10); - } @Test @@ -754,8 +766,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement, distributionSetManagement); targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned")); - final List installedtargets = targetManagement - .createTargets(TestDataUtil.generateTargets(10, "assigned")); + List installedtargets = targetManagement.createTargets(TestDataUtil.generateTargets(10, "assigned")); // set on installed and assign another one deploymentManagement.assignDistributionSet(installedSet, installedtargets).getActions().forEach(actionId -> { @@ -766,6 +777,10 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { }); deploymentManagement.assignDistributionSet(assignedSet, installedtargets); + // get final updated version of targets + installedtargets = targetManagement.findTargetByControllerID( + installedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), pageReq)) .as("Contains the assigned targets").containsAll(installedtargets) .as("and that means the following expected amount").hasSize(10); @@ -780,8 +795,7 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { final DistributionSet installedSet = TestDataUtil.generateDistributionSet("another", softwareManagement, distributionSetManagement); targetManagement.createTargets(TestDataUtil.generateTargets(10, "unassigned")); - final List installedtargets = targetManagement - .createTargets(TestDataUtil.generateTargets(10, "assigned")); + List installedtargets = targetManagement.createTargets(TestDataUtil.generateTargets(10, "assigned")); // set on installed and assign another one deploymentManagement.assignDistributionSet(installedSet, installedtargets).getActions().forEach(actionId -> { @@ -792,6 +806,10 @@ public class TargetManagementSearchTest extends AbstractIntegrationTest { }); deploymentManagement.assignDistributionSet(assignedSet, installedtargets); + // get final updated version of targets + installedtargets = targetManagement.findTargetByControllerID( + installedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())); + assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), TargetSpecifications.hasAssignedDistributionSet(assignedSet.getId()), pageReq)) .as("Contains the assigned targets").containsAll(installedtargets) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java new file mode 100644 index 000000000..d9de859cd --- /dev/null +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java @@ -0,0 +1,92 @@ +package org.eclipse.hawkbit.repository.model; + +import static org.fest.assertions.api.Assertions.assertThat; + +import org.eclipse.hawkbit.AbstractIntegrationTest; +import org.junit.Test; + +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Unit Tests - Repository") +@Stories("Repository Model") +public class ModelEqualsHashcodeTest extends AbstractIntegrationTest { + + @Test + @Description("Verfies that different objects even with identical primary key, version and tenant " + + "return different hash codes.") + public void differentEntitiesReturnDifferentHashCodes() { + assertThat(new Action().hashCode()).as("action should have different hashcode than action status") + .isNotEqualTo(new ActionStatus().hashCode()); + assertThat(new DistributionSet().hashCode()) + .as("Distribution set should have different hashcode than software module") + .isNotEqualTo(new SoftwareModule().hashCode()); + assertThat(new DistributionSet().hashCode()) + .as("Distribution set should have different hashcode than action status") + .isNotEqualTo(new ActionStatus().hashCode()); + assertThat(new DistributionSetType().hashCode()) + .as("Distribution set type should have different hashcode than action status") + .isNotEqualTo(new ActionStatus().hashCode()); + } + + @Test + @Description("Verfies that different object even with identical primary key, version and tenant " + + "are not equal.") + public void differentEntitiesAreNotEqual() { + assertThat(new Action().equals(new ActionStatus())).as("action equals action status").isFalse(); + assertThat(new DistributionSet().equals(new SoftwareModule())).as("Distribution set equals software module") + .isFalse(); + assertThat(new DistributionSet().equals(new ActionStatus())).as("Distribution set equals action status") + .isFalse(); + assertThat(new DistributionSetType().equals(new ActionStatus())) + .as("Distribution set type equals action status").isFalse(); + } + + @Test + @Description("Verfies that updated entities are not equal.") + public void changedEntitiesAreNotEqual() { + final SoftwareModuleType type = softwareManagement + .createSoftwareModuleType(new SoftwareModuleType("test", "test", "test", 1)); + assertThat(type).isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1)); + + type.setDescription("another"); + final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(type); + assertThat(type).as("Changed entity is not equal to the previous version").isNotEqualTo(updated); + } + + @Test + @Description("Verify that no proxy of the entity manager has an influence on the equals or hashcode result.") + public void managedEntityIsEqualToUnamangedObjectWithSameKey() { + final SoftwareModuleType type = softwareManagement + .createSoftwareModuleType(new SoftwareModuleType("test", "test", "test", 1)); + + final SoftwareModuleType mock = new SoftwareModuleType("test", "test", "test", 1); + mock.setId(type.getId()); + mock.setOptLockRevision(type.getOptLockRevision()); + mock.setTenant(type.getTenant()); + + assertThat(type).as("managed entity is equal to regular object with same content").isEqualTo(mock); + assertThat(type.hashCode()).as("managed entity has same hash code as regular object with same content") + .isEqualTo(mock.hashCode()); + } + + @Test + @Description("Verfies that updated entities do not have the same hashcode.") + public void updatedEntitiesHaveDifferentHashcodes() { + final SoftwareModuleType type = softwareManagement + .createSoftwareModuleType(new SoftwareModuleType("test", "test", "test", 1)); + assertThat(type.hashCode()).isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1).hashCode()); + + final int beforeChange = type.hashCode(); + type.setDescription("another"); + assertThat(type.hashCode()) + .as("Changed entity has no different hashcode than the previous version until updated in repository") + .isEqualTo(beforeChange); + + final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(type); + assertThat(type.hashCode()).as("Updated entity has different hashcode than the previous version") + .isNotEqualTo(updated.hashCode()); + } + +} From 5cf2ae511eb48b18d7d3efc824421bbed0f280fd Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 11:08:01 +0200 Subject: [PATCH 07/14] Fixed broken test. Signed-off-by: Kai Zimmermann --- .../eclipse/hawkbit/repository/DeploymentManagementTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 035866ab9..83db4ed96 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -611,8 +611,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final List deployResWithDsBTargets = targetManagement.findTargetByControllerID(deployResWithDsB .getDeployedTargets().stream().map(target -> target.getControllerId()).collect(Collectors.toList())); - assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsB.getDeployedTargets()); - assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsB.getDeployedTargets()); + assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets); + assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets); for (final Target t_ : deployed2DS) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); From 3d9b1465a2bc283247ee5abe95e711a5c7c3845a Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 11:31:01 +0200 Subject: [PATCH 08/14] Added missing license header. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/model/ModelEqualsHashcodeTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java index d9de859cd..e42ff4b9c 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ package org.eclipse.hawkbit.repository.model; import static org.fest.assertions.api.Assertions.assertThat; From b839fd49252237bb73bf85387c91ea1413d2d906 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 14:18:17 +0200 Subject: [PATCH 09/14] Log complete message in error case --- .../src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java index 4662c8d39..846c9f232 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java @@ -105,7 +105,7 @@ public class BaseAmqpService { } protected final void logAndThrowMessageError(final Message message, final String error) { - LOGGER.warn("Error \"{}\" reported by message {}", error, message.getMessageProperties().getMessageId()); + LOGGER.warn("Error \"{}\" reported by message: {}", error, message); throw new IllegalArgumentException(error); } From ae7585e1bc42ed406f3804c205948b7baf174e8f Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 14:47:00 +0200 Subject: [PATCH 10/14] Added description to test asserts. Signed-off-by: Kai Zimmermann --- .../hawkbit/repository/model/ModelEqualsHashcodeTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java index e42ff4b9c..45e56167a 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/model/ModelEqualsHashcodeTest.java @@ -56,7 +56,8 @@ public class ModelEqualsHashcodeTest extends AbstractIntegrationTest { public void changedEntitiesAreNotEqual() { final SoftwareModuleType type = softwareManagement .createSoftwareModuleType(new SoftwareModuleType("test", "test", "test", 1)); - assertThat(type).isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1)); + assertThat(type).as("persited entity is not equal to regular object") + .isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1)); type.setDescription("another"); final SoftwareModuleType updated = softwareManagement.updateSoftwareModuleType(type); @@ -84,7 +85,8 @@ public class ModelEqualsHashcodeTest extends AbstractIntegrationTest { public void updatedEntitiesHaveDifferentHashcodes() { final SoftwareModuleType type = softwareManagement .createSoftwareModuleType(new SoftwareModuleType("test", "test", "test", 1)); - assertThat(type.hashCode()).isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1).hashCode()); + assertThat(type.hashCode()).as("persited entity does not have same hashcode as regular object") + .isNotEqualTo(new SoftwareModuleType("test", "test", "test", 1).hashCode()); final int beforeChange = type.hashCode(); type.setDescription("another"); From 2b5a887f6e5605643973cf26ba3b4a57eba7f32b Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 15:47:24 +0200 Subject: [PATCH 11/14] Fixed wrong timeframe check. Set proper 24h default. Signed-off-by: Kai Zimmermann --- .../main/java/org/eclipse/hawkbit/ControllerPollProperties.java | 2 +- .../eclipse/hawkbit/tenancy/configuration/DurationHelper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java index c923963d2..0d70ae69d 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java @@ -31,7 +31,7 @@ public class ControllerPollProperties { * Maximum polling time that can be configured by a tenant in HH:MM:SS * notation. */ - private String maxPollingTime = "23:59:00"; + private String maxPollingTime = "23:59:59"; /** * Minimum polling time that can be configured by a tenant in HH:MM:SS diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java index 8e7c46223..b87cf524a 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java @@ -37,7 +37,7 @@ public final class DurationHelper { } public boolean isWithinRange(final Duration duration) { - return duration.compareTo(min) > 0 && duration.compareTo(max) < 0; + return duration.compareTo(min) >= 0 && duration.compareTo(max) <= 0; } } From 3bbbadd1654612fd849cc650f61b08e87e28f3c9 Mon Sep 17 00:00:00 2001 From: SirWayne Date: Thu, 31 Mar 2016 15:53:52 +0200 Subject: [PATCH 12/14] Check if the message body is empty Signed-off-by: SirWayne --- .../java/org/eclipse/hawkbit/amqp/BaseAmqpService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java index 8a054165b..293a8212c 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java @@ -59,7 +59,7 @@ public class BaseAmqpService { */ @SuppressWarnings("unchecked") public T convertMessage(final Message message, final Class clazz) { - if (message == null || message.getBody() == null) { + if (isMessageBodyEmpty(message)) { return null; } message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, @@ -67,6 +67,10 @@ public class BaseAmqpService { return (T) rabbitTemplate.getMessageConverter().fromMessage(message); } + private boolean isMessageBodyEmpty(final Message message) { + return message == null || message.getBody() == null || message.getBody().length == 0; + } + /** * Is needed to convert a incoming message to is originally list object * type. @@ -79,7 +83,7 @@ public class BaseAmqpService { */ @SuppressWarnings("unchecked") public List convertMessageList(final Message message, final Class clazz) { - if (message == null || message.getBody() == null) { + if (isMessageBodyEmpty(message)) { return Collections.emptyList(); } message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, From 9b11d92b7f42bdaa78262c13bed202ed675f91e4 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 31 Mar 2016 15:56:51 +0200 Subject: [PATCH 13/14] Added javadoc. Signed-off-by: Kai Zimmermann --- .../hawkbit/tenancy/configuration/DurationHelper.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java index b87cf524a..5968f4420 100644 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/DurationHelper.java @@ -36,6 +36,13 @@ public final class DurationHelper { this.max = max; } + /** + * Checks if the requested duration is in the defined min/max range. + * + * @param duration + * to checked + * @return true if in time range + */ public boolean isWithinRange(final Duration duration) { return duration.compareTo(min) >= 0 && duration.compareTo(max) <= 0; } From 0a0c08b70042ef1043d58b89ee52eb444cabe84d Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Fri, 1 Apr 2016 15:55:00 +0200 Subject: [PATCH 14/14] Fixed wrong call of sw module type. UI uses name and not key. Signed-off-by: Kai Zimmermann --- .../java/org/eclipse/hawkbit/repository/SoftwareManagement.java | 2 +- .../java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java index c6eab402a..384353b8e 100644 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java @@ -259,7 +259,7 @@ public class SoftwareManagement { } /** - * retrieves {@link SoftwareModule}s by their name AND version. + * retrieves {@link SoftwareModule} by their name AND version AND type.. * * @param name * of the {@link SoftwareModule} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java index 67e71ba4f..3f947cfd0 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -809,7 +809,7 @@ public final class HawkbitCommonUtil { public static boolean isDuplicate(final String name, final String version, final String type) { final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class); final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version, - swMgmtService.findSoftwareModuleTypeByKey(type)); + swMgmtService.findSoftwareModuleTypeByName(type)); boolean duplicate = false; if (swModule != null) { duplicate = true;