for (Map.Entry<String, String> entry : attrs.entrySet()) {
if (!ATTACHMENT_ID_ATTRIBUTE_NAME.equals(entry.getKey())) {
newAttrs.put(entry.getKey(), entry.getValue());
} else {
String newValue;
AttachmentId mapped = mapping.get(entry.getValue());
if (mapped == null) {
log.warning("Attachment id not found: " + entry);
// Preserve; not sure this is a good idea but it's probably better
// than dropping the value.
newValue = entry.getValue();
} else {
log.info("Replacing " + entry + " with value " + mapped);
newValue = mapped.getId();
}
newAttrs.put(entry.getKey(), newValue);
}
}
attrs = AttributesImpl.fromStringMap(newAttrs);