Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1867#discussion_r122895895
  
    --- Diff: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java
 ---
    @@ -403,7 +420,12 @@ public MimeMessage parseMessage(EmailMessage item) 
throws Exception {
             //sent date
             mm.setSentDate(ewsMessage.getDateTimeSent());
             //add message headers
    -        ewsMessage.getInternetMessageHeaders().forEach(x-> 
mm.addHeader(x.getName(), x.getValue()));
    +        if(hdrList.size() > 0 && hdrList.get(0).equals("*"))
    +            ewsMessage.getInternetMessageHeaders().forEach(x-> 
mm.addHeader(x.getName(), x.getValue()));
    +        else if(hdrList.size() > 0)
    +            ewsMessage.getInternetMessageHeaders().forEach(x-> {
    +                if(hdrList.contains(x.getName())) 
mm.addHeader(x.getName(), x.getValue());
    +            });
    --- End diff --
    
    We maybe able to simplify this with:
    
    ```
    ewsMessage.getInternetMessageHeaders().stream()
        .filter(x -> (hdrList == null || hdrList.isEmpty() || 
hdrList.contains(x.getName)))
        .forEach(x-> mm.addHeader(x.getName(), x.getValue());
    ```
    
    Then we could add exclude list as well easily:
    ```
    ewsMessage.getInternetMessageHeaders().stream()
        .filter(x -> (includes == null || includes.isEmpty() || 
includes.contains(x.getName))
                          && (excludes == null || excludes.isEmpty() || 
!excludes.contains(x.getName))
        .forEach(x-> mm.addHeader(x.getName(), x.getValue());
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to