Project

General

Profile

« Previous | Next » 

Revision 56961

fixing from & quantity values for export-to-csv functionality

View differences:

modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java
2 2

  
3 3
import eu.dnetlib.domain.data.PiwikInfo;
4 4
import eu.dnetlib.domain.data.Repository;
5
import eu.dnetlib.domain.data.RepositoryInterface;
5 6
import eu.dnetlib.domain.functionality.validator.JobForValidation;
7
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
8
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
9
import org.json.JSONException;
6 10
import org.springframework.security.core.Authentication;
7 11

  
8 12
public interface EmailUtils {
......
18 22

  
19 23
    void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception;
20 24

  
25
    /****USER REGISTRATION REQUEST EMAILS****/
21 26
    void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
22 27

  
23 28
    void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception;
24 29

  
30
    /****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
31
    void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
32

  
33
    void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
34

  
35
    /****FAILURE REGISTRATION RESULTS EMAILS****/
36
    void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
37

  
38
    void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
39

  
40
    /****SUCCESSFUL UPDATE RESULTS EMAILS****/
41
    void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
42

  
43
    void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
44

  
45
    /****FAILURE UPDATE RESULTS EMAILS****/
46
    void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
47

  
48
    void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
49

  
50
    /****VALIDATION OF CONTENT PROVIDER EMAILS****/
51
    void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
52

  
53
    void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
54

  
55
    /****GENERAL FAILURE OF VALIDATOR****/
56
    void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception;
57

  
58

  
25 59
    void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
26 60

  
27 61
    void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception;
28 62

  
29 63
    void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception;
64

  
65
    void sendUponJobCompletion(String repoId,
66
                               String repoInterfaceId,
67
                               int scoreUsage,
68
                               int scoreContent,
69
                               boolean isSuccess,
70
                               boolean isUpdate,
71
                               String issuerEmail,
72
                               String jobId) throws Exception;
30 73
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java
535 535

  
536 536
            HttpEntity<String> httpEntity = new HttpEntity <> (json_interface,httpHeaders);
537 537
            restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
538
            submitInterfaceValidation(e, registeredBy, repositoryInterface);
538
            submitInterfaceValidation(e, registeredBy, repositoryInterface, false);
539 539

  
540 540
            return repositoryInterface;
541 541

  
......
554 554
        this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());
555 555
        this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance());
556 556
        this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet());
557
        submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface);
557
        submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true);
558 558
        return repositoryInterface;
559 559
    }
560 560

  
561
    private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace) throws ValidatorServiceException {
561
    private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting) throws ValidatorServiceException {
562 562
        JobForValidation job = new JobForValidation();
563 563

  
564 564
        job.setActivationId(UUID.randomUUID().toString());
......
572 572
        job.setUserEmail(userEmail);
573 573
        job.setValidationSet((iFace.getAccessSet().isEmpty() ? "none" : iFace.getAccessSet()));
574 574
        job.setRecords(-1);
575
        job.setRegistration(true);
576
        job.setUpdateExisting(false);
575
        job.setRegistration(!updateExisting);
576
        job.setUpdateExisting(updateExisting);
577 577

  
578 578
        this.validatorService.submitJobForValidation(job);
579 579
    }
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java
2 2

  
3 3
import eu.dnetlib.domain.data.PiwikInfo;
4 4
import eu.dnetlib.domain.data.Repository;
5
import eu.dnetlib.domain.data.RepositoryInterface;
5 6
import eu.dnetlib.domain.functionality.validator.JobForValidation;
6 7
import eu.dnetlib.repo.manager.config.CascadingPropertyLoader;
8
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
9
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
7 10
import eu.dnetlib.utils.MailLibrary;
8 11
import org.apache.log4j.Logger;
12
import org.json.JSONException;
9 13
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
10 14
import org.springframework.beans.factory.annotation.Autowired;
11 15
import org.springframework.beans.factory.annotation.Value;
12 16
import org.springframework.security.core.Authentication;
17
import org.springframework.security.core.context.SecurityContextHolder;
13 18
import org.springframework.stereotype.Component;
14 19

  
15 20
import javax.annotation.PostConstruct;
......
18 23
import java.io.Writer;
19 24
import java.util.ArrayList;
20 25
import java.util.List;
26
import java.util.stream.Collectors;
21 27

  
22 28

  
23 29
@Component("emailUtils")
......
47 53
    @Value("${services.provide.adminEmail}")
48 54
    private String provideAdminEmail;
49 55

  
56
    @Value("${validator.results.url}")
