private Map<String, Attachment> transformToCxfAttachments(Map<String, SoapAttachment> attachments) { ImmutableMap.Builder<String, Attachment> builder = ImmutableMap.builder(); attachments.forEach((name, value) -> { try { builder.put(name, new AttachmentImpl(name, toDataHandler(name, value.getContent(), value.getContentType()))); } catch (IOException e) { throw new BadRequestException(format("Error while preparing attachment [%s] for upload", name), e); } }); return builder.build(); }