From ceb2789a350923ae1de18ee02af4bff83a2b6600 Mon Sep 17 00:00:00 2001 From: Xaiofeng Bai Date: Tue, 7 Sep 2021 09:42:09 +0800 Subject: [PATCH] JBPM-9884 Dont allow to modify process variable of type Integer/Boolean/..etc with invalid values through business-central console. --- .../process/core/datatype/impl/type/BooleanDataType.java | 4 +++- .../process/core/datatype/impl/type/FloatDataType.java | 5 +++-- .../process/core/datatype/impl/type/IntegerDataType.java | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/BooleanDataType.java b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/BooleanDataType.java index 36eeed2658..2fe2a42778 100644 --- a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/BooleanDataType.java +++ b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/BooleanDataType.java @@ -41,7 +41,9 @@ public void writeExternal(ObjectOutput out) throws IOException { @Override public boolean verifyDataType(final Object value) { - if ( value instanceof Boolean ) { + if (value == null) { + return true; + } else if (value instanceof Boolean || "true".equalsIgnoreCase(value.toString()) || "false".equalsIgnoreCase(value.toString())) { return true; } return false; diff --git a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/FloatDataType.java b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/FloatDataType.java index e3fa20d017..7e233cc2ef 100644 --- a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/FloatDataType.java +++ b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/FloatDataType.java @@ -20,6 +20,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; +import org.apache.commons.lang3.StringUtils; import org.jbpm.process.core.datatype.DataType; /** @@ -41,9 +42,9 @@ public void writeExternal(ObjectOutput out) throws IOException { @Override public boolean verifyDataType(final Object value) { - if ( value instanceof Float ) { + if (value == null) { return true; - } else if ( value == null ) { + } else if (value instanceof Float || StringUtils.isNumeric(value.toString())) { return true; } else { return false; diff --git a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/IntegerDataType.java b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/IntegerDataType.java index a0a2194e06..019df7f907 100644 --- a/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/IntegerDataType.java +++ b/jbpm-flow/src/main/java/org/jbpm/process/core/datatype/impl/type/IntegerDataType.java @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import org.jbpm.process.core.datatype.DataType; +import org.apache.commons.lang3.StringUtils; /** * Representation of an integer datatype. @@ -41,9 +42,9 @@ public void writeExternal(ObjectOutput out) throws IOException { @Override public boolean verifyDataType(final Object value) { - if ( value instanceof Integer ) { + if (value == null) { return true; - } else if ( value == null ) { + } else if (value instanceof Integer || StringUtils.isNumeric(value.toString())) { return true; } else { return false; @@ -75,4 +76,8 @@ public Object valueOf(String value) { } } + public static void main(String[] args){ + IntegerDataType idt = new IntegerDataType(); + idt.verifyDataType("1234567"); + } }