57
    private String valBaseUrl;
50 58

  
59
    @Autowired
60
    private RepositoryService repositoryService;
61

  
62

  
51 63
    @PostConstruct
52 64
    public void init(){
53 65
        System.out.println("url -> " + this.baseUrl);
......
225 237
            String subject = "OpenAIRE content provider registration request started for " +
226 238
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
227 239

  
228
            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
240
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
241
            String message = "Dear user,\n" +
229 242
                    "\n" +
230 243
                    "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
231 244
                    " to the OpenAIRE compliant list of content providers. " +
......
247 260
    }
248 261

  
249 262
    @Override
263
    public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
264
        try {
265
            String subject = "OpenAIRE content provider registration request - results (success) for " +
266
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
267

  
268
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
269
            String message = "Dear user,\n" +
270
                    "\n" +
271
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
272
                    " was successful and the datasource type \""+ repository.getDatasourceType()  + "\" will be prepared for aggregation in OpenAIRE."+
273
                    "\n\n" +
274
                    "Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
275
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
276
                    "\nOfficial Name:" + repository.getOfficialName() +
277
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
278
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
279
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
280
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
281
                    "\n\n\nPlease do not reply to this email\n"+
282
                    "This message has been generated manually\n\n"+
283
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
284
                    "Regards,\n" +
285
                    "the OpenAIRE technical team\n";
286

  
287
            this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
288

  
289
        } catch (Exception e) {
290
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
291
            throw e;
292
        }
293
    }
294

  
295
    @Override
296
    public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
297
        try {
298
            String subject = "OpenAIRE content provider registration request - results (success) for " +
299
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
300

  
301
            String message = "Dear admin ,\n" +
302
                    "\n" +
303
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
304
                    " was successful and the datasource type \""+ repository.getDatasourceType()  + "\" will be prepared for aggregation in OpenAIRE."+
305
                    "\n\n" +
306
                    "Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" +
307
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
308
                    "\nOfficial Name:" + repository.getOfficialName() +
309
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
310
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
311
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
312
                    "\n\nUser Contact:"+ issuerEmail +""+
313
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
314
                    "\n\n\nPlease do not reply to this email\n"+
315
                    "This message has been generated manually\n\n"+
316
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
317
                    "Regards,\n" +
318
                    "the OpenAIRE technical team\n";
319

  
320
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
321

  
322
        } catch (Exception e) {
323
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
324
            throw e;
325
        }
326
    }
327

  
328
    @Override
329
    public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
330
        try {
331
            String subject = "OpenAIRE content provider registration request - results (failure) for " +
332
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
333
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
334
            String message = "Dear user,\n" +
335
                    "\n" +
336
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
337
                    " was not successful and the registration process was interrupted."+
338
                    "\n\n" +
339
                    "We will check what caused the problem and get back to you within a couple of days.\n\n" +
340
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
341
                    "\nOfficial Name:" + repository.getOfficialName() +
342
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
343
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
344
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
345
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
346
                    "\n\n\nPlease do not reply to this email\n"+
347
                    "This message has been generated manually\n\n"+
348
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
349
                    "Regards,\n" +
350
                    "the OpenAIRE technical team\n";
351

  
352
            this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
353

  
354
        } catch (Exception e) {
355
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
356
            throw e;
357
        }
358
    }
359

  
360
    @Override
361
    public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
362
        try {
363
            String subject = "OpenAIRE content provider registration request - results (failure) for " +
364
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
365

  
366
            String message = "Dear admin,\n" +
367
                    "\n" +
368
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
369
                    " was not successful and the registration process was interrupted."+
370
                    "\n\n" +
371
                    "We will check what caused the problem and get back to you within a couple of days.\n\n" +
372
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
373
                    "\nOfficial Name:" + repository.getOfficialName() +
374
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
375
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
376
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
377
                    "\n\nUser Contact:"+ issuerEmail +""+
378
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
379
                    "\n\n\nPlease do not reply to this email\n"+
380
                    "This message has been generated manually\n\n"+
381
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
382
                    "Regards,\n" +
383
                    "the OpenAIRE technical team\n";
384

  
385
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
386

  
387
        } catch (Exception e) {
388
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
389
            throw e;
390
        }
391
    }
392

  
393
    @Override
394
    public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
