use of org.apache.servicecomb.common.rest.definition.RestParam in project incubator-servicecomb-java-chassis by apache.
the class URLPathBuilder method initQueryWriterList.
private void initQueryWriterList(Map<String, RestParam> paramMap) {
for (RestParam param : paramMap.values()) {
if (!QueryProcessorCreator.PARAMTYPE.equals(param.getParamProcessor().getProcessorType())) {
continue;
}
char prefix = '&';
if (queryParamWriterList.isEmpty()) {
prefix = '?';
}
UrlParamWriter dynamicWriter = new QueryVarParamWriter(prefix, param);
queryParamWriterList.add(dynamicWriter);
}
}
use of org.apache.servicecomb.common.rest.definition.RestParam in project incubator-servicecomb-java-chassis by apache.
the class InvocationToHttpServletRequest method getParameterMap.
@Override
public Map<String, String[]> getParameterMap() {
Map<String, String[]> paramMap = new HashMap<>();
for (RestParam param : swaggerOperation.getParamList()) {
String[] value = param.getValueAsStrings(args);
paramMap.put(param.getParamName(), value);
}
return paramMap;
}
use of org.apache.servicecomb.common.rest.definition.RestParam in project incubator-servicecomb-java-chassis by apache.
the class RestCodec method restToArgs.
public static Object[] restToArgs(HttpServletRequest request, RestOperationMeta restOperation) throws InvocationException {
List<RestParam> paramList = restOperation.getParamList();
try {
Object[] paramValues = new Object[paramList.size()];
for (int idx = 0; idx < paramList.size(); idx++) {
RestParam param = paramList.get(idx);
paramValues[idx] = param.getParamProcessor().getValue(request);
}
return paramValues;
} catch (Exception e) {
LOG.error("Parameter is not valid for operation {}. ", restOperation.getOperationMeta().getMicroserviceQualifiedName(), e);
throw ExceptionFactory.convertProducerException(e, "Parameter is not valid.");
}
}
Aggregations