Skip to content
Merged
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 @@ -79,6 +79,7 @@ public class DefaultDispatcher<ID> implements Dispatcher {
public static final String RECORD_COUNT_KEY = "__recordCount";
public static final String COUNT_QUERY_RECORD_KEY = "__countRecords";
public static final String LOCALE_KEY = "__locale";
public static final String REQUEST_PARAMETERS_KEY = "__requestParameters";

public static final String MASK = "__mask";
public static final String SDK = "sdk";
Expand Down Expand Up @@ -633,6 +634,11 @@ public Map<String, Object> callOperation(final String operationFullyQualifiedNam
}
context.putIfAbsent(LOCALE_KEY, locale);

if (exchange.containsKey(REQUEST_PARAMETERS_KEY)) {
Map<String, String> requestParameters = (Map<String, String>) exchange.get(REQUEST_PARAMETERS_KEY);
context.putIfAbsent(REQUEST_PARAMETERS_KEY, requestParameters);
}

final EOperation operation = operationCache.get(operationFullyQualifiedName)
.orElseThrow(() -> new UnsupportedOperationException("Operation not found: " + operationFullyQualifiedName));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package hu.blackbelt.judo.runtime.core.dispatcher.environment;

/*-
* #%L
* JUDO Runtime Core :: Parent
* %%
* Copyright (C) 2018 - 2022 BlackBelt Technology
* %%
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License, v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is
* available at https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
* #L%
*/

import hu.blackbelt.judo.dispatcher.api.Context;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

import java.util.Map;
import java.util.function.Function;

@NoArgsConstructor
@RequiredArgsConstructor
public class RequestParametersVariableProvider<T> implements Function<String, T> {

public static final String REQUEST_PARAMETERS_KEY = "__requestParameters";

@NonNull
@Setter
Context context;

@Override
public T apply(final String parameterName) {
Object value = null;
Map map = context.getAs(Map.class, REQUEST_PARAMETERS_KEY);
if (map != null && map.containsKey(parameterName)) {
value = (String) context.getAs(Map.class, REQUEST_PARAMETERS_KEY).get(parameterName);
}
return (T) value;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public VariableResolver get() {
variableResolver.registerSupplier("SYSTEM", "current_time", new CurrentTimeProvider(), false);
variableResolver.registerFunction("ENVIRONMENT", new EnvironmentVariableProvider(), true);
variableResolver.registerFunction("SEQUENCE", new SequenceProvider(sequence), false);
variableResolver.registerFunction("REQUEST", new RequestParametersVariableProvider(context), false);
return variableResolver;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ public VariableResolver getVariableResolver() {
variableResolver.registerSupplier("SYSTEM", "current_time", new CurrentTimeProvider(), false);
variableResolver.registerFunction("ENVIRONMENT", new EnvironmentVariableProvider(), true);
variableResolver.registerFunction("SEQUENCE", new SequenceProvider(sequence), false);
variableResolver.registerFunction("REQUEST", new RequestParametersVariableProvider(context), false);
return variableResolver;
}

Expand Down
Loading