Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into sonar-S6201
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirk Olmes committed Nov 8, 2024
2 parents 2bf4232 + f452b5c commit 6b26fee
Show file tree
Hide file tree
Showing 196 changed files with 4,755 additions and 398 deletions.
1 change: 0 additions & 1 deletion .mvn/maven.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
--errors
--show-version
--no-transfer-progress
-DinstallAtEnd=true
-DdeployAtEnd=true
-Duser.timezone=Europe/Berlin
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ An entire repository can be built by running `mvn clean install` in the root dir
This will build all sub modules and execute unit tests.
Furthermore, you can restrict the build to just the module you are changing by running the same command in the corresponding directory.
Check the repository's or module's README for additional module-specific instructions.
The `webapps` and `swagger-ui` modules requires NodeJS.
You can exclude building them by running `mvn clean install -pl '!webapps,!webapps/assembly,!webapps/assembly-jakarta,!org.operaton.bpm.run:operaton-bpm-run-modules-swaggerui'`.
The `webapps` module requires NodeJS.
You can exclude building them by running `mvn clean install -pl '!webapps,!webapps/assembly,!webapps/assembly-jakarta'`.

Integration tests (e.g. tests that run in an actual application server) are usually not part of the default Maven profiles. If you think they are relevant to your contribution, please ask us in the ticket, on the forum or in your pull request for how to run them. Smaller contributions usually do not need this.

Expand Down
5 changes: 5 additions & 0 deletions bom/operaton-only-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@
<artifactId>operaton-bpm-spring-boot-starter-webapp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.operaton.bpm.springboot</groupId>
<artifactId>operaton-bpm-spring-boot-starter-security</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.operaton.bpm.springboot</groupId>
<artifactId>operaton-bpm-spring-boot-starter-webapp-ee</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions clients/java/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</parent>

<properties>
<version.httpclient>5.3</version.httpclient>
<engine.runtime>${project.build.directory}/operaton-tomcat</engine.runtime>
<tomcat.runtime>${engine.runtime}/server/apache-tomcat-${version.tomcat}</tomcat.runtime>
<http.port>${tomcat.connector.http.port}</http.port>
Expand Down Expand Up @@ -66,7 +65,7 @@
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${version.httpclient}</version>
<version>${version.httpclient5}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
import org.operaton.bpm.client.util.RecordingExternalTaskHandler;
import org.operaton.bpm.client.util.RecordingInvocationHandler;
import org.operaton.bpm.client.util.RecordingInvocationHandler.RecordedInvocation;
import org.operaton.bpm.client.variable.impl.value.DeferredFileValueImpl;
import org.operaton.bpm.client.variable.value.DeferredFileValue;
import org.operaton.bpm.engine.variable.Variables;
import org.operaton.bpm.engine.variable.value.FileValue;
import org.operaton.bpm.engine.variable.value.TypedValue;
import org.operaton.bpm.model.bpmn.Bpmn;
import org.operaton.bpm.model.bpmn.BpmnModelInstance;
import org.operaton.commons.utils.IoUtil;

Expand Down Expand Up @@ -64,6 +66,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_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";

Expand Down Expand Up @@ -114,6 +118,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")
.operatonExternalTask(EXTERNAL_TASK_TOPIC_FOO)
// create the local file variable with the same content but different name
.operatonInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}")
.serviceTask("serviceTaskBar")
.operatonExternalTask(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_NAME_FILE)))
.isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE));
}

@Test
public void shouldGetAll() {
// given
Expand Down Expand Up @@ -142,7 +181,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)
Expand All @@ -160,6 +201,48 @@ public void shouldGetTyped_Deferred() {
assertThat(typedValue.isLoaded()).isFalse();
assertThat(typedValue.getEncoding()).isNull();
assertThat(typedValue.getMimeType()).isNull();

DeferredFileValueImpl typedValueImpl = (DeferredFileValueImpl) typedValue;
assertThat(typedValueImpl.getExecutionId()).isEqualTo(task.getExecutionId());
}