395
        try {
396
            String subject = "OpenAIRE content provider registration request - results (success) for " +
397
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
398

  
399
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
400
            String message = "Dear user,\n" +
401
                    "\n" +
402
                    "the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" +
403
                    "We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
404
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
405
                    "\nOfficial Name:" + repository.getOfficialName() +
406
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
407
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
408
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
409
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
410
                    "\n\n\nPlease do not reply to this email\n"+
411
                    "This message has been generated manually\n\n"+
412
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
413
                    "Regards,\n" +
414
                    "the OpenAIRE technical team\n";
415

  
416
            this.sendMail(issuer, subject, message, false, null);
417

  
418
        } catch (Exception e) {
419
            LOGGER.error("Error while sending registration notification email to the administrator", e);
420
            throw e;
421
        }
422
    }
423

  
424
    @Override
425
    public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
426
            try {
427
                String subject = "OpenAIRE content provider registration request - results (success) for " +
428
                        repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
429

  
430
                String message = "Dear admin,\n" +
431
                        "\n" +
432
                        "the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" +
433
                        "We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" +
434
                        "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
435
                        "\nOfficial Name:" + repository.getOfficialName() +
436
                        "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
437
                        "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
438
                        "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
439
                        "\n\nUser Contact:"+ issuerEmail +""+
440
                        "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
441
                        "\n\n\nPlease do not reply to this email\n"+
442
                        "This message has been generated manually\n\n"+
443
                        "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
444
                        "Regards,\n" +
445
                        "the OpenAIRE technical team\n";
446

  
447
                this.sendMail(this.provideAdminEmail, subject, message, false, null);
448

  
449
            } catch (Exception e) {
450
                LOGGER.error("Error while sending registration notification email to the administrator", e);
451
                throw e;
452
            }
453
    }
454

  
455
    @Override
456
    public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
457
        try {
458
            String subject = "OpenAIRE content provider update request - results (failure) for " +
459
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
460

  
461
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
462
            String message = "Dear user,\n" +
463
                    "\n" +
464
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
465
                    " was not successful."+
466
                    "\n\n" +
467
                    "WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
468
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
469
                    "\nOfficial Name:" + repository.getOfficialName() +
470
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
471
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
472
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
473
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
474
                    "\n\n\nPlease do not reply to this email\n"+
475
                    "This message has been generated manually\n\n"+
476
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
477
                    "Regards,\n" +
478
                    "the OpenAIRE technical team\n";
479

  
480
            this.sendMail(issuer, subject, message, false, null);
481

  
482
        } catch (Exception e) {
483
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
484
            throw e;
485
        }
486
    }
487

  
488
    @Override
489
    public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
490
        try {
491
            String subject = "OpenAIRE content provider update request - results (failure) for " +
492
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
493

  
494
            String message = "Dear admin,\n" +
495
                    "\n" +
496
                    "the compatibility test on " + "[" + repository.getEnglishName() + "]" +
497
                    " was not successful."+
498
                    "\n\n" +
499
                    "WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" +
500
                    "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+
501
                    "\nOfficial Name:" + repository.getOfficialName() +
502
                    "\n\nBase URL: "+ repositoryInterface.getBaseUrl() +
503
                    "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
504
                    "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() +
505
                    "\n\nUser Contact:"+ issuerEmail +""+
506
                    "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
507
                    "\n\n\nPlease do not reply to this email\n"+
508
                    "This message has been generated manually\n\n"+
509
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
510
                    "Regards,\n" +
511
                    "the OpenAIRE technical team\n";
512

  
513
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
514

  
515
        } catch (Exception e) {
516
            LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
517
            throw e;
518
        }
519
    }
520

  
521
    @Override
522
    public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
523
        try {
524
            String subject = "OpenAIRE validator - Test results ";
525

  
526
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
527
            String message = "Dear user,\n" +
528
                    "\n" +
529
                    "the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
530
                    "Please do not reply to this message.\n" +
531
                    "This message has been generated automatically.\n" +
532
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
533
                    "Regards,\n" +
534
                    "the OpenAIRE technical team\n";
535

  
536
            this.sendMail(issuer, subject, message, false, null);
537

  
538
        } catch (Exception e) {
539
            LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
540
            throw e;
541
        }
542
    }
543

  
544
    @Override
545
    public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
546
        try {
547
            String subject = "OpenAIRE validator - Test results ";
548

  
549
            String message = "Dear admin,\n" +
550
                    "\n" +
551
                    "the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" +
552
                    "\n\nUser Contact:"+ issuer +""+
553
                    "Please do not reply to this message.\n" +
554
                    "This message has been generated automatically.\n" +
555
                    "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" +
556
                    "Regards,\n" +
557
                    "the OpenAIRE technical team\n";
558

  
559
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
560

  
561
        } catch (Exception e) {
562
            LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
563
            throw e;
564
        }
565
    }
