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 |
}
|
fixing from & quantity values for export-to-csv functionality