From 6a93b158548f4ecb81996bd8e69ec7d3e1d196b5 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Wed, 10 Feb 2016 12:43:54 +0100 Subject: [PATCH] fixing newly created bug by trying to simplify if-statement with commit a4e1ae7ac8317625f1a4ce391ffbaee5fc9344d8 Signed-off-by: Michael Hirsch --- .../DistributionAddUpdateWindowLayout.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 256a04926..dfdbcd9de 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -344,21 +344,22 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { private boolean duplicateCheck(final String name, final String version) { final DistributionSet existingDs = distributionSetManagement.findDistributionSetByNameAndVersion(name, version); + /* + * Distribution should not exists with the same name & version. Display + * error message, when the "existingDs" is not null and it is add window + * (or) when the "existingDs" is not null and it is edit window and the + * distribution Id of the edit window is different then the "existingDs" + */ + if (existingDs != null && !existingDs.getId().equals(editDistId)) { + distNameTextField.addStyleName("v-textfield-error"); + distVersionTextField.addStyleName("v-textfield-error"); + notificationMessage.displayValidationError( + i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); - if (existingDs == null) { + return false; + } else { return true; } - - if (editDistribution && !existingDs.getId().equals(editDistId)) { - return true; - } - - distNameTextField.addStyleName("v-textfield-error"); - distVersionTextField.addStyleName("v-textfield-error"); - notificationMessage.displayValidationError( - i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); - - return false; } /**