Search in sources :

Example 31 with MetadataCollection

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

the class MimeAggregator method createBodyPart.

protected MimeBodyPart createBodyPart(AdaptrisMessage msg) throws MessagingException, IOException {
    InternetHeaders hdrs = new InternetHeaders();
    byte[] encodedData = encodeData(msg.getPayload(), getEncoding(), hdrs);
    hdrs.addHeader(HEADER_CONTENT_TYPE, contentType(msg));
    MetadataCollection metadata = partHeaderFilter().filter(msg);
    metadata.forEach((e) -> {
        hdrs.addHeader(e.getKey(), e.getValue());
    });
    return new MimeBodyPart(hdrs, encodedData);
}
Also used : InternetHeaders(javax.mail.internet.InternetHeaders) MetadataCollection(com.adaptris.core.MetadataCollection) MimeBodyPart(javax.mail.internet.MimeBodyPart)

Example 32 with MetadataCollection

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

the class ReformatMetadataKey method doService.

@Override
public void doService(AdaptrisMessage msg) throws ServiceException {
    MetadataCollection toFilter = getKeysToModify().filter(msg);
    MetadataCollection replacements = buildReplacements(toFilter);
    // toFilter.forEach(e -> { msg.removeMetadata(e); });
    // replacements.forEach(e -> { msg.addMetadata(e); });
    logMetadata("Removing {}", toFilter);
    removeMetadata(msg, toFilter);
    logMetadata("Adding {}", replacements);
    addMetadata(msg, replacements);
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection)

Example 33 with MetadataCollection

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

the class UrlEncodedMetadataValues method buildEncodedString.

protected String buildEncodedString(AdaptrisMessage msg) throws Exception {
    MetadataCollection filtered = metadataFilter().filter(msg);
    StringBuilder result = new StringBuilder();
    for (MetadataElement e : filtered) {
        if (result.length() > 1) {
            // This is not the first parameter so add a separator
            result.append(separator());
        }
        result.append(e.getKey()).append("=").append(URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8.name()));
    }
    return result.toString();
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection) MetadataElement(com.adaptris.core.MetadataElement)

Example 34 with MetadataCollection

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

the class MetadataKeysOnly method format.

private Collection<MetadataElement> format(Collection<MetadataElement> set) {
    MetadataCollection metadata = new MetadataCollection();
    set.stream().forEach(e -> {
        metadata.add(new KeysOnly(e.getKey(), e.getValue()));
    });
    return metadata;
}
Also used : MetadataCollection(com.adaptris.core.MetadataCollection)

Example 35 with MetadataCollection

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

the class PasswordMetadataFilter method filter.

@Override
public MetadataCollection filter(MetadataCollection original) {
    if (getPasswordPatterns().size() == 0) {
        return original;
    }
    patternPasswords = validatePatterns(getPasswordPatterns(), patternPasswords);
    MetadataCollection result = new MetadataCollection();
    result.addAll(original.stream().map(e -> {
        return matches(e, patternPasswords) ? rebuild(e) : e;
    }).collect(Collectors.toList()));
    return result;
}
Also used : 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