Project

General

Profile

« Previous | Next » 

Revision 57912

More thorought implementation for the email notifications when registering/updating repositories

View differences:

EmailUtilsImpl.java
8 8
import eu.dnetlib.repo.manager.domain.ValidationServiceException;
9 9
import eu.dnetlib.utils.MailLibrary;
10 10
import org.apache.log4j.Logger;
11
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
11 12
import org.springframework.beans.factory.annotation.Autowired;
12 13
import org.springframework.beans.factory.annotation.Value;
13 14
import org.springframework.security.core.Authentication;
......
205 206
    @Override
206 207
    public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
207 208
        try {
208
            String subject = "OpenAIRE content provider registration request started for " +
209
            String subject = "OpenAIRE content provider registration for " +
209 210
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
210 211

  
211 212
            String message = "Dear administrator" + ",\n" +
212 213
                    "\n" +
213 214
                    "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
214 215
                    " to the OpenAIRE compliant list of content providers. " +
215
                    "A validation process against the OpenAIRE guidelines compatibility " +
216
                    "has been started. You will be informed in another message once the process is finished." +
217 216
                    "\n\n" +
217
                    "User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
218
                    "\n\n" +
218 219
                    "Please do not reply to this message\n" +
219 220
                    "This message has been generated automatically.\n\n" +
220 221
                    "Regards,\n" +
......
231 232
    @Override
232 233
    public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception {
233 234
        try {
234
            String subject = "OpenAIRE content provider registration request started for " +
235
            String subject = "OpenAIRE content provider registration for " +
235 236
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
236 237

  
237 238
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
......
239 240
                    "\n" +
240 241
                    "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
241 242
                    " to the OpenAIRE compliant list of content providers. " +
242
                    "A validation process against the OpenAIRE guidelines compatibility " +
243
                    "has been started. You will be informed in another message once the process is finished." +
244 243
                    "\n\n" +
245 244
                    "Please do not reply to this message\n" +
246 245
                    "This message has been generated automatically.\n\n" +
......
257 256
    }
258 257

  
259 258
    @Override
259
    public void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
260
        try {
261
            String subject = "OpenAIRE new interface registration request started for " +
262
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
263

  
264
            String message = "Dear administrator" + ",\n" +
265
                    "\n" +
266
                    "We received a request to add the following interface: \n\n" +
267
                    "Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
268
                    "Set: " + repositoryInterface.getAccessSet() + "\n" +
269
                    "Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
270
                    "to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
271
                    "A validation process for this interface against the OpenAIRE guidelines compatibility " +
272
                    "has been started. You will be informed in another message once the process is finished." +
273
                    "\n\n" +
274
                    "User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
275
                    "\n\n" +
276
                    "Please do not reply to this message\n" +
277
                    "This message has been generated automatically.\n\n" +
278
                    "Regards,\n" +
279
                    "the OpenAIRE technical team\n";
280

  
281
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
282

  
283
        } catch (Exception e) {
284
            LOGGER.error("Error while sending registration of interface notification email to the administrator", e);
285
            throw e;
286
        }
287
    }
288

  
289
    @Override
290
    public void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
291
        try {
292
            String subject = "OpenAIRE new interface registration request started for " +
293
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
294

  
295
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
296
            String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
297
                    "\n" +
298
                    "We received a request to add the following interface: \n\n" +
299
                    "Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
300
                    "Set: " + repositoryInterface.getAccessSet() + "\n" +
301
                    "Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
302
                    "to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
303
                    "A validation process for this interface against the OpenAIRE guidelines compatibility " +
304
                    "has been started. You will be informed in another message once the process is finished." +
305
                    "\n\n" +
306
                    "Please do not reply to this message\n" +
307
                    "This message has been generated automatically.\n\n" +
308
                    "Regards,\n" +
309
                    "the OpenAIRE technical team\n";
310

  
311
            this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
312

  
313
        } catch (Exception e) {
314
            LOGGER.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredBy(), e);
315
            throw e;
316
        }
317
    }
318

  
319
    @Override
260 320
    public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
