Search in sources :

Example 36 with MetadataCollection

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

the class RegexMetadataFilter method include.

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

Example 37 with MetadataCollection

use of com.adaptris.core.MetadataCollection 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 38 with MetadataCollection

use of com.adaptris.core.MetadataCollection 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)

Example 39 with MetadataCollection

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

the class OrderedItemMetadataFilter method filter.

@Override
public MetadataCollection filter(MetadataCollection originalCollection) {
    MetadataCollection results = new MetadataCollection();
    Map<String, String> original;
    if (ignoreCase()) {
        original = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        original.putAll(MetadataCollection.asMap(originalCollection));
    } else {
        original = MetadataCollection.asMap(originalCollection);
    }
    for (String key : getMetadataKeys()) {
        String value = original.get(key);
        if (value != null) {
            results.add(new MetadataElement(key, value));
        } else {
            results.add(new MetadataElement(key, ""));
        }
    }
    return results;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Example 40 with MetadataCollection

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

the class DiscardValuesTooLongFilterTest method testFilterCollection.

@Test
public void testFilterCollection() throws Exception {
    DiscardValuesTooLongFilter filter = new DiscardValuesTooLongFilter(36);
    MetadataCollection c = filter.filter(new MetadataCollection(createMessage().getMetadata()));
    assertEquals(4, c.size());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

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