@Test
public void shouldGetVariableTypedForLocalVariable() {
// given
ProcessDefinitionDto processDefinitionDto = engineRule.deploy(
Bpmn.createExecutableProcess("process")
.startEvent("startEvent")
.serviceTask("serviceTaskFoo")
.operatonExternalTask(EXTERNAL_TASK_TOPIC_FOO)
// create the local file variable with the same content but different name
.operatonInputParameter(LOCAL_VARIABLE_NAME_FILE, "${execution.getVariableTyped('fileVariable')}")
.serviceTask("serviceTaskBar")
.operatonExternalTask(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
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();

InputStream value = typedValue.getValue();
assertThat(IoUtil.inputStreamAsString(value)).isEqualTo(new String(VARIABLE_VALUE_FILE_VALUE));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ public class EngineClient {
public static final String FAILURE_RESOURCE_PATH = ID_RESOURCE_PATH + "/failure";
public static final String BPMN_ERROR_RESOURCE_PATH = ID_RESOURCE_PATH + "/bpmnError";
public static final String NAME_PATH_PARAM = "{name}";
public static final String EXECUTION_RESOURCE_PATH = "/execution";
public static final String EXECUTION_ID_RESOURCE_PATH = EXECUTION_RESOURCE_PATH + "/" + ID_PATH_PARAM;
public static final String GET_LOCAL_VARIABLE = EXECUTION_ID_RESOURCE_PATH + "/localVariables/" + NAME_PATH_PARAM;
public static final String GET_LOCAL_BINARY_VARIABLE = GET_LOCAL_VARIABLE + "/data";

public static final String PROCESS_INSTANCE_RESOURCE_PATH = "/process-instance";
public static final String PROCESS_INSTANCE_ID_RESOURCE_PATH = PROCESS_INSTANCE_RESOURCE_PATH + "/" + ID_PATH_PARAM;
public static final String GET_BINARY_VARIABLE =
PROCESS_INSTANCE_ID_RESOURCE_PATH + "/variables/" + NAME_PATH_PARAM + "/data";
protected String baseUrl;
protected String workerId;
protected int maxTasks;
Expand Down Expand Up @@ -147,9 +146,9 @@ public void extendLock(String taskId, long newDuration) {
engineInteraction.postRequest(resourceUrl, payload, Void.class);
}

public byte[] getLocalBinaryVariable(String variableName, String processInstanceId) {
String resourcePath = baseUrl + GET_LOCAL_BINARY_VARIABLE
.replace(ID_PATH_PARAM, processInstanceId)
public byte[] getLocalBinaryVariable(String variableName, String executionId) {
String resourcePath = baseUrl + GET_BINARY_VARIABLE
.replace(ID_PATH_PARAM, executionId)
.replace(NAME_PATH_PARAM, variableName);

return engineInteraction.getRequest(resourcePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Map<String, TypedValueField> serializeVariables(Map<String, Object> varia

@SuppressWarnings("rawtypes")
public Map<String, VariableValue> wrapVariables(ExternalTask externalTask, Map<String, TypedValueField> variables) {
String processInstanceId = externalTask.getProcessInstanceId();
String executionId = externalTask.getExecutionId();

Map<String, VariableValue> result = new HashMap<>();

Expand All @@ -80,7 +80,7 @@ public Map<String, VariableValue> wrapVariables(ExternalTask externalTask, Map<S
typeName = Character.toLowerCase(typeName.charAt(0)) + typeName.substring(1);
variableValue.setType(typeName);

VariableValue value = new VariableValue(processInstanceId, variableName, variableValue, serializers);
VariableValue value = new VariableValue(executionId, variableName, variableValue, serializers);
result.put(variableName, value);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

public class VariableValue<T extends TypedValue> {

protected String processInstanceId;
protected String executionId;
protected String variableName;
protected TypedValueField typedValueField;
protected ValueMappers mappers;

protected ValueMapper<T> 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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -83,7 +83,7 @@ public ValueMapper<T> getSerializer() {
public String toString() {
return "VariableValue ["
+ "cachedValue=" + cachedValue + ", "
+ "processInstanceId=" + processInstanceId + ", "
+ "executionId=" + executionId + ", "
+ "variableName=" + variableName + ", "
+ "typedValueField=" + typedValueField + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DeferredFileValueImpl extends FileValueImpl implements DeferredFile
protected boolean isLoaded = false;

protected String variableName;
protected String processInstanceId;
protected String executionId;
protected EngineClient engineClient;

public DeferredFileValueImpl(String filename, EngineClient engineClient) {
Expand All @@ -47,7 +47,7 @@ public DeferredFileValueImpl(String filename, EngineClient engineClient) {

protected void load() {
try {
byte[] bytes = engineClient.getLocalBinaryVariable(variableName, processInstanceId);
byte[] bytes = engineClient.getLocalBinaryVariable(variableName, executionId);
setValue(bytes);

this.isLoaded = true;
Expand All @@ -71,17 +71,22 @@ public InputStream getValue() {
return super.getValue();
}

public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}

public void setVariableName(String variableName) {
this.variableName = variableName;
}

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 + ", isTransient=" + isTransient + ", isLoaded=" + isLoaded + "]";
return "DeferredFileValueImpl [mimeType=" + mimeType + ", filename=" + filename + ", type=" + type + ", "
+ "isTransient=" + isTransient + ", isLoaded=" + isLoaded + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ void shouldDisplayAttributesIncludingMapsInToString() {
task.setWorkerId("wi");

Map<String, VariableValue> 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<String, TypedValueField> variables = new LinkedHashMap<>();
Expand All @@ -163,9 +163,9 @@ 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, "
Expand All @@ -184,10 +184,10 @@ 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) {
Expand Down
2 changes: 1 addition & 1 deletion database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<version.mariadb-v1>1.1.8</version.mariadb-v1>
<version.mysql>8.3.0</version.mysql>
<version.sqlserver>8.4.1.jre8</version.sqlserver>
<version.db2-11.5>11.5.0.0</version.db2-11.5>
<version.db2-11.5>11.5.9.0</version.db2-11.5>
<version.db2>${version.db2-11.5}</version.db2>
<version.postgresql>42.5.5</version.postgresql>
<version.liquibase>4.8.0</version.liquibase>
Expand Down
11 changes: 11 additions & 0 deletions distro/run/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
</includes>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<outputDirectory>internal/oauth2/</outputDirectory>
<includes>
<include>org.operaton.bpm.run:operaton-bpm-run-modules-oauth2</include>
</includes>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<dependencySet>
<outputDirectory>internal/example/</outputDirectory>
<includes>
Expand Down Expand Up @@ -122,6 +129,10 @@
<directory>../modules/rest/target/dependency/</directory>
<outputDirectory>internal/rest/</outputDirectory>
</fileSet>
<fileSet>
<directory>../modules/oauth2/target/dependency/</directory>
<outputDirectory>internal/oauth2/</outputDirectory>
</fileSet>
<!-- create empty resource folder -->
<fileSet>
<directory>resources/dummyResource</directory>
Expand Down
15 changes: 15 additions & 0 deletions distro/run/assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
</exclusions>
</dependency>

<!-- make sure this runs after the oauth2 module -->
<dependency>
<groupId>org.operaton.bpm.run</groupId>
<artifactId>operaton-bpm-run-modules-oauth2</artifactId>
<version>${project.version}</version>
<type>jar</type>
<exclusions>
<!-- we don't need any transitive dependencies -->
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.operaton.bpm.run</groupId>
<artifactId>operaton-bpm-run-modules-example-invoice</artifactId>
Expand Down
Loading

0 comments on commit 6b26fee

Please sign in to comment.