261 321
        try {
262
            String subject = "OpenAIRE content provider registration request - results (success) for " +
322
            String subject = "OpenAIRE new interface registration request - results (success) for " +
263 323
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
264 324

  
265 325
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
......
292 352
    @Override
293 353
    public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
294 354
        try {
295
            String subject = "OpenAIRE content provider registration request - results (success) for " +
355
            String subject = "OpenAIRE new interface registration request - results (success) for " +
296 356
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
297 357

  
298 358
            String message = "Dear admin ,\n" +
......
325 385
    @Override
326 386
    public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
327 387
        try {
328
            String subject = "OpenAIRE content provider registration request - results (failure) for " +
388
            String subject = "OpenAIRE new interface registration request - results (failure) for " +
329 389
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
330 390
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
331 391
            String message = "Dear user,\n" +
......
357 417
    @Override
358 418
    public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
359 419
        try {
360
            String subject = "OpenAIRE content provider registration request - results (failure) for " +
420
            String subject = "OpenAIRE new interface registration request - results (failure) for " +
361 421
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
362 422

  
363 423
            String message = "Dear admin,\n" +
......
390 450
    @Override
391 451
    public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
392 452
        try {
393
            String subject = "OpenAIRE content provider registration request - results (success) for " +
453
            String subject = "OpenAIRE interface update request - results (success) for " +
394 454
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
395 455

  
396 456
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
......
421 481
    @Override
422 482
    public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
423 483
            try {
424
                String subject = "OpenAIRE content provider registration request - results (success) for " +
484
                String subject = "OpenAIRE interface update request - results (success) for " +
425 485
                        repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
426 486

  
427 487
                String message = "Dear admin,\n" +
......
452 512
    @Override
453 513
    public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
454 514
        try {
455
            String subject = "OpenAIRE content provider update request - results (failure) for " +
515
            String subject = "OpenAIRE interface update request - results (failure) for " +
456 516
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
457 517

  
458 518
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
......
485 545
    @Override
486 546
    public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
487 547
        try {
488
            String subject = "OpenAIRE content provider update request - results (failure) for " +
548
            String subject = "OpenAIRE interface update request - results (failure) for " +
489 549
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
490 550

  
491 551
            String message = "Dear admin,\n" +
......
545 605

  
546 606
            String message = "Dear admin,\n" +
547 607
                    "\n" +
548
                    "the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
608
                    "a validation request has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
549 609
                    "\n\nUser Contact:"+ issuer +""+
550 610
                    "Please do not reply to this message.\n" +
551 611
                    "This message has been generated automatically.\n" +
......
582 642
    }
583 643

  
584 644
    @Override
585
    public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
645
    public void sendAdminUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
586 646
        try {
587
            String subject = "OpenAIRE content provider update request started for " +
647
            String subject = "OpenAIRE content provider update information for " +
588 648
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
589 649

  
590 650
            String message = "Dear administrator" + ",\n" +
591 651
                    "\n" +
592
                    "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
652
                    "We received a request to update the basic information for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n\n" +
653
                    "Please do not reply to this message\n" +
654
                    "This message has been generated automatically.\n\n" +
655
                    "Regards,\n" +
656
                    "the OpenAIRE technical team\n";
657

  
658
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
659

  
660
        } catch (Exception e) {
661
            LOGGER.error("Error while sending registration notification email to the administrator", e);
662
            throw e;
663
        }
664
    }
665

  
666
    @Override
667
    public void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception {
668
        try {
669
            String subject = "OpenAIRE content provider update information for " +
670
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
671

  
672
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
673
            String message = "Dear user,\n" +
674
                    "\n" +
675
                    "We received a request to update the basic information for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n\n" +
676
                    "Please do not reply to this message\n" +
677
                    "This message has been generated automatically.\n\n" +
678
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
679
                    "Regards,\n" +
680
                    "the OpenAIRE technical team\n";
681

  
682
            this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
683

  
684
        } catch (Exception e) {
685
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
686
            throw e;
687
        }
688
    }
689

  
690
    @Override
691
    public void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
692
        try {
693
            String subject = "OpenAIRE interface update request started for " +
694
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
695

  
696
            String message = "Dear administrator" + ",\n" +
697
                    "\n" +
698
                    "We received a request to update the following interface: \n\n" +
699
                    "Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
700
                    "Set: " + repositoryInterface.getAccessSet() + "\n" +
701
                    "Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
702
                    "for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
593 703
                    "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
704
                    "User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" +
705
                    "\n\n" +
594 706
                    "Please do not reply to this message\n" +
595 707
                    "This message has been generated automatically.\n\n" +
596 708
                    "Regards,\n" +
......
605 717
    }
606 718

  
607 719
    @Override
608
    public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
720
    public void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
609 721
        try {
610
            String subject = "OpenAIRE content provider update request started for " +
722
            String subject = "OpenAIRE interface update request started for " +
611 723
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
612 724

  
613 725
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
614 726
            String message = "Dear user,\n" +
615 727
                    "\n" +
616
                    "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
728
                    "We received a request to update the following interface: \n\n" +
729
                    "Base URL: " + repositoryInterface.getBaseUrl() + "\n" +
730
                    "Set: " + repositoryInterface.getAccessSet() + "\n" +
731
                    "Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" +
732
                    "for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" +
617 733
                    "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
618 734
                    "Please do not reply to this message\n" +
619 735
                    "This message has been generated automatically.\n\n" +

Also available in: Unified diff