Search in sources :

Example 26 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class RegexMetadataFilter method exclude.

/**
 * Take a collection of metadata items and filter that collection based on the list of excluding
 * regular expression patterns.
 *
 * @param metadataCollection the <code>MetadataCollection</code>
 * @return A new modified collection.
 */
private MetadataCollection exclude(MetadataCollection metadataCollection) {
    if (getExcludePatterns().size() == 0) {
        return metadataCollection;
    }
    initialisePatterns();
    MetadataCollection toBeRemoved = new MetadataCollection();
    toBeRemoved.addAll(metadataCollection.stream().filter(e -> matches(e, patternExcludes)).collect(Collectors.toList()));
    metadataCollection.removeAll(toBeRemoved);
    return metadataCollection;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection)

Example 27 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class DiscardValuesTooLongFilter method filter.

@Override
public MetadataCollection filter(MetadataCollection original) {
    MetadataCollection result = new MetadataCollection();
    int maxLen = maxLength();
    result.addAll(original.stream().filter(e -> e.getValue().length() <= maxLen).collect(Collectors.toList()));
    return result;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection)

Example 28 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class StringMetadataParameter method createParameters.

@Override
public Map createParameters(AdaptrisMessage msg, Map existingParams) {
    MetadataCollection metadataToInclude = metadataFilter.filter(msg);
    if (metadataToInclude.size() == 0) {
        return existingParams;
    }
    Map params = existingParams == null ? new HashMap() : new HashMap(existingParams);
    for (MetadataElement e : metadataToInclude) {
        params.put(e.getKey(), e.getValue());
    }
    log.trace("Stylesheet parameters: {}", params);
    return params;
}
Also used : HashMap(java.util.HashMap) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class MultipartMessageBuilder method createOutputPart.

protected MultiPartOutput createOutputPart(AdaptrisMessage msg) throws Exception {
    MultiPartOutput output = new MultiPartOutput(contentId(msg), mimeContentSubType(msg));
    MetadataCollection metadata = mimeHeaderFilter().filter(msg);
    metadata.forEach((e) -> {
        output.setHeader(e.getKey(), e.getValue());
    });
    return output;
}
Also used : MultiPartOutput(com.adaptris.util.text.mime.MultiPartOutput) MetadataCollection(com.adaptris.core.MetadataCollection)

Example 30 with MetadataCollection

use of com.adaptris.core.MetadataCollection in project interlok by adaptris.

the class MetadataResponseHeaderProvider method addHeaders.

@Override
public HttpServletResponse addHeaders(AdaptrisMessage msg, HttpServletResponse target) {
    MetadataCollection subset = getFilter().filter(msg);
    for (MetadataElement me : subset) {
        log.trace("Adding Response Header [{}: {}]", me.getKey(), me.getValue());
        target.addHeader(me.getKey(), me.getValue());
    }
    return target;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Aggregations

MetadataCollection (com.adaptris.core.MetadataCollection)66 Test (org.junit.Test)43 MetadataElement (com.adaptris.core.MetadataElement)18 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 KeyValuePair (com.adaptris.util.KeyValuePair)4 Message (javax.jms.Message)4 Session (javax.jms.Session)4 MultiPartOutput (com.adaptris.util.text.mime.MultiPartOutput)3 InternetHeaders (javax.mail.internet.InternetHeaders)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 Event (com.adaptris.core.Event)1 AdapterCloseEvent (com.adaptris.core.event.AdapterCloseEvent)1 MetadataFilterImpl (com.adaptris.core.metadata.MetadataFilterImpl)1 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Properties (java.util.Properties)1 JMSException (javax.jms.JMSException)1