From 33b290ac97cdac42bdc4508a149ed6d46b654f13 Mon Sep 17 00:00:00 2001 From: MDeLuise <66636702+MDeLuise@users.noreply.github.com> Date: Thu, 6 Jul 2023 11:38:55 +0200 Subject: [PATCH] fix(batch-jobs): Add max length to `configuration put` step definition. A configuration cannot have more than 65535 characters, due to the database column `TEXT` definition. Adding the validation in the frontend permits to fail fast illegal requests without sending them to the backend. Also add check on backend. --- .../console/module/job/client/steps/JobStepAddDialog.java | 1 + .../kapua/service/job/step/internal/JobStepServiceImpl.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/client/steps/JobStepAddDialog.java b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/client/steps/JobStepAddDialog.java index 0579a50c700..86c2408efb6 100644 --- a/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/client/steps/JobStepAddDialog.java +++ b/console/module/job/src/main/java/org/eclipse/kapua/app/console/module/job/client/steps/JobStepAddDialog.java @@ -340,6 +340,7 @@ protected void refreshJobStepDefinition(GwtJobStepDefinition gwtJobStepDefinitio textArea.setData(PROPERTY_TYPE, property.getPropertyType()); textArea.setData(PROPERTY_NAME, property.getPropertyName()); + textArea.setMaxLength(65535); jobStepPropertiesPanel.add(textArea); if (property.getExampleValue() != null) { diff --git a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java index fd30c307f05..03db81de9b5 100644 --- a/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java +++ b/service/job/internal/src/main/java/org/eclipse/kapua/service/job/step/internal/JobStepServiceImpl.java @@ -93,6 +93,11 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException { ArgumentValidator.validateEntityName(jobStepCreator.getName(), "jobStepCreator.name"); ArgumentValidator.notNull(jobStepCreator.getJobStepDefinitionId(), "jobStepCreator.stepDefinitionId"); + for (JobStepProperty jobStepProperty : jobStepCreator.getStepProperties()) { + Integer stepPropertyMaxLength = jobStepProperty.getMaxLength() != null ? jobStepProperty.getMaxLength() : 65535; + ArgumentValidator.lengthRange(jobStepProperty.getPropertyValue(), jobStepProperty.getMinLength(), stepPropertyMaxLength, "stepProperties[]." + jobStepProperty.getName()); + } + if (jobStepCreator.getDescription() != null) { ArgumentValidator.numRange(jobStepCreator.getDescription().length(), 0, 8192, "jobStepCreator.description"); }