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

list iterator parameters fix #1365

Merged
merged 2 commits into from
Aug 2, 2022
Merged
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 @@ -38,6 +38,8 @@ public class CloudSlangJavaExecutionParameterProvider implements JavaExecutionPa
private static final String SERIALIZABLE_SESSION_OBJECT = SerializableSessionObject.class.getCanonicalName();
private static final String STEP_SERIALIZABLE_SESSION_OBJECT =
StepSerializableSessionObject.class.getCanonicalName();
private static final String LIST_ITERATOR_ACTION = "io.cloudslang.content.actions.ListIteratorAction";

private final Map<String, SerializableSessionObject> serializableSessionData;
private final Map<String, Serializable> currentContext;
private final Map<String, Object> globalSessionObjectData;
Expand Down Expand Up @@ -69,18 +71,19 @@ public Object[] getExecutionParameters(Method executionMethod) {
for (Annotation annotation : annotations) {
String parameterName = getValueIfParamAnnotation(annotation);
if (parameterName != null) {
final String methodName = executionMethod.getDeclaringClass().getName();
String paramClassName = parameterTypes[index].getCanonicalName();
if (paramClassName.equals(GLOBAL_SESSION_OBJECT_CLASS_NAME)) {
handleSessionContextArgument(globalSessionObjectData, GLOBAL_SESSION_OBJECT_CLASS_NAME,
args, parameterName,
args, parameterName, methodName,
annotation.getClass().getClassLoader());
} else if (paramClassName.equals(SESSION_OBJECT_CLASS_NAME)) {
handleSessionContextArgument(sessionObjectData, SESSION_OBJECT_CLASS_NAME,
args, parameterName + "_" + (depth - 1),
args, parameterName + "_" + (depth - 1), methodName,
annotation.getClass().getClassLoader());
} else if (paramClassName.equals(SERIALIZABLE_SESSION_OBJECT)) {
handleSessionContextArgument(serializableSessionData, SERIALIZABLE_SESSION_OBJECT,
args, parameterName,
args, parameterName, methodName,
annotation.getClass().getClassLoader());
} else if (paramClassName.equals(STEP_SERIALIZABLE_SESSION_OBJECT)) {
handleStepSessionContextArgument(serializableSessionData, args, parameterName,
Expand Down Expand Up @@ -146,9 +149,9 @@ private void handleStepSessionContextArgument(Map sessionData, List<Object> args
}

private void handleSessionContextArgument(Map sessionData, String objectClassName, List<Object> args,
String parameterName, ClassLoader classLoader) {
// cloudslang list iterator fix
final String parameter = StringUtils.startsWith(this.nodeNameWithDepth, "list_iterator") ?
String parameterName, String methodName, ClassLoader classLoader) {
// cloudSlang list iterator fix
final String parameter = StringUtils.equals(methodName, LIST_ITERATOR_ACTION) ?
this.nodeNameWithDepth : parameterName;

Object sessionContextObject = sessionData.get(parameter);
Expand Down