Class FlattenMimeParts

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, Service, StateManagedComponent

    @ComponentProfile(summary="Flatten a mime-message so all body parts are part of the root multipart",
                      tag="service,mime")
    public class FlattenMimeParts
    extends ServiceImp
    Flatten any nested MimeBodyParts inside the payload.

    Flattens the payload so that any nested Multiparts have their body parts added directly to the root multipart. This can be useful if you are processing an email message; it can often contain both text and html versions of message body as a nested multipart.

    For example if you have a MIME message that contains 4 body parts; 3 that are plain text, and a 4th that is a multipart which itself contains 3 text parts; then the resulting output will contain 6 parts; the 3 original plain text parts and the 3 nested parts. Note that a Content-Id header will be generated for each part if it does not already exist. Headers will be generally untouched, but boundary markers will change.

    i.e.
     
       
    Mime-Version: 1.0
    Content-Type: multipart/mixed; boundary="----=_Part_3_815648243.1522235646062"
    
    ------=_Part_3_815648243.1522235646062
    Content-Id: part1
    
    ...
    ------=_Part_3_815648243.1522235646062
    Content-Id: part2
    
    ...
    ------=_Part_3_815648243.1522235646062
    Content-Id: part3
    
    ...
    ------=_Part_3_815648243.1522235646062
    Content-Type: multipart/mixed; boundary="----=_Part_2_1537805706.1522235646062"
    
    ------=_Part_2_1537805706.1522235646062
    Content-Id: nested1
    
    ...
    ------=_Part_2_1537805706.1522235646062
    Content-Id: nested2
    
    ...
    ------=_Part_2_1537805706.1522235646062
    Content-Id: nested3
    
    ...
    ------=_Part_2_1537805706.1522235646062--
    
    ------=_Part_3_815648243.1522235646062--
       
     
    becomes
       
    Mime-Version: 1.0
    Content-Type: multipart/mixed; boundary="----=_Part_4_18130400.1522235646074"
    
    ------=_Part_4_18130400.1522235646074
    Content-Id: part1
    
    ...
    ------=_Part_4_18130400.1522235646074
    Content-Id: part2
    
    ...
    ------=_Part_4_18130400.1522235646074
    Content-Id: part3
    
    ...
    ------=_Part_4_18130400.1522235646074
    Content-Id: nested1
    
    ...
    ------=_Part_4_18130400.1522235646074
    Content-Id: nested2
    
    ...
    ------=_Part_4_18130400.1522235646074
    Content-Id: nested3
    
    ...
    ------=_Part_4_18130400.1522235646074--
       
     

    In the adapter configuration file this class is aliased as flatten-mime-parts which is the preferred alternative to the fully qualified classname when building your configuration.