Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing only SUPPORT-23079 #4527

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -146,9 +145,9 @@ public void extendLock(String taskId, long newDuration) {
String resourceUrl = baseUrl + resourcePath;
engineInteraction.postRequest(resourceUrl, payload, Void.class);
}

// /process-instance/{id}/variables/{name}/data
public byte[] getLocalBinaryVariable(String variableName, String processInstanceId) {
String resourcePath = baseUrl + GET_LOCAL_BINARY_VARIABLE
String resourcePath = baseUrl + GET_BINARY_VARIABLE
.replace(ID_PATH_PARAM, processInstanceId)
.replace(NAME_PATH_PARAM, variableName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.camunda.bpm.engine.variable.value.TypedValue;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.camunda.bpm.engine.variable.value.builder.Executionaware;

/**
* @author Tassilo Weidner
Expand Down Expand Up @@ -257,6 +258,9 @@ public <T> T getVariable(String variableName) {

VariableValue variableValue = receivedVariableMap.get(variableName);
if (variableValue != null) {
if(variableValue.getTypedValue() instanceof Executionaware) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Instead of introducing a new interface ExecutionAware, can we just check if instanceof DeferredFileValue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks!
Incorporated into #4594

((Executionaware) variableValue.getTypedValue()).setExecutionId(executionId);
}
value = (T) variableValue.getValue();
}

Expand All @@ -274,6 +278,10 @@ public VariableMap getAllVariablesTyped(boolean deserializeObjectValues) {

receivedVariableMap.forEach((variableName, variableValue) -> {
TypedValue typedValue = getVariableTyped(variableName, deserializeObjectValues);
if(typedValue instanceof Executionaware) {
Executionaware executionaware = (Executionaware) typedValue;
executionaware.setExecutionId(this.executionId);
}
variables.putValueTyped(variableName, typedValue);
});

Expand All @@ -295,6 +303,10 @@ public <T extends TypedValue> T getVariableTyped(String variableName, boolean de
VariableValue variableValue = receivedVariableMap.get(variableName);
if (variableValue != null) {
typedValue = variableValue.getTypedValue(deserializeObjectValues);
if(typedValue instanceof Executionaware) {
Executionaware executionaware = (Executionaware) typedValue;
executionaware.setExecutionId(this.executionId);
}
}

return (T) typedValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class DeferredFileValueImpl extends FileValueImpl implements DeferredFile
protected String variableName;
protected String processInstanceId;
protected EngineClient engineClient;
protected String executionId = null;

public DeferredFileValueImpl(String filename, EngineClient engineClient) {
super(PrimitiveValueType.FILE, filename);
Expand All @@ -47,7 +48,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 Down Expand Up @@ -84,4 +85,14 @@ public String toString() {
return "DeferredFileValueImpl [mimeType=" + mimeType + ", filename=" + filename + ", type=" + type + ", isTransient=" + isTransient + ", isLoaded=" + isLoaded + "]";
}

@Override
public void setExecutionId(String executionId){
this.executionId = executionId;
};

@Override
public String getExecutionId() {
return executionId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.camunda.bpm.client.variable.value;

import org.camunda.bpm.engine.variable.value.FileValue;
import org.camunda.bpm.engine.variable.value.builder.Executionaware;

/**
* File value is not available unless it is loaded actively
Expand All @@ -26,8 +27,7 @@
*
* @author Tassilo Weidner
*/
public interface DeferredFileValue extends FileValue {

public interface DeferredFileValue extends FileValue, Executionaware {
/**
* Indicates whether the file value has been loaded
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.engine.variable.value.builder;

public interface Executionaware {
public String getExecutionId();
public void setExecutionId(String executionId);
}