patricker commented on a change in pull request #4776:
URL: https://github.com/apache/nifi/pull/4776#discussion_r562966351



##########
File path: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java
##########
@@ -343,7 +354,7 @@ protected void fillMessageQueueIfNecessary(ProcessContext 
context) throws Proces
 
             try {
                 //Get Folder
-                Folder folder = getFolder(service);
+                Folder folder = getFolder(service, context);

Review comment:
       I'd suggest moving `String MailboxProperty = 
context.getProperty(MAILBOX).getValue();` up here, and passing in the MAILBOX 
as an optional parameter to `getFolder`. Then you can keep `getFolder` as an 
Exchange only method.

##########
File path: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java
##########
@@ -376,11 +387,22 @@ protected void fillMessageQueueIfNecessary(ProcessContext 
context) throws Proces
         }
     }
 
-    protected Folder getFolder(ExchangeService service) {
+    protected Folder getFolder(ExchangeService service, ProcessContext 
context) {
         Folder folder;
+        String MailboxProperty = context.getProperty(MAILBOX).getValue();
         if(folderName.equals("INBOX")){
             try {
-                folder = Folder.bind(service, WellKnownFolderName.Inbox);
+                if (!StringUtils.isEmpty(MailboxProperty))
+                    {
+                        Mailbox mailbox = new Mailbox(MailboxProperty);
+                        FolderId InboxFolderId = new 
FolderId(WellKnownFolderName.Inbox, mailbox);

Review comment:
       But now MAILBOX only works if the folder is the INBOX right? This would 
stop you from accessing any folder in a different mailbox except the INBOX.

##########
File path: 
nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java
##########
@@ -107,6 +109,14 @@
             .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
             .sensitive(true)
             .build();
+    public static final PropertyDescriptor MAILBOX = new 
PropertyDescriptor.Builder()
+            .name("mailbox")
+            .displayName("Mailbox")
+            .description("Mailbox")
+            .required(false)

Review comment:
       I would add a default value just to make sure querying this property at 
least returns an empty string:
   `.defaultValue("")` is used in other properties for this reason already.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to