From d70aab578b0fcf42f57046ab1f174f5420495518 Mon Sep 17 00:00:00 2001 From: SimoneFiorani Date: Fri, 29 Sep 2023 17:45:08 +0200 Subject: [PATCH 1/3] fix: resolved inconsistency for empty string csv input Signed-off-by: SimoneFiorani --- .../kura/web/server/util/AssetConfigValidator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java index 87028f9e824..c3d451c5076 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/util/AssetConfigValidator.java @@ -34,6 +34,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.eclipse.kura.configuration.metatype.Option; +import org.eclipse.kura.configuration.metatype.Scalar; import org.eclipse.kura.core.configuration.metatype.Tad; import org.eclipse.kura.driver.Driver; import org.eclipse.kura.internal.wire.asset.WireAssetChannelDescriptor; @@ -305,12 +306,13 @@ protected Object validate(Tad field, String value, List errors, int line String trimmedValue = value.trim(); final boolean isEmpty = trimmedValue.isEmpty(); + final boolean isEmptyString = field.getType().equals(Scalar.STRING); if (field.isRequired() && isEmpty) { throw new ValidationException(); } - if (!isEmpty) { + if (isEmptyOrEmptyString(isEmpty, isEmptyString)) { // Validate "Options" field first. Data type will be taken care of next. if (!field.getOption().isEmpty()) { boolean foundEqual = false; @@ -361,6 +363,10 @@ protected Object validate(Tad field, String value, List errors, int line return null; } + private boolean isEmptyOrEmptyString(boolean isEmpty, boolean isEmptyString) { + return !isEmpty || isEmptyString; + } + protected interface ValidationErrorConsumer { public void addError(String errorMsg); From 09de1758cd82e07c19c531b3b3931d898aff0e33 Mon Sep 17 00:00:00 2001 From: SimoneFiorani Date: Wed, 4 Oct 2023 13:50:59 +0200 Subject: [PATCH 2/3] Updated order of checkboxed and added new checkbox description Signed-off-by: SimoneFiorani --- .../drivers/assets/AssetConfigurationUi.java | 12 +++++ .../assets/AssetConfigurationUi.ui.xml | 3 ++ .../kura/web/server/servlet/FileServlet.java | 3 +- .../web/server/util/AssetConfigValidator.java | 44 ++++++++++++------- .../web/client/messages/Messages.properties | 2 + 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java index b7ca7a9f8e3..e175415585d 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/drivers/assets/AssetConfigurationUi.java @@ -145,12 +145,16 @@ interface AssetConfigurationUiBinder extends UiBinder