Search in sources :

Example 61 with MetadataCollection

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

the class RemoveAllMetadataFilterTest method testFilterMessage.

@Test
public void testFilterMessage() throws Exception {
    RemoveAllMetadataFilter filter = new RemoveAllMetadataFilter();
    MetadataCollection c = filter.filter(createMessage());
    assertEquals(0, c.size());
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) Test(org.junit.Test)

Example 62 with MetadataCollection

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

the class ReformatMetadataKey method buildReplacements.

private MetadataCollection buildReplacements(MetadataCollection toFilter) throws ServiceException {
    MetadataCollection replacements = new MetadataCollection();
    for (MetadataElement e : toFilter) {
        String newKey = reformatKey(e.getKey());
        replacements.add(new MetadataElement(newKey, e.getValue()));
    }
    return replacements;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Example 63 with MetadataCollection

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

the class MetadataFilterService method doService.

@Override
public void doService(AdaptrisMessage msg) {
    log.trace("Filtering metadata using [{}]", filter.getClass().getCanonicalName());
    MetadataCollection filtered = filter.filter(msg);
    msg.clearMetadata();
    msg.setMetadata(filtered.toSet());
    logMetadata("Metadata preserved : {}", filtered);
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection)

Example 64 with MetadataCollection

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

the class HttpProducer method getAdditionalHeaders.

/**
 * Get any additional items that need to be added as HTTP Headers.
 *
 * @param msg the AdaptrisMessage
 * @return a set of properties that contain the required items.
 * @see #setAdditionalHeaders(KeyValuePairSet)
 * @see #setMetadataFilter(MetadataFilter)
 */
protected Properties getAdditionalHeaders(AdaptrisMessage msg) {
    Properties result = new Properties();
    for (Iterator i = additionalHeaders.getKeyValuePairs().iterator(); i.hasNext(); ) {
        KeyValuePair kp = (KeyValuePair) i.next();
        result.setProperty(kp.getKey(), kp.getValue());
    }
    MetadataCollection metadataSubset = getMetadataFilter().filter(msg);
    for (MetadataElement me : metadataSubset) {
        result.setProperty(me.getKey(), me.getValue());
    }
    return result;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) Iterator(java.util.Iterator) MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement) Properties(java.util.Properties)

Example 65 with MetadataCollection

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

the class IgnoreOriginalMimeAggregator method createInitialPart.

@Override
protected MultiPartOutput createInitialPart(AdaptrisMessage original) throws MessagingException, IOException {
    MultiPartOutput output = new MultiPartOutput(original.getUniqueId(), mimeContentSubType(original));
    MetadataCollection metadata = mimeHeaderFilter().filter(original);
    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)

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