use of org.jboss.resteasy.core.Headers in project openremote by openremote.
the class HTTPProtocol method doLinkAttribute.
@Override
protected void doLinkAttribute(String assetId, Attribute<?> attribute, HTTPAgentLink agentLink) {
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
String method = agentLink.getMethod().map(Enum::name).orElse(DEFAULT_HTTP_METHOD);
String path = agentLink.getPath().orElse(null);
String contentType = agentLink.getContentType().orElse(null);
Map<String, List<String>> headers = agentLink.getHeaders().orElse(null);
Map<String, List<String>> queryParams = agentLink.getQueryParameters().orElse(null);
Integer pollingMillis = agentLink.getPollingMillis().map(millis -> Math.max(millis, MIN_POLLING_MILLIS)).orElse(null);
boolean pagingEnabled = agentLink.getPagingMode().orElse(false);
String pollingAttribute = agentLink.getPollingAttribute().orElse(null);
if (!TextUtil.isNullOrEmpty(pollingAttribute)) {
synchronized (pollingLinkedAttributeMap) {
AttributeRef pollingSourceRef = new AttributeRef(attributeRef.getId(), pollingAttribute);
pollingLinkedAttributeMap.compute(pollingSourceRef, (ref, links) -> {
if (links == null) {
links = new HashSet<>();
}
links.add(attributeRef);
return links;
});
}
}
String body = agentLink.getWriteValue().orElse(null);
if (client == null) {
LOG.warning("Client is undefined: " + this);
return;
}
HttpClientRequest clientRequest = buildClientRequest(path, method, headers != null ? WebTargetBuilder.mapToMultivaluedMap(headers, new MultivaluedHashMap<>()) : null, queryParams != null ? WebTargetBuilder.mapToMultivaluedMap(queryParams, new MultivaluedHashMap<>()) : null, pagingEnabled, contentType);
LOG.fine("Creating HTTP request for attributeRef '" + clientRequest + "': " + attributeRef);
requestMap.put(attributeRef, clientRequest);
Optional.ofNullable(pollingMillis).ifPresent(seconds -> pollingMap.put(attributeRef, schedulePollingRequest(attributeRef, agentLink, clientRequest, body, seconds)));
}
use of org.jboss.resteasy.core.Headers in project brave by openzipkin.
the class ClientRequestContextWrapperTest method putHeader.
@Test
public void putHeader() {
MultivaluedMap<String, Object> headers = new Headers<>();
when(request.getHeaders()).thenReturn(headers);
new ClientRequestContextWrapper(request).header("name", "value");
assertThat(headers).containsExactly(entry("name", Collections.singletonList("value")));
}
Aggregations