Line data Source code
1 : // Copyright (C) 2014 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.validators; 16 : 17 : import com.google.gerrit.common.Nullable; 18 : import com.google.gerrit.entities.Address; 19 : import com.google.gerrit.entities.EmailHeader; 20 : import com.google.gerrit.extensions.annotations.ExtensionPoint; 21 : import java.util.Map; 22 : import java.util.Set; 23 : 24 : /** Listener to provide validation on outgoing email notification. */ 25 : @ExtensionPoint 26 : public interface OutgoingEmailValidationListener { 27 : /** Arguments supplied to validateOutgoingEmail. */ 28 55 : class Args { 29 : // in arguments 30 : public String messageClass; 31 : @Nullable public String htmlBody; 32 : 33 : // in/out arguments 34 : public Address smtpFromAddress; 35 : public Set<Address> smtpRcptTo; 36 : public String body; // The text body of the email. 37 : public Map<String, EmailHeader> headers; 38 : } 39 : 40 : /** 41 : * Outgoing e-mail validation. 42 : * 43 : * <p>Invoked by Gerrit just before an e-mail is sent, after all e-mail templates have been 44 : * applied. 45 : * 46 : * <p>Plugins may modify the following fields in args: - smtpFromAddress - smtpRcptTo - body - 47 : * headers 48 : * 49 : * @param args E-mail properties. Some are mutable. 50 : * @throws ValidationException if validation fails. 51 : */ 52 : void validateOutgoingEmail(OutgoingEmailValidationListener.Args args) throws ValidationException; 53 : }