public static EbMSMessage ebMSMessageContentToEbMSMessage(
      CollaborationProtocolAgreement cpa, EbMSMessageContent content, String hostname)
      throws DatatypeConfigurationException {
    MessageHeader messageHeader = createMessageHeader(cpa, content.getContext(), hostname);

    AckRequested ackRequested = createAckRequested(cpa, content.getContext());

    Manifest manifest = createManifest();
    for (int i = 0; i < content.getAttachments().size(); i++)
      manifest.getReference().add(createReference(i + 1));

    List<DataSource> attachments = new ArrayList<DataSource>();
    for (EbMSAttachment attachment : content.getAttachments()) {
      ByteArrayDataSource ds =
          new ByteArrayDataSource(attachment.getContent(), attachment.getContentType());
      ds.setName(attachment.getName());
      attachments.add(ds);
    }

    return new EbMSMessage(messageHeader, ackRequested, manifest, attachments);
  }
 public static Manifest createManifest() {
   Manifest manifest = new Manifest();
   manifest.setVersion(Constants.EBMS_VERSION);
   return manifest;
 }