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);
}
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);
}
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();
}
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;
}
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;
}
Aggregations