[GitHub] [nifi] exceptionfactory commented on a change in pull request #5471: NIFI-9308: Created EmailRecordSinkService for Reporting Tasks
exceptionfactory commented on a change in pull request #5471: URL: https://github.com/apache/nifi/pull/5471#discussion_r738424864 ## File path: nifi-nar-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java ## @@ -0,0 +1,381 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.record.sink; + +import jakarta.mail.Authenticator; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.PasswordAuthentication; +import jakarta.mail.Session; +import jakarta.mail.Transport; +import jakarta.mail.internet.AddressException; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeMessage; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; +import org.apache.nifi.serialization.WriteResult; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSet; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +public class EmailRecordSink extends AbstractControllerService implements RecordSinkService { + +public static final PropertyDescriptor FROM = new PropertyDescriptor.Builder() +.name("from") +.displayName("From") +.description("Specifies the Email address to use as the sender. " ++ "Comma separated sequence of addresses following RFC822 syntax.") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +public static final PropertyDescriptor TO = new PropertyDescriptor.Builder() +.name("to") +.displayName("To") +.description("The recipients to include in the To-Line of the email. " ++ "Comma separated sequence of addresses following RFC822 syntax.") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +public static final PropertyDescriptor CC = new PropertyDescriptor.Builder() +.name("cc") +.displayName("CC") +.description("The recipients to include in the CC-Line of the email. " ++ "Comma separated sequence of addresses following RFC822 syntax.") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +public static final PropertyDescriptor BCC = new PropertyDescriptor.Builder() +.name("bcc") +.displayName("BCC") +.description("The recipients to include in the BCC-Line of the email. " ++ "Comma separated sequence of addresses following RFC822 syntax.") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +public static final PropertyDescriptor SUBJECT = new
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5471: NIFI-9308: Created EmailRecordSinkService for Reporting Tasks
exceptionfactory commented on a change in pull request #5471: URL: https://github.com/apache/nifi/pull/5471#discussion_r734604045 ## File path: nifi-nar-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java ## @@ -0,0 +1,360 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.record.sink; + +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.RecordSetWriter; +import org.apache.nifi.serialization.RecordSetWriterFactory; +import org.apache.nifi.serialization.WriteResult; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSet; + +import javax.mail.Authenticator; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +public class EmailRecordSink extends AbstractControllerService implements RecordSinkService { + +public static final PropertyDescriptor SMTP_HOSTNAME = new PropertyDescriptor.Builder() +.name("SMTP Hostname") +.description("The hostname of the SMTP Server that is used to send Email Notifications") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.required(true) +.build(); +public static final PropertyDescriptor SMTP_PORT = new PropertyDescriptor.Builder() +.name("SMTP Port") +.description("The Port used for SMTP communications") +.required(true) +.defaultValue("25") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.PORT_VALIDATOR) +.build(); +public static final PropertyDescriptor SMTP_USERNAME = new PropertyDescriptor.Builder() +.name("SMTP Username") +.description("Username for the SMTP account") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.required(false) +.build(); +public static final PropertyDescriptor SMTP_PASSWORD = new PropertyDescriptor.Builder() +.name("SMTP Password") +.description("Password for the SMTP account") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.required(false) +.sensitive(true) +.build(); +public static final PropertyDescriptor SMTP_AUTH = new PropertyDescriptor.Builder() +.name("SMTP Auth") Review comment: Could this property be inferred based on the presence of the Username and Password properties? Alternatively, the Username and Password properties should depend on this property being enabled. ## File path: nifi-nar-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java ## @@ -0,0 +1,360 @@ +/* + * Licensed to the Apache Software