You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by patricker <gi...@git.apache.org> on 2017/05/29 06:45:14 UTC

[GitHub] nifi pull request #1867: NIFI-3992

GitHub user patricker opened a pull request:

    https://github.com/apache/nifi/pull/1867

    NIFI-3992

    If an email contains attachments, ConsumeEWS may generate emails where the attachments cannot be extracted.
    
    This is due to some of the headers present on the original Exchange email that confuse the Mime Parser.
    To resolve this I added a configuration option on whether or not to copy the original headers.
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [x] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [ ] Have you written or updated unit tests to verify your changes?
    - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/patricker/nifi NIFI-3992

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/1867.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1867
    
----
commit c0e960f446bf9fb38ec31476a4b05a68ae78995b
Author: patricker <pa...@gmail.com>
Date:   2017-05-29T06:42:21Z

    NIFI-3992

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by ijokarumawak <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by ijokarumawak <gi...@git.apache.org>.
Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1867#discussion_r122894561
  
    --- Diff: nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java ---
    @@ -304,6 +314,13 @@ protected void fillMessageQueueIfNecessary(ProcessContext context) throws Proces
                 ExchangeService service = this.initializeIfNecessary(context);
                 boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
                 boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");
    +            String includeHeaders = context.getProperty(INCLUDE_EMAIL_HEADERS).getValue();
    +            String[] headersList;
    +            if(includeHeaders.equals("")){
    +                headersList = new String[1];
    +                headersList[0] = "*";
    +            }
    +            headersList = includeHeaders.split(",");
    --- End diff --
    
    ```
    if (!StringUtils.isEmpty(includeHeaders)) {
      headersList = includeHeaders.split(",");
    }
    ```
    
    Would be simpler.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by ijokarumawak <gi...@git.apache.org>.
Github user ijokarumawak commented on the issue:

    https://github.com/apache/nifi/pull/1867
  
    @patricker The updates LGTM +1. Thank you! I'm going to merge this into master.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by ijokarumawak <gi...@git.apache.org>.
Github user ijokarumawak commented on the issue:

    https://github.com/apache/nifi/pull/1867
  
    @patricker Thank you for the fix! Having regex option like LogAttribute processor might be more flexible than boolean switch, if user would like to consume attachment as well as use headers. How do you think?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by patricker <gi...@git.apache.org>.
Github user patricker commented on the issue:

    https://github.com/apache/nifi/pull/1867
  
    @ijokarumawak I've updated my code to work this way.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by patricker <gi...@git.apache.org>.
Github user patricker commented on the issue:

    https://github.com/apache/nifi/pull/1867
  
    @ijokarumawak Thanks for the review and code. It worked out well. I think I've made all the requested updates.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by ijokarumawak <gi...@git.apache.org>.
Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1867#discussion_r122896473
  
    --- Diff: nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java ---
    @@ -175,6 +175,16 @@
                 .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
                 .build();
     
    +    public static final PropertyDescriptor INCLUDE_EMAIL_HEADERS = new PropertyDescriptor.Builder()
    +            .name("ews-include-headers")
    +            .displayName("Original Headers to Include")
    +            .description("Comma delimited list specifying which headers from the original message to include in the exported email message. '*' means copy all headers. " +
    +                    "Some headers can cause problems with message parsing, specifically the 'Content-Type' header.")
    --- End diff --
    
    If excluding 'Content-Type' is the most use-case, user may want to simply excludes it. It can be better if it provides both of 'include' and 'exclude' headers options. There are many headers possibly returned, https://www.iana.org/assignments/message-headers/message-headers.xhtml


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1867: NIFI-3992 ConsumeEWS May Generate Unusable Emails

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi/pull/1867


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---