From 87c3f8ae5b0ac9d3ddaceb18fc06e0227ce317a2 Mon Sep 17 00:00:00 2001 From: venetrius Date: Mon, 16 Sep 2024 16:25:25 +0200 Subject: [PATCH 1/8] fix(client) don't expose executionId to public API related to: #4523 --- .../bpm/client/task/impl/ExternalTaskImpl.java | 9 +++++---- .../impl/value/DeferredFileValueImpl.java | 8 +------- .../client/variable/value/DeferredFileValue.java | 16 ---------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java index ad8c00061e9..20fe6f4e484 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java @@ -25,6 +25,7 @@ import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.variable.impl.TypedValueField; import org.camunda.bpm.client.variable.impl.VariableValue; +import org.camunda.bpm.client.variable.impl.value.DeferredFileValueImpl; import org.camunda.bpm.client.variable.value.DeferredFileValue; import org.camunda.bpm.engine.variable.VariableMap; import org.camunda.bpm.engine.variable.Variables; @@ -258,8 +259,8 @@ public T getVariable(String variableName) { VariableValue variableValue = receivedVariableMap.get(variableName); if (variableValue != null) { - if(variableValue.getTypedValue() instanceof DeferredFileValue) { - DeferredFileValue deferredFileValue = (DeferredFileValue) variableValue.getTypedValue(); + if(variableValue.getTypedValue() instanceof DeferredFileValueImpl) { + DeferredFileValueImpl deferredFileValue = (DeferredFileValueImpl) variableValue.getTypedValue(); deferredFileValue.setExecutionId(this.executionId); } value = (T) variableValue.getValue(); @@ -300,8 +301,8 @@ public T getVariableTyped(String variableName, boolean de VariableValue variableValue = receivedVariableMap.get(variableName); if (variableValue != null) { typedValue = variableValue.getTypedValue(deserializeObjectValues); - if(typedValue instanceof DeferredFileValue) { - DeferredFileValue deferredFileValue = (DeferredFileValue) typedValue; + if(typedValue instanceof DeferredFileValueImpl) { + DeferredFileValueImpl deferredFileValue = (DeferredFileValueImpl) typedValue; deferredFileValue.setExecutionId(this.executionId); } } diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java index aeea49e855a..b3fc6a2accf 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java @@ -80,20 +80,14 @@ public void setVariableName(String variableName) { this.variableName = variableName; } - @Override public void setExecutionId(String executionId){ this.executionId = executionId; }; - @Override - public String getExecutionId() { - return executionId; - } - @Override public String toString() { return "DeferredFileValueImpl [mimeType=" + mimeType + ", filename=" + filename + ", type=" + type + ", " - + "isTransient=" + isTransient + ", isLoaded=" + isLoaded + ", processInstanceId" + processInstanceId + ", executionId" + executionId + "]"; + + "isTransient=" + isTransient + ", isLoaded=" + isLoaded + "]"; } } diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/value/DeferredFileValue.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/value/DeferredFileValue.java index c8158ff55de..1eea30f8e93 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/value/DeferredFileValue.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/value/DeferredFileValue.java @@ -39,20 +39,4 @@ public interface DeferredFileValue extends FileValue { */ boolean isLoaded(); - /** - * Sets the executionId, which defines the scope of the DeferredFileValue. - * This identifier ensures that the correct scope is applied when loading the file value. - * - * @param executionId defines the scope of the DeferredFileValue - */ - void setExecutionId(String executionId); - - /** - * Returns the executionId, which specifies the scope of the DeferredFileValue. - * This identifier ensures that the correct scope is applied when loading the file value. - * - * @return the executionId which defines the scope of the DeferredFileValue - */ - String getExecutionId(); - } From 25309042d62a87fb90c8ca4d24e42dbdce3c1ea4 Mon Sep 17 00:00:00 2001 From: venetrius Date: Thu, 19 Sep 2024 12:08:05 +0200 Subject: [PATCH 2/8] add IT test --- .../client/variable/FileSerializationIT.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index 49522436d05..3c5d8f9ff47 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -50,6 +50,7 @@ import org.camunda.bpm.engine.variable.Variables; import org.camunda.bpm.engine.variable.value.FileValue; import org.camunda.bpm.engine.variable.value.TypedValue; +import org.camunda.bpm.model.bpmn.Bpmn; import org.camunda.bpm.model.bpmn.BpmnModelInstance; import org.camunda.commons.utils.IoUtil; import org.junit.Before; @@ -63,6 +64,8 @@ public class FileSerializationIT { protected static final String VARIABLE_NAME_FILE = "fileVariable"; protected static final String VARIABLE_VALUE_FILE_NAME = "aFileName.txt"; protected static final byte[] VARIABLE_VALUE_FILE_VALUE = "ABC".getBytes(); + protected static final String LOCAL_VARIABLE_VALUE_FILE_NAME = "localFileName.txt"; + protected static final String VARIABLE_VALUE_FILE_ENCODING = "UTF-8"; protected static final String VARIABLE_VALUE_FILE_MIME_TYPE = "text/plain"; @@ -117,6 +120,41 @@ public void shouldGet() { .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); } + @Test + public void shouldGetLocalAndGlobalVariables() { + // given + ProcessDefinitionDto processDefinitionDto = engineRule.deploy( + Bpmn.createExecutableProcess("process") + .startEvent("startEvent") + .serviceTask("serviceTaskFoo") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_FOO) + // create the local file variable with the same content but different name + .camundaInputParameter(LOCAL_VARIABLE_VALUE_FILE_NAME, "${execution.getVariableTyped('fileVariable')}") + .serviceTask("serviceTaskBar") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_BAR) + .endEvent("endEvent") + .done() + ).get(0); + + engineRule.startProcessInstance(processDefinitionDto.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE); + + // when + client.subscribe(EXTERNAL_TASK_TOPIC_FOO) + .handler(handler) + .open(); + + clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty()); + + ExternalTask task = handler.getHandledTasks().get(0); + + // then + assertThat(task.getAllVariables().size()).isEqualTo(2); + assertThat(IoUtil.inputStreamAsString(task.getVariable(VARIABLE_NAME_FILE))) + .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); + assertThat(IoUtil.inputStreamAsString(task.getVariable(LOCAL_VARIABLE_VALUE_FILE_NAME))) + .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); + } + @Test public void shouldGetAll() { // given From 3e1eed87d95d19f9e76415931b12c0226fe34422 Mon Sep 17 00:00:00 2001 From: venetrius Date: Thu, 19 Sep 2024 19:00:08 +0200 Subject: [PATCH 3/8] Add test to verify ExecutionId is set correctly --- .../camunda/bpm/client/variable/FileSerializationIT.java | 9 ++++++++- .../variable/impl/value/DeferredFileValueImpl.java | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index 3c5d8f9ff47..853e2a9b2c3 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -46,6 +46,7 @@ import org.camunda.bpm.client.util.RecordingExternalTaskHandler; import org.camunda.bpm.client.util.RecordingInvocationHandler; import org.camunda.bpm.client.util.RecordingInvocationHandler.RecordedInvocation; +import org.camunda.bpm.client.variable.impl.value.DeferredFileValueImpl; import org.camunda.bpm.client.variable.value.DeferredFileValue; import org.camunda.bpm.engine.variable.Variables; import org.camunda.bpm.engine.variable.value.FileValue; @@ -183,7 +184,9 @@ public void shouldGetAll() { @Test public void shouldGetTyped_Deferred() { // given - engineRule.startProcessInstance(processDefinition.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE); + ProcessInstanceDto processInstanceDto = engineRule.startProcessInstance(processDefinition.getId(), + VARIABLE_NAME_FILE, + VARIABLE_VALUE_FILE); client.subscribe(EXTERNAL_TASK_TOPIC_FOO) .handler(handler) @@ -201,6 +204,10 @@ public void shouldGetTyped_Deferred() { assertThat(typedValue.isLoaded()).isFalse(); assertThat(typedValue.getEncoding()).isNull(); assertThat(typedValue.getMimeType()).isNull(); + + DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue; + assertThat(typedValueImpl.getProcessInstanceId()).isEqualTo(processInstanceDto.getId()); + assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); } @Test diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java index b3fc6a2accf..258a3ed0666 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java @@ -76,6 +76,10 @@ public void setProcessInstanceId(String processInstanceId) { this.processInstanceId = processInstanceId; } + public String getProcessInstanceId() { + return processInstanceId; + } + public void setVariableName(String variableName) { this.variableName = variableName; } @@ -84,6 +88,10 @@ public void setExecutionId(String executionId){ this.executionId = executionId; }; + public String getExecutionId() { + return executionId; + } + @Override public String toString() { return "DeferredFileValueImpl [mimeType=" + mimeType + ", filename=" + filename + ", type=" + type + ", " From 5fc8dfd7a472e097b35b4f9dd250ca00726d0d84 Mon Sep 17 00:00:00 2001 From: venetrius Date: Fri, 20 Sep 2024 10:42:42 +0200 Subject: [PATCH 4/8] shouldGetVariableTypedForLocalVariable --- .../client/variable/FileSerializationIT.java | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index 853e2a9b2c3..aa0678a562c 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -65,7 +65,7 @@ public class FileSerializationIT { protected static final String VARIABLE_NAME_FILE = "fileVariable"; protected static final String VARIABLE_VALUE_FILE_NAME = "aFileName.txt"; protected static final byte[] VARIABLE_VALUE_FILE_VALUE = "ABC".getBytes(); - protected static final String LOCAL_VARIABLE_VALUE_FILE_NAME = "localFileName.txt"; + protected static final String LOCAL_VARIABLE_NAME_FILE = "localFileName.txt"; protected static final String VARIABLE_VALUE_FILE_ENCODING = "UTF-8"; protected static final String VARIABLE_VALUE_FILE_MIME_TYPE = "text/plain"; @@ -130,7 +130,7 @@ public void shouldGetLocalAndGlobalVariables() { .serviceTask("serviceTaskFoo") .camundaExternalTask(EXTERNAL_TASK_TOPIC_FOO) // create the local file variable with the same content but different name - .camundaInputParameter(LOCAL_VARIABLE_VALUE_FILE_NAME, "${execution.getVariableTyped('fileVariable')}") + .camundaInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}") .serviceTask("serviceTaskBar") .camundaExternalTask(EXTERNAL_TASK_TOPIC_BAR) .endEvent("endEvent") @@ -152,7 +152,7 @@ public void shouldGetLocalAndGlobalVariables() { assertThat(task.getAllVariables().size()).isEqualTo(2); assertThat(IoUtil.inputStreamAsString(task.getVariable(VARIABLE_NAME_FILE))) .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); - assertThat(IoUtil.inputStreamAsString(task.getVariable(LOCAL_VARIABLE_VALUE_FILE_NAME))) + assertThat(IoUtil.inputStreamAsString(task.getVariable(LOCAL_VARIABLE_NAME_FILE))) .isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); } @@ -210,6 +210,46 @@ public void shouldGetTyped_Deferred() { assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); } + @Test + public void shouldGetVariableTypedForLocalVariable() { + // given + ProcessDefinitionDto processDefinitionDto = engineRule.deploy( + Bpmn.createExecutableProcess("process") + .startEvent("startEvent") + .serviceTask("serviceTaskFoo") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_FOO) + // create the local file variable with the same content but different name + .camundaInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}") + .serviceTask("serviceTaskBar") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_BAR) + .endEvent("endEvent") + .done() + ).get(0); + + ProcessInstanceDto processInstanceDto = engineRule.startProcessInstance(processDefinitionDto.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE); + + // when + client.subscribe(EXTERNAL_TASK_TOPIC_FOO) + .handler(handler) + .open(); + + clientRule.waitForFetchAndLockUntil(() -> !handler.getHandledTasks().isEmpty()); + + ExternalTask task = handler.getHandledTasks().get(0); + + // then + DeferredFileValue typedValue = task.getVariableTyped(LOCAL_VARIABLE_NAME_FILE); + assertThat(typedValue.getFilename()).isEqualTo(VARIABLE_VALUE_FILE_NAME); + assertThat(typedValue.getType()).isEqualTo(FILE); + assertThat(typedValue.isLoaded()).isFalse(); + assertThat(typedValue.getEncoding()).isNull(); + assertThat(typedValue.getMimeType()).isNull(); + + DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue; + assertThat(typedValueImpl.getProcessInstanceId()).isEqualTo(processInstanceDto.getId()); + assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); + } + @Test public void shouldGetTyped_Loaded() { // given From b4d8368ea6963349e11dfb09eb3b7e3d5c296b71 Mon Sep 17 00:00:00 2001 From: venetrius Date: Fri, 20 Sep 2024 10:45:36 +0200 Subject: [PATCH 5/8] Update VariableValue to serialize executionId, remove processInstanceId --- .../bpm/client/variable/FileSerializationIT.java | 2 -- .../bpm/client/variable/impl/TypedValues.java | 4 ++-- .../bpm/client/variable/impl/VariableValue.java | 10 +++++----- .../variable/impl/value/DeferredFileValueImpl.java | 8 -------- .../bpm/client/task/ExternalTaskImplTest.java | 12 ++++++------ 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index aa0678a562c..1117ccb8f59 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -206,7 +206,6 @@ public void shouldGetTyped_Deferred() { assertThat(typedValue.getMimeType()).isNull(); DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue; - assertThat(typedValueImpl.getProcessInstanceId()).isEqualTo(processInstanceDto.getId()); assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); } @@ -246,7 +245,6 @@ public void shouldGetVariableTypedForLocalVariable() { assertThat(typedValue.getMimeType()).isNull(); DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue; - assertThat(typedValueImpl.getProcessInstanceId()).isEqualTo(processInstanceDto.getId()); assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); } diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/TypedValues.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/TypedValues.java index f72e7adbf39..cd72d1b9282 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/TypedValues.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/TypedValues.java @@ -69,7 +69,7 @@ public Map serializeVariables(Map varia @SuppressWarnings("rawtypes") public Map wrapVariables(ExternalTask externalTask, Map variables) { - String processInstanceId = externalTask.getProcessInstanceId(); + String executionId = externalTask.getExecutionId(); Map result = new HashMap<>(); @@ -80,7 +80,7 @@ public Map wrapVariables(ExternalTask externalTask, Map { - protected String processInstanceId; + protected String executionId; protected String variableName; protected TypedValueField typedValueField; protected ValueMappers mappers; @@ -30,8 +30,8 @@ public class VariableValue { protected ValueMapper serializer; protected T cachedValue; - public VariableValue(String processInstanceId, String variableName, TypedValueField typedValueField, ValueMappers mappers) { - this.processInstanceId = processInstanceId; + public VariableValue(String executionId, String variableName, TypedValueField typedValueField, ValueMappers mappers) { + this.executionId = executionId; this.variableName = variableName; this.typedValueField = typedValueField; this.mappers = mappers; @@ -63,7 +63,7 @@ public T getTypedValue(boolean deserializeValue) { if (cachedValue instanceof DeferredFileValueImpl) { DeferredFileValueImpl fileValue = (DeferredFileValueImpl) cachedValue; - fileValue.setProcessInstanceId(processInstanceId); + fileValue.setExecutionId(executionId); fileValue.setVariableName(variableName); } } @@ -83,7 +83,7 @@ public ValueMapper getSerializer() { public String toString() { return "VariableValue [" + "cachedValue=" + cachedValue + ", " - + "processInstanceId=" + processInstanceId + ", " + + "executionId=" + executionId + ", " + "variableName=" + variableName + ", " + "typedValueField=" + typedValueField + "]"; } diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java index 258a3ed0666..92fbd851777 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java @@ -72,14 +72,6 @@ public InputStream getValue() { return super.getValue(); } - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public String getProcessInstanceId() { - return processInstanceId; - } - public void setVariableName(String variableName) { this.variableName = variableName; } diff --git a/clients/java/client/src/test/java/org/camunda/bpm/client/task/ExternalTaskImplTest.java b/clients/java/client/src/test/java/org/camunda/bpm/client/task/ExternalTaskImplTest.java index 65d504eddde..9cd1e151c10 100644 --- a/clients/java/client/src/test/java/org/camunda/bpm/client/task/ExternalTaskImplTest.java +++ b/clients/java/client/src/test/java/org/camunda/bpm/client/task/ExternalTaskImplTest.java @@ -139,8 +139,8 @@ public void shouldDisplayAttributesIncludingMapsInToString() { task.setWorkerId("wi"); Map receivedVariables = new LinkedHashMap<>(); - receivedVariables.put("rv1", generateVariableValue("pii", "variable1", ValueType.STRING.getName(), "value1", 42, "vi2")); - receivedVariables.put("rv2", generateVariableValue("pii", "variable2", ValueType.INTEGER.getName(), 99, 42, "vi2", 87L)); + receivedVariables.put("rv1", generateVariableValue(task.getExecutionId(), "variable1", ValueType.STRING.getName(), "value1", 42, "vi2")); + receivedVariables.put("rv2", generateVariableValue(task.getExecutionId(), "variable2", ValueType.INTEGER.getName(), 99, 42, "vi2", 87L)); task.setReceivedVariableMap(receivedVariables); Map variables = new LinkedHashMap<>(); @@ -163,9 +163,9 @@ public void shouldDisplayAttributesIncludingMapsInToString() { + "processDefinitionVersionTag=versionTag, " + "processInstanceId=pii, " + "receivedVariableMap={" - + "rv1=VariableValue [cachedValue=null, processInstanceId=pii, variableName=variable1, typedValueField=" + + "rv1=VariableValue [cachedValue=null, executionId=ei, variableName=variable1, typedValueField=" + "TypedValueField [type=string, value=value1, valueInfo={vi1=42, vi2=vi2}]], " - + "rv2=VariableValue [cachedValue=null, processInstanceId=pii, variableName=variable2, typedValueField=" + + "rv2=VariableValue [cachedValue=null, executionId=ei, variableName=variable2, typedValueField=" + "TypedValueField [type=integer, value=99, valueInfo={vi1=42, vi2=vi2, vi3=87}]]" + "}, " + "retries=34, " @@ -184,10 +184,10 @@ public void shouldDisplayAttributesIncludingMapsInToString() { private static final ValueMappers DEFAULT_MAPPERS = new DefaultValueMappers(Variables.SerializationDataFormats.JSON.getName()); @SuppressWarnings("rawtypes") - private static VariableValue generateVariableValue(String processInstanceId, String variableName, + private static VariableValue generateVariableValue(String executionId, String variableName, final String typeI, final Object valueI, Object... valueInfos) { TypedValueField typedValueField = generateTypedValueField(typeI, valueI, valueInfos); - return new VariableValue(processInstanceId, variableName, typedValueField, DEFAULT_MAPPERS); + return new VariableValue(executionId, variableName, typedValueField, DEFAULT_MAPPERS); } private static TypedValueField generateTypedValueField(final String typeI, final Object valueI, Object... valueInfos) { From 0aeec493ca12bd7fdeadeea9f280178a78fa6ed8 Mon Sep 17 00:00:00 2001 From: venetrius Date: Fri, 20 Sep 2024 14:47:34 +0200 Subject: [PATCH 6/8] Remove redundant ExecutionId on DeferredFileValueImpl --- .../camunda/bpm/client/task/impl/ExternalTaskImpl.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java index 20fe6f4e484..c185e070281 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java @@ -259,10 +259,6 @@ public T getVariable(String variableName) { VariableValue variableValue = receivedVariableMap.get(variableName); if (variableValue != null) { - if(variableValue.getTypedValue() instanceof DeferredFileValueImpl) { - DeferredFileValueImpl deferredFileValue = (DeferredFileValueImpl) variableValue.getTypedValue(); - deferredFileValue.setExecutionId(this.executionId); - } value = (T) variableValue.getValue(); } @@ -301,10 +297,6 @@ public T getVariableTyped(String variableName, boolean de VariableValue variableValue = receivedVariableMap.get(variableName); if (variableValue != null) { typedValue = variableValue.getTypedValue(deserializeObjectValues); - if(typedValue instanceof DeferredFileValueImpl) { - DeferredFileValueImpl deferredFileValue = (DeferredFileValueImpl) typedValue; - deferredFileValue.setExecutionId(this.executionId); - } } return (T) typedValue; From 468cc62a3d9676b66431c0860bd80e96a4ba9770 Mon Sep 17 00:00:00 2001 From: Tassilo Weidner <3015690+tasso94@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:55:10 +0200 Subject: [PATCH 7/8] small cleanup --- .../client/variable/FileSerializationIT.java | 18 +++++++++--------- .../bpm/client/task/impl/ExternalTaskImpl.java | 2 -- .../impl/value/DeferredFileValueImpl.java | 3 +-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index 1117ccb8f59..10953c35ff3 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -214,18 +214,18 @@ public void shouldGetVariableTypedForLocalVariable() { // given ProcessDefinitionDto processDefinitionDto = engineRule.deploy( Bpmn.createExecutableProcess("process") - .startEvent("startEvent") - .serviceTask("serviceTaskFoo") - .camundaExternalTask(EXTERNAL_TASK_TOPIC_FOO) + .startEvent("startEvent") + .serviceTask("serviceTaskFoo") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_FOO) // create the local file variable with the same content but different name - .camundaInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}") - .serviceTask("serviceTaskBar") - .camundaExternalTask(EXTERNAL_TASK_TOPIC_BAR) - .endEvent("endEvent") - .done() + .camundaInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}") + .serviceTask("serviceTaskBar") + .camundaExternalTask(EXTERNAL_TASK_TOPIC_BAR) + .endEvent("endEvent") + .done() ).get(0); - ProcessInstanceDto processInstanceDto = engineRule.startProcessInstance(processDefinitionDto.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE); + engineRule.startProcessInstance(processDefinitionDto.getId(), VARIABLE_NAME_FILE, VARIABLE_VALUE_FILE); // when client.subscribe(EXTERNAL_TASK_TOPIC_FOO) diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java index c185e070281..f1223d45ff2 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/task/impl/ExternalTaskImpl.java @@ -25,8 +25,6 @@ import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.variable.impl.TypedValueField; import org.camunda.bpm.client.variable.impl.VariableValue; -import org.camunda.bpm.client.variable.impl.value.DeferredFileValueImpl; -import org.camunda.bpm.client.variable.value.DeferredFileValue; import org.camunda.bpm.engine.variable.VariableMap; import org.camunda.bpm.engine.variable.Variables; import org.camunda.bpm.engine.variable.value.TypedValue; diff --git a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java index 92fbd851777..bc973e280c0 100644 --- a/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java +++ b/clients/java/client/src/main/java/org/camunda/bpm/client/variable/impl/value/DeferredFileValueImpl.java @@ -37,9 +37,8 @@ public class DeferredFileValueImpl extends FileValueImpl implements DeferredFile protected boolean isLoaded = false; protected String variableName; - protected String processInstanceId; + protected String executionId; protected EngineClient engineClient; - protected String executionId = null; public DeferredFileValueImpl(String filename, EngineClient engineClient) { super(PrimitiveValueType.FILE, filename); From bb4dc29b190eede22dd9d054a559103b69e51b20 Mon Sep 17 00:00:00 2001 From: Tassilo Weidner <3015690+tasso94@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:08:50 +0200 Subject: [PATCH 8/8] Refactor test from white to black box test. --- .../org/camunda/bpm/client/variable/FileSerializationIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java index 10953c35ff3..c36af2da712 100644 --- a/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java +++ b/clients/java/client/src/it/java/org/camunda/bpm/client/variable/FileSerializationIT.java @@ -244,8 +244,8 @@ public void shouldGetVariableTypedForLocalVariable() { assertThat(typedValue.getEncoding()).isNull(); assertThat(typedValue.getMimeType()).isNull(); - DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue; - assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId()); + InputStream value = typedValue.getValue(); + assertThat(IoUtil.inputStreamAsString(value)).isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE)); } @Test