use of jakarta.ws.rs.core.MultivaluedMap in project incubator-hugegraph by apache.
the class CustomizedCrosspointsTraverser method crosspointsPaths.
public CrosspointsPaths crosspointsPaths(Iterator<Vertex> vertices, List<PathPattern> pathPatterns, long capacity, long limit) {
E.checkArgument(vertices.hasNext(), "The source vertices can't be empty");
E.checkArgument(!pathPatterns.isEmpty(), "The steps pattern can't be empty");
checkCapacity(capacity);
checkLimit(limit);
MultivaluedMap<Id, Node> initialSources = newMultivalueMap();
List<HugeVertex> verticesList = newList();
while (vertices.hasNext()) {
HugeVertex vertex = (HugeVertex) vertices.next();
verticesList.add(vertex);
Node node = new Node(vertex.id(), null);
initialSources.add(vertex.id(), node);
}
List<Path> paths = newList();
for (PathPattern pathPattern : pathPatterns) {
MultivaluedMap<Id, Node> sources = initialSources;
int stepNum = pathPattern.size();
long access = 0;
MultivaluedMap<Id, Node> newVertices = null;
for (Step step : pathPattern.steps()) {
stepNum--;
newVertices = newMultivalueMap();
Iterator<Edge> edges;
// Traversal vertices of previous level
for (Map.Entry<Id, List<Node>> entry : sources.entrySet()) {
List<Node> adjacency = newList();
edges = this.edgesOfVertex(entry.getKey(), step.edgeStep);
while (edges.hasNext()) {
HugeEdge edge = (HugeEdge) edges.next();
Id target = edge.id().otherVertexId();
for (Node n : entry.getValue()) {
// If have loop, skip target
if (n.contains(target)) {
continue;
}
Node newNode = new Node(target, n);
adjacency.add(newNode);
checkCapacity(capacity, ++access, "customized crosspoints");
}
}
// Add current node's adjacent nodes
for (Node node : adjacency) {
newVertices.add(node.id(), node);
}
}
// Re-init sources
sources = newVertices;
}
assert stepNum == 0;
for (List<Node> nodes : newVertices.values()) {
for (Node n : nodes) {
paths.add(new Path(n.path()));
}
}
}
return intersectionPaths(verticesList, paths, limit);
}
use of jakarta.ws.rs.core.MultivaluedMap in project helidon by oracle.
the class ClientTracingFilter method filter.
@Override
public void filter(ClientRequestContext requestContext) {
// if we run within Jersey server, the tracing context will be filled in by TracingHelperFilter
// if not, it will be empty
Optional<TracingContext> tracingContext = Contexts.context().flatMap(ctx -> ctx.get(TracingContext.class));
// maybe we are disabled
if (tracingDisabled(requestContext, tracingContext)) {
return;
}
// also we may configure tracing through other means
SpanTracingConfig spanConfig = TracingConfigUtil.spanConfig(JAX_RS_TRACING_COMPONENT, SPAN_OPERATION_NAME);
if (!spanConfig.enabled()) {
return;
}
Tracer tracer = findTracer(requestContext, tracingContext);
Optional<SpanContext> parentSpan = findParentSpan(tracer, requestContext, tracingContext);
Map<String, List<String>> inboundHeaders = findInboundHeaders(tracingContext);
String spanName = findSpanName(requestContext, spanConfig);
// create a new span for this jersey client request
Span currentSpan = createSpan(requestContext, tracer, parentSpan, spanName);
// register it so we can close the span on response
requestContext.setProperty(SPAN_PROPERTY_NAME, currentSpan);
// and also register it with Context, so we can close the span in case of an exception that does not hit the
// response filter
Contexts.context().ifPresent(ctx -> ctx.register(SPAN_PROPERTY_NAME, currentSpan));
Contexts.context().ifPresent(ctx -> ctx.register(TracingConfigUtil.OUTBOUND_SPAN_QUALIFIER, currentSpan.context()));
// propagate tracing headers, so remote service can use currentSpan as its parent
Map<String, List<String>> tracingHeaders = tracingHeaders(tracer, currentSpan);
Map<String, List<String>> outboundHeaders = tracerProvider.map(provider -> provider.updateOutboundHeaders(currentSpan, tracer, parentSpan.orElse(null), tracingHeaders, inboundHeaders)).orElse(tracingHeaders);
// add headers from inbound request that were not added by tracing provider and are needed
// by supported proxies or routing services
outboundHeaders = updateOutboundHeaders(outboundHeaders, inboundHeaders);
// update the headers to be correctly propagated to remote service
MultivaluedMap<String, Object> headers = requestContext.getHeaders();
outboundHeaders.forEach((key, value) -> headers.put(key, new ArrayList<>(value)));
}
use of jakarta.ws.rs.core.MultivaluedMap in project minijax by minijax.
the class HttpHeadersTest method testMultiple.
@Test
void testMultiple() throws Exception {
final Map<String, List<String>> headerMap = new HashMap<>();
headerMap.computeIfAbsent("X-Foo", k -> new ArrayList<>()).add("bar");
headerMap.computeIfAbsent("X-Foo", k -> new ArrayList<>()).add("baz");
final WebSocketHttpExchange exchange = mock(WebSocketHttpExchange.class);
when(exchange.getRequestHeaders()).thenReturn(headerMap);
final MinijaxUndertowWebSocketHttpHeaders httpHeaders = new MinijaxUndertowWebSocketHttpHeaders(exchange);
assertEquals(Arrays.asList("bar", "baz"), httpHeaders.getRequestHeader("X-Foo"));
final MultivaluedMap<String, String> multiMap = httpHeaders.getRequestHeaders();
assertNotNull(multiMap);
assertEquals(multiMap, httpHeaders.getRequestHeaders());
}
use of jakarta.ws.rs.core.MultivaluedMap in project tomee by apache.
the class XSLTJaxbProvider method createTemplates.
protected Templates createTemplates(Templates templates, Map<String, Object> configuredParams, Map<String, String> outProps) {
if (templates == null) {
if (supportJaxbOnly) {
return null;
}
LOG.severe("No template is available");
throw ExceptionUtils.toInternalServerErrorException(null, null);
}
TemplatesImpl templ = new TemplatesImpl(templates, uriResolver);
MessageContext mc = getContext();
if (mc != null) {
UriInfo ui = mc.getUriInfo();
MultivaluedMap<String, String> params = ui.getPathParameters();
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
String value = entry.getValue().get(0);
int ind = value.indexOf(';');
if (ind > 0) {
value = value.substring(0, ind);
}
templ.setTransformerParameter(entry.getKey(), value);
}
List<PathSegment> segments = ui.getPathSegments();
if (!segments.isEmpty()) {
setTransformParameters(templ, segments.get(segments.size() - 1).getMatrixParameters());
}
setTransformParameters(templ, ui.getQueryParameters());
templ.setTransformerParameter(ABSOLUTE_PATH_PARAMETER, ui.getAbsolutePath().toString());
templ.setTransformerParameter(RELATIVE_PATH_PARAMETER, ui.getPath());
templ.setTransformerParameter(BASE_PATH_PARAMETER, ui.getBaseUri().toString());
if (configuredParams != null) {
for (Map.Entry<String, Object> entry : configuredParams.entrySet()) {
templ.setTransformerParameter(entry.getKey(), entry.getValue());
}
}
}
if (outProps != null) {
templ.setOutProperties(outProps);
}
return templ;
}
use of jakarta.ws.rs.core.MultivaluedMap in project tomee by apache.
the class InjectionUtils method injectIntoMap.
private static Object injectIntoMap(Type genericType, Annotation[] paramAnns, MultivaluedMap<String, String> processedValues, boolean decoded, ParameterType pathParam, Message message) {
ParameterizedType paramType = (ParameterizedType) genericType;
Class<?> keyType = (Class<?>) paramType.getActualTypeArguments()[0];
Type secondType = InjectionUtils.getType(paramType.getActualTypeArguments(), 1);
if (secondType instanceof ParameterizedType) {
MultivaluedMap<Object, Object> theValues = new MetadataMap<>();
ParameterizedType valueParamType = (ParameterizedType) secondType;
Class<?> valueType = (Class<?>) InjectionUtils.getType(valueParamType.getActualTypeArguments(), 0);
for (Map.Entry<String, List<String>> processedValuesEntry : processedValues.entrySet()) {
List<String> valuesList = processedValuesEntry.getValue();
for (String value : valuesList) {
Object o = InjectionUtils.handleParameter(value, decoded, valueType, valueType, paramAnns, pathParam, message);
theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
}
}
return theValues;
}
Map<Object, Object> theValues = new HashMap<>();
Class<?> valueType = (Class<?>) InjectionUtils.getType(paramType.getActualTypeArguments(), 1);
for (Map.Entry<String, List<String>> processedValuesEntry : processedValues.entrySet()) {
List<String> valuesList = processedValuesEntry.getValue();
for (String value : valuesList) {
Object o = InjectionUtils.handleParameter(value, decoded, valueType, valueType, paramAnns, pathParam, message);
theValues.put(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
}
}
return theValues;
}
Aggregations