566

  
567
    @Override
568
    public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception {
569
        try {
570
            String subject = "OpenAIRE validator - job failure";
571

  
572
            String message = "Dear admin,\n" +
573
                    "\n" +
574
                    "the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseUrl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialName()+") failed to complete." +
575
                    "This message has been generated automatically.\n\n" +
576
                    "Regards,\n" +
577
                    "the OpenAIRE technical team\n";
578

  
579
            this.sendMail(this.provideAdminEmail, subject, message, false, null);
580

  
581
        } catch (Exception e) {
582
            LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e);
583
            throw e;
584
        }
585
    }
586

  
587
    @Override
250 588
    public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception {
251 589
        try {
252 590
            String subject = "OpenAIRE content provider update request started for " +
......
275 613
            String subject = "OpenAIRE content provider update request started for " +
276 614
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
277 615

  
278
            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
616
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
617
            String message = "Dear user,\n" +
279 618
                    "\n" +
280 619
                    "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." +
281 620
                    "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" +
......
298 637
        try {
299 638
            String subject = "OpenAIRE validator - Test submission ";
300 639

  
301
            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
640
            //            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
641
            String message = "Dear user,\n" +
302 642
                    "\n" +
303 643
                    "The validation request you have submitted has started.\n" +
304 644
                    "Please do not reply to this message.\n" +
......
315 655
        }
316 656
    }
317 657

  
658
    @Override
659
    public void sendUponJobCompletion(
660
            String repoId,
661
            String repoInterfaceId,
662
            int scoreUsage,
663
            int scoreContent,
664
            boolean isSuccess,
665
            boolean isUpdate,
666
            String issuerEmail,
667
            String jobId) throws Exception {
668
        List<RepositoryInterface> repositoryInterfaces = repositoryService.getRepositoryInterface(repoId);
669
        if(repositoryInterfaces.size()==0)
670
            throw new ValidationServiceException("Repository interface with id \""+repoInterfaceId+"\" not found",ValidationServiceException.ErrorCode.GENERAL_ERROR);
671

  
672
        RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter( repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0);
673
        Repository repository = repositoryService.getRepositoryById(repoId);
674

  
675
        if(!isUpdate){
676
            if(isSuccess){
677
                if(scoreContent>=50 && scoreUsage >= 50){
678
                    this.sendUserRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
679
                    this.sendAdminRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
680
                }else{
681
                    this.sendUserRegistrationResultsFailureEmail(jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
682
                    this.sendAdminRegistrationResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
683
                }
684
            }else{
685
                this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
686
            }
687
        }else{
688
            if(isSuccess){
689
                if(scoreContent>=50 && scoreUsage >= 50){
690
                    this.sendUserUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
691
                    this.sendAdminUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
692
                }else{
693
                    this.sendUserUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
694
                    this.sendAdminUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication());
695
                }
696
            }else{
697
                this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication());
698
            }
699
        }
700

  
701
    }
702

  
703

  
318 704
    private void sendMail(String email, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
319 705
        ArrayList<String> to = new ArrayList<String>();
320 706
        to.add(email);
321 707
        this.sendMail(to,subject,message,sendToSpecial,repoAdminMails);
322 708
    }
323 709

  
324
    private void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
710
    public void sendMail(List<String> recipients, String subject, String message, boolean sendToSpecial, List<String> repoAdminMails) throws Exception {
325 711

  
326 712
        try {
327 713
            if (sendToSpecial) {
......
383 769
        this.logonly = logonly;
384 770
    }
385 771

  
386

  
387 772
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/ValidatorController.java
1 1
package eu.dnetlib.repo.manager.controllers;
2 2

  
3 3
import eu.dnetlib.api.functionality.ValidatorServiceException;
4
import eu.dnetlib.domain.data.RepositoryInterface;
4 5
import eu.dnetlib.domain.functionality.validator.StoredJob;
6
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
7
import eu.dnetlib.repo.manager.service.EmailUtils;
8
import eu.dnetlib.repo.manager.service.RepositoryService;
5 9
import eu.dnetlib.repo.manager.service.ValidatorServiceImpl;
6 10
import eu.dnetlib.repo.manager.shared.InterfaceInformation;
7 11
import eu.dnetlib.repo.manager.shared.ValidationServiceException;
......
28 32
    @Autowired
29 33
    private ValidatorServiceImpl validatorService;
30 34

  
35
    @Autowired
36
    private EmailUtils emailUtils;
37

  
31 38
    @RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
32 39
            consumes = MediaType.APPLICATION_JSON_VALUE,
33 40
            produces = MediaType.APPLICATION_JSON_VALUE)
......
94 101

  
95 102
    @RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
96 103
    @ResponseBody
97
    public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
104
    public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
98 105
        return validatorService.getInterfaceInformation(baseUrl);
99 106
    }
