From 51c52b87b7307e8c674fcbc05d449144eccc77e1 Mon Sep 17 00:00:00 2001 From: kaizimmerm Date: Mon, 26 Sep 2016 15:53:24 +0200 Subject: [PATCH] Fixed sonar issues Signed-off-by: kaizimmerm --- .../hawkbit/ui/menu/DashboardMenu.java | 2 +- .../rollout/AddUpdateRolloutWindowLayout.java | 59 +++++-------------- 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java index fb3dc6c9f..c35378e20 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java @@ -296,7 +296,7 @@ public final class DashboardMenu extends CustomComponent { final Optional findFirst = dashboardVaadinViews.stream() .filter(view -> view.getViewName().equals(viewName)).findFirst(); - if (findFirst == null || !findFirst.isPresent()) { + if (!findFirst.isPresent()) { return null; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java index fd551a9b1..dae322b2e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java @@ -43,10 +43,10 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; -import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; @@ -610,26 +610,15 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { - try { - if (isNoOfGroupsOrTargetFilterEmpty()) { - uiNotification - .displayValidationError(i18n.get("message.rollout.noofgroups.or.targetfilter.missing")); - } else { - if (value != null) { - final int groupSize = getGroupSize(); - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, - groupSize).validate(Integer.valueOf(value.toString())); - } + if (isNoOfGroupsOrTargetFilterEmpty()) { + uiNotification.displayValidationError(i18n.get("message.rollout.noofgroups.or.targetfilter.missing")); + } else { + if (value != null) { + final int groupSize = getGroupSize(); + new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, groupSize), 0, groupSize) + .validate(Integer.valueOf(value.toString())); } } - // suppress the need of preserve original exception, will blow - // up the - // log and not necessary here - catch (final InvalidValueException ex) { - // we have to throw the exception here, otherwise the UI won't - // show the vaadin validation error! - throw ex; - } } private boolean isNoOfGroupsOrTargetFilterEmpty() { @@ -648,19 +637,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { - try { - if (value != null) { - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100) - .validate(Integer.valueOf(value.toString())); - } - } - // suppress the need of preserve original exception, will blow - // up the - // log and not necessary here - catch (final InvalidValueException ex) { - // we have to throw the exception here, otherwise the UI won't - // show the vaadin validation error! - throw ex; + if (value != null) { + new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100) + .validate(Integer.valueOf(value.toString())); } } } @@ -670,19 +649,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout { @Override public void validate(final Object value) { - try { - if (value != null) { - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500) - .validate(Integer.valueOf(value.toString())); - } - } - // suppress the need of preserve original exception, will blow - // up the - // log and not necessary here - catch (final InvalidValueException ex) { - // we have to throw the exception here, otherwise the UI won't - // show the vaadin validation error! - throw ex; + if (value != null) { + new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500) + .validate(Integer.valueOf(value.toString())); } } }