diff --git a/job-engine/commons/src/main/java/org/eclipse/kapua/job/engine/commons/wrappers/StepContextWrapper.java b/job-engine/commons/src/main/java/org/eclipse/kapua/job/engine/commons/wrappers/StepContextWrapper.java index 1f4cb54698a..21eb42028ef 100644 --- a/job-engine/commons/src/main/java/org/eclipse/kapua/job/engine/commons/wrappers/StepContextWrapper.java +++ b/job-engine/commons/src/main/java/org/eclipse/kapua/job/engine/commons/wrappers/StepContextWrapper.java @@ -18,13 +18,11 @@ import org.eclipse.kapua.commons.util.xml.XmlUtil; import org.eclipse.kapua.model.id.KapuaId; import org.eclipse.kapua.model.id.KapuaIdFactory; -import org.xml.sax.SAXException; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.Metric; import javax.batch.runtime.context.StepContext; import javax.xml.bind.DatatypeConverter; -import javax.xml.bind.JAXBException; import java.io.Serializable; import java.util.Properties; @@ -92,10 +90,15 @@ public > T getStepProperty(String stepPropertyName, Class\n\n \n org.eclipse.kura.demo.heater.Heater\n \n \n 0.25\n \n \n 60\n \n \n 22:00\n \n \n false\n \n \n org.eclipse.kura.demo.heater.Heater\n \n \n org.eclipse.kura.demo.heater.Heater\n \n \n 06:00\n \n \n Program\n \n \n data/210\n \n \n 30.0\n \n \n 2\n \n \n 13.0\n \n \n 30.0\n \n \n \n", 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 c94f7d61121..207951b3a17 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 @@ -125,6 +125,7 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException { return txManager.execute(tx -> { // Check job step definition validateJobStepProperties(tx, jobStepCreator); + // Check duplicate name if (jobStepRepository.countEntitiesWithNameInScope( tx, @@ -414,8 +415,17 @@ private void validateJobStepProperties(List jobStepProperties, } if (jobStepProperty.getPropertyValue() != null) { - ArgumentValidator.areEqual(jobStepProperty.getPropertyType(), jobStepDefinitionProperty.getPropertyType(), "stepProperties[]." + jobStepProperty.getName()); - ArgumentValidator.lengthRange(jobStepProperty.getPropertyValue(), jobStepDefinitionProperty.getMinLength(), jobStepDefinitionProperty.getMaxLength(), "stepProperties[]." + jobStepProperty.getName()); + ArgumentValidator.areEqual( + jobStepProperty.getPropertyType(), + jobStepDefinitionProperty.getPropertyType(), + "stepProperties[]." + jobStepProperty.getName() + ); + ArgumentValidator.lengthRange( + jobStepProperty.getPropertyValue(), + jobStepDefinitionProperty.getMinLength(), + jobStepDefinitionProperty.getMaxLength(), + "stepProperties[]." + jobStepProperty.getName() + ); validateJobStepPropertyValue(jobStepProperty, jobStepDefinitionProperty); } @@ -447,7 +457,12 @@ private , E extends Enum> void validateJobStepPropert Class jobStepDefinitionPropertyClassEnum = (Class) jobStepDefinitionPropertyClass; Enum.valueOf(jobStepDefinitionPropertyClassEnum, jobStepProperty.getPropertyValue()); } else { - XmlUtil.unmarshal(jobStepProperty.getPropertyValue(), jobStepDefinitionPropertyClass); + // Try both formats: XML - JSON + try { + XmlUtil.unmarshal(jobStepProperty.getPropertyValue(), jobStepDefinitionPropertyClass); + } catch (Exception e) { + XmlUtil.unmarshalJson(jobStepProperty.getPropertyValue(), jobStepDefinitionPropertyClass); + } } } catch (KapuaIllegalArgumentException kiae) {