100 107

  
101 108

  
109
    @RequestMapping(value = "/complete" , method = RequestMethod.POST,  produces = MediaType.APPLICATION_JSON_VALUE)
110
    @ResponseBody
111
    public void validationCompleted(
112
        @RequestParam(value = "interfaceId") String interfaceId,
113
        @RequestParam(value = "repoId") String repoId,
114
        @RequestParam(value = "jobId") String jobId,
115
        @RequestParam(value = "issuerEmail") String issuerEmail,
116
        @RequestParam(value = "isUpdate") boolean isUpdate,
117
        @RequestParam(value = "isSuccess") boolean isSuccess,
118
        @RequestParam(value = "scoreUsage") int scoreUsage,
119
        @RequestParam(value = "scoreContent") int scoreContent) throws Exception {
120

  
121
        emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
122
    }
123

  
124

  
102 125
}
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/applicationContext.xml
55 55
                <value>classpath*:/application.properties</value>
56 56
                <value>classpath*:/email-texts.properties</value>
57 57

  
58
                <value>classpath*:dnet-site-wizard.properties</value>
59
                <value>classpath*:dnet-site-override.properties</value>
60
                <value>classpath*:dnet-wizard.properties</value>
61
                <value>classpath*:dnet-override.properties</value>
62
                <value>classpath*:dnet-validator-wizard.properties</value>
63
                <value>classpath*:dnet-validator-override.properties</value>
64
                <value>classpath*:dnet-site-force-override.properties</value>
65
                <value>classpath*:dnet-force-override.properties</value>
58
<!--                <value>classpath*:dnet-site-wizard.properties</value>-->
59
<!--                <value>classpath*:dnet-site-override.properties</value>-->
60
<!--                <value>classpath*:dnet-wizard.properties</value>-->
61
<!--                <value>classpath*:dnet-override.properties</value>-->
62
<!--                <value>classpath*:dnet-validator-wizard.properties</value>-->
63
<!--                <value>classpath*:dnet-validator-override.properties</value>-->
64
<!--                <value>classpath*:dnet-site-force-override.properties</value>-->
65
<!--                <value>classpath*:dnet-force-override.properties</value>-->
66 66
            </list>
67 67
        </property>
68 68
    </bean>
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/log4j.properties
1 1
log4j.rootLogger = WARN, R
2 2

  
3
log4j.logger.eu.dnetlib = DEBUG
3
log4j.logger.eu.dnetlib = INFO
4
log4j.logger.eu.dnetlib.repo.manager = INFO
4 5
log4j.logger.eu.dnetlib.clients.data.datasourcemanager.ws.Converter = FATAL
5
log4j.logger.org.springframework = INFO, S
6
log4j.additivity.org.springframework = false
7 6

  
8 7
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL
9 8
log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL
10 9

  
11
log4j.logger.eu.dnetlib.repo.manager=DEBUG
12

  
13 10
log4j.appender.R=org.apache.log4j.RollingFileAppender
14 11
log4j.appender.R.File=/tmp/repository-service.log
15 12
#log4j.appender.R.File=/var/log/tomcat_dnet/8780/repository-service.log
......
24 21
log4j.appender.S.MaxFileSize=10MB
25 22
log4j.appender.S.MaxBackupIndex=10
26 23
log4j.appender.S.layout=org.apache.log4j.PatternLayout
27
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
28

  
29
#log4j.rootLogger = WARN, R
30
#
31
#log4j.logger.org.springframework = DEBUG, S
32
#log4j.additivity.org.springframework = false
33
#
34
#log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL
35
#log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL
36
#
37
#log4j.logger.eu.dnetlib.repo.manager=DEBUG
38
#
39
#log4j.appender.R=org.apache.log4j.ConsoleAppender
40
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
41
#log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
42
#
43
#log4j.appender.S=org.apache.log4j.ConsoleAppender
44
#log4j.appender.S.layout=org.apache.log4j.PatternLayout
45
#log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
24
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n
modules/uoa-repository-manager-service/trunk/src/main/webapp/WEB-INF/web.xml
6 6
    </listener>
7 7
    <listener>
8 8
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
9
        <!-- TODO: import correct dependency -->
10
<!--        <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>-->
9 11
    </listener>
10 12

  
11 13
    <context-param>

Also available in: Unified diff