LCOV - code coverage report
Current view: top level - server/mail/send - EmailArguments.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 33 33 100.0 %
Date: 2022-11-19 15:00:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2016 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.mail.send;
      16             : 
      17             : import com.google.gerrit.common.UsedAt;
      18             : import com.google.gerrit.extensions.registration.DynamicItem;
      19             : import com.google.gerrit.extensions.registration.DynamicSet;
      20             : import com.google.gerrit.server.AnonymousUser;
      21             : import com.google.gerrit.server.CurrentUser;
      22             : import com.google.gerrit.server.GerritPersonIdentProvider;
      23             : import com.google.gerrit.server.IdentifiedUser;
      24             : import com.google.gerrit.server.IdentifiedUser.GenericFactory;
      25             : import com.google.gerrit.server.PatchSetUtil;
      26             : import com.google.gerrit.server.account.AccountCache;
      27             : import com.google.gerrit.server.account.GroupBackend;
      28             : import com.google.gerrit.server.approval.ApprovalsUtil;
      29             : import com.google.gerrit.server.config.AllProjectsName;
      30             : import com.google.gerrit.server.config.AnonymousCowardName;
      31             : import com.google.gerrit.server.config.GerritInstanceName;
      32             : import com.google.gerrit.server.config.GerritServerConfig;
      33             : import com.google.gerrit.server.config.SitePaths;
      34             : import com.google.gerrit.server.config.UrlFormatter;
      35             : import com.google.gerrit.server.git.GitRepositoryManager;
      36             : import com.google.gerrit.server.mail.EmailSettings;
      37             : import com.google.gerrit.server.notedb.ChangeNotes;
      38             : import com.google.gerrit.server.patch.DiffOperations;
      39             : import com.google.gerrit.server.patch.PatchSetInfoFactory;
      40             : import com.google.gerrit.server.permissions.PermissionBackend;
      41             : import com.google.gerrit.server.project.ProjectCache;
      42             : import com.google.gerrit.server.query.account.InternalAccountQuery;
      43             : import com.google.gerrit.server.query.change.ChangeData;
      44             : import com.google.gerrit.server.query.change.ChangeQueryBuilder;
      45             : import com.google.gerrit.server.ssh.SshAdvertisedAddresses;
      46             : import com.google.gerrit.server.update.RetryHelper;
      47             : import com.google.gerrit.server.validators.OutgoingEmailValidationListener;
      48             : import com.google.inject.Inject;
      49             : import com.google.inject.Provider;
      50             : import com.google.inject.Singleton;
      51             : import com.google.template.soy.jbcsrc.api.SoySauce;
      52             : import java.util.List;
      53             : import org.eclipse.jgit.lib.Config;
      54             : import org.eclipse.jgit.lib.PersonIdent;
      55             : 
      56             : /**
      57             :  * Arguments used for sending notification emails.
      58             :  *
      59             :  * <p>Notification emails are sent by out by {@link OutgoingEmail} and it's subclasses, so called
      60             :  * senders. To construct an email the sender class needs to get various other classes injected.
      61             :  * Instead of injecting these classes into the sender classes directly, they only get {@code
      62             :  * EmailArguments} injected and {@code EmailArguments} provides them all dependencies that they
      63             :  * need.
      64             :  *
      65             :  * <p>This class is public because plugins need access to it for sending emails.
      66             :  */
      67             : @Singleton
      68             : @UsedAt(UsedAt.Project.PLUGINS_ALL)
      69             : public class EmailArguments {
      70             :   final GitRepositoryManager server;
      71             :   final ProjectCache projectCache;
      72             :   final PermissionBackend permissionBackend;
      73             :   final GroupBackend groupBackend;
      74             :   final AccountCache accountCache;
      75             :   final DiffOperations diffOperations;
      76             :   final PatchSetUtil patchSetUtil;
      77             :   final ApprovalsUtil approvalsUtil;
      78             :   final Provider<FromAddressGenerator> fromAddressGenerator;
      79             :   final EmailSender emailSender;
      80             :   final PatchSetInfoFactory patchSetInfoFactory;
      81             :   final IdentifiedUser.GenericFactory identifiedUserFactory;
      82             :   final ChangeNotes.Factory changeNotesFactory;
      83             :   final Provider<AnonymousUser> anonymousUser;
      84             :   final String anonymousCowardName;
      85             :   final Provider<PersonIdent> gerritPersonIdent;
      86             :   final DynamicItem<UrlFormatter> urlFormatter;
      87             :   final AllProjectsName allProjectsName;
      88             :   final List<String> sshAddresses;
      89             :   final SitePaths site;
      90             :   final Provider<ChangeQueryBuilder> queryBuilder;
      91             :   final ChangeData.Factory changeDataFactory;
      92             :   final Provider<SoySauce> soySauce;
      93             :   final EmailSettings settings;
      94             :   final DynamicSet<OutgoingEmailValidationListener> outgoingEmailValidationListeners;
      95             :   final Provider<InternalAccountQuery> accountQueryProvider;
      96             :   final OutgoingEmailValidator validator;
      97             :   final boolean addInstanceNameInSubject;
      98             :   final Provider<String> instanceNameProvider;
      99             :   final Provider<CurrentUser> currentUserProvider;
     100             :   final RetryHelper retryHelper;
     101             : 
     102             :   @Inject
     103             :   EmailArguments(
     104             :       GitRepositoryManager server,
     105             :       ProjectCache projectCache,
     106             :       PermissionBackend permissionBackend,
     107             :       GroupBackend groupBackend,
     108             :       AccountCache accountCache,
     109             :       DiffOperations diffOperations,
     110             :       PatchSetUtil patchSetUtil,
     111             :       ApprovalsUtil approvalsUtil,
     112             :       Provider<FromAddressGenerator> fromAddressGenerator,
     113             :       EmailSender emailSender,
     114             :       PatchSetInfoFactory patchSetInfoFactory,
     115             :       GenericFactory identifiedUserFactory,
     116             :       ChangeNotes.Factory changeNotesFactory,
     117             :       Provider<AnonymousUser> anonymousUser,
     118             :       @AnonymousCowardName String anonymousCowardName,
     119             :       GerritPersonIdentProvider gerritPersonIdent,
     120             :       DynamicItem<UrlFormatter> urlFormatter,
     121             :       AllProjectsName allProjectsName,
     122             :       Provider<ChangeQueryBuilder> queryBuilder,
     123             :       ChangeData.Factory changeDataFactory,
     124             :       @MailTemplates Provider<SoySauce> soySauce,
     125             :       EmailSettings settings,
     126             :       @SshAdvertisedAddresses List<String> sshAddresses,
     127             :       SitePaths site,
     128             :       DynamicSet<OutgoingEmailValidationListener> outgoingEmailValidationListeners,
     129             :       Provider<InternalAccountQuery> accountQueryProvider,
     130             :       OutgoingEmailValidator validator,
     131             :       @GerritInstanceName Provider<String> instanceNameProvider,
     132             :       @GerritServerConfig Config cfg,
     133             :       Provider<CurrentUser> currentUserProvider,
     134         146 :       RetryHelper retryHelper) {
     135         146 :     this.server = server;
     136         146 :     this.projectCache = projectCache;
     137         146 :     this.permissionBackend = permissionBackend;
     138         146 :     this.groupBackend = groupBackend;
     139         146 :     this.accountCache = accountCache;
     140         146 :     this.diffOperations = diffOperations;
     141         146 :     this.patchSetUtil = patchSetUtil;
     142         146 :     this.approvalsUtil = approvalsUtil;
     143         146 :     this.fromAddressGenerator = fromAddressGenerator;
     144         146 :     this.emailSender = emailSender;
     145         146 :     this.patchSetInfoFactory = patchSetInfoFactory;
     146         146 :     this.identifiedUserFactory = identifiedUserFactory;
     147         146 :     this.changeNotesFactory = changeNotesFactory;
     148         146 :     this.anonymousUser = anonymousUser;
     149         146 :     this.anonymousCowardName = anonymousCowardName;
     150         146 :     this.gerritPersonIdent = gerritPersonIdent;
     151         146 :     this.urlFormatter = urlFormatter;
     152         146 :     this.allProjectsName = allProjectsName;
     153         146 :     this.queryBuilder = queryBuilder;
     154         146 :     this.changeDataFactory = changeDataFactory;
     155         146 :     this.soySauce = soySauce;
     156         146 :     this.settings = settings;
     157         146 :     this.sshAddresses = sshAddresses;
     158         146 :     this.site = site;
     159         146 :     this.outgoingEmailValidationListeners = outgoingEmailValidationListeners;
     160         146 :     this.accountQueryProvider = accountQueryProvider;
     161         146 :     this.validator = validator;
     162         146 :     this.instanceNameProvider = instanceNameProvider;
     163         146 :     this.addInstanceNameInSubject = cfg.getBoolean("sendemail", "addInstanceNameInSubject", false);
     164         146 :     this.currentUserProvider = currentUserProvider;
     165         146 :     this.retryHelper = retryHelper;
     166         146 :   }
     167             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750