Search in sources :

Example 81 with MetadataElement

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()));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InputStreamWithEncoding(com.adaptris.core.common.InputStreamWithEncoding) MetadataElement(com.adaptris.core.MetadataElement)

Example 82 with MetadataElement

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);
}
Also used : Matcher(java.util.regex.Matcher) MetadataElement(com.adaptris.core.MetadataElement) InputFieldHint(com.adaptris.annotation.InputFieldHint) HashSet(java.util.HashSet)

Example 83 with MetadataElement

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;
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MetadataElement(com.adaptris.core.MetadataElement) MleMarker(com.adaptris.core.MleMarker)

Example 84 with MetadataElement

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;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Example 85 with MetadataElement

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;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Aggregations

MetadataElement (com.adaptris.core.MetadataElement)151 Test (org.junit.Test)101 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)94 XPath (com.adaptris.util.text.xml.XPath)23 Document (org.w3c.dom.Document)19 MetadataCollection (com.adaptris.core.MetadataCollection)18 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)18 ServiceException (com.adaptris.core.ServiceException)17 ServiceList (com.adaptris.core.ServiceList)14 Cache (com.adaptris.core.cache.Cache)14 MetadataCacheValueTranslator (com.adaptris.core.services.cache.translators.MetadataCacheValueTranslator)12 ArrayList (java.util.ArrayList)11 CoreException (com.adaptris.core.CoreException)10 Service (com.adaptris.core.Service)10 HashSet (java.util.HashSet)9 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)8 StandaloneProducer (com.adaptris.core.StandaloneProducer)7 StaticCacheValueTranslator (com.adaptris.core.services.cache.translators.StaticCacheValueTranslator)7 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)6 Session (javax.jms.Session)6