use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class StandardHttpProducer method handleResponse.
private void handleResponse(HttpURLConnection http, AdaptrisMessage reply) throws IOException, InterlokException {
int responseCode = http.getResponseCode();
logHeaders("Response Information", http.getResponseMessage(), http.getHeaderFields().entrySet());
log.trace("Content-Length is " + http.getContentLength());
if (responseCode < 200 || responseCode > 299) {
if (ignoreServerResponseCode()) {
log.trace("Ignoring HTTP Reponse code {}", responseCode);
responseBody().insert(new InputStreamWithEncoding(http.getErrorStream(), getContentEncoding(http)), reply);
} else {
fail(responseCode, new InputStreamWithEncoding(http.getErrorStream(), getContentEncoding(http)));
}
} else {
if (getEncoder() != null) {
AdaptrisMessage decodedReply = getEncoder().readMessage(http);
AdaptrisMessageImp.copyPayload(decodedReply, reply);
reply.getObjectHeaders().putAll(decodedReply.getObjectHeaders());
reply.setMetadata(decodedReply.getMetadata());
} else {
responseBody().insert(new InputStreamWithEncoding(http.getInputStream(), getContentEncoding(http)), reply);
}
}
getResponseHeaderHandler().handle(http, reply);
reply.addMetadata(new MetadataElement(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE, String.valueOf(http.getResponseCode())));
reply.addObjectHeader(CoreConstants.HTTP_PRODUCER_RESPONSE_CODE, Integer.valueOf(http.getResponseCode()));
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class JettyRouteCondition method build.
public JettyRoute build(String method, String uri) throws CoreException {
int expected = (isBlank(getMethod()) ? 0 : 1) + 1;
int rc = 0;
Set<MetadataElement> matchedMetadata = new HashSet<>();
if (!isBlank(getMethod())) {
rc += getMethod().equalsIgnoreCase(method) ? 1 : 0;
}
Matcher matcher = _urlPattern.matcher(uri);
if (matcher.matches()) {
rc++;
matchedMetadata = MetadataHelper.metadataFromMatchGroups(matcher, metadataKeys());
}
return new JettyRoute(rc == expected, matchedMetadata);
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class MockNonStandardRequestReplyProducer method request.
@Override
public AdaptrisMessage request(AdaptrisMessage msg) throws ProduceException {
Args.notNull(msg, "message");
AdaptrisMessage reply = defaultIfNull(getMessageFactory()).newMessage();
reply.setUniqueId(msg.getUniqueId());
log.trace("Produced [" + msg.getUniqueId() + "]");
producedMessages.add(msg);
reply.setPayload(msg.getPayload());
reply.addMetadata(new MetadataElement(REPLY_METADATA_KEY, REPLY_METADATA_VALUE));
reply.getMessageLifecycleEvent().addMleMarker(new MleMarker("DummyMarker", true, 99, uniqueIdGenerator.create(new Object())));
return reply;
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class ExcludeJmsHeaders method removeJmsHdrs.
private MetadataCollection removeJmsHdrs(MetadataCollection metadataCollection) {
MetadataCollection toBeRemoved = new MetadataCollection();
for (MetadataElement element : metadataCollection) {
if (jmsPattern.matcher(element.getKey()).find()) {
toBeRemoved.add(element);
}
}
metadataCollection.removeAll(toBeRemoved);
return metadataCollection;
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class FixedValuesMetadataFilter method filter.
@Override
public MetadataCollection filter(MetadataCollection original) {
MetadataCollection result = new MetadataCollection();
getMetadata().forEach((e) -> {
result.add(new MetadataElement(e.getKey(), e.getValue()));
});
return result;
}
Aggregations