Revision 59190
Added by Antonis Lempesis over 3 years ago
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.service; |
2 | 2 |
|
3 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
4 | 3 |
import eu.dnetlib.domain.data.Repository; |
5 | 4 |
import eu.dnetlib.domain.data.RepositoryInterface; |
6 | 5 |
import eu.dnetlib.repo.manager.domain.*; |
... | ... | |
48 | 47 |
RepositoryInterface addRepositoryInterface(String datatype, |
49 | 48 |
String repoId, |
50 | 49 |
String registeredBy, |
51 |
RepositoryInterface iFace) throws Exception;
|
|
50 |
String comment, RepositoryInterface repositoryInterface) throws Exception;
|
|
52 | 51 |
|
53 | 52 |
List<String> getDnetCountries(); |
54 | 53 |
|
... | ... | |
74 | 73 |
|
75 | 74 |
Map<String, String> getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException; |
76 | 75 |
|
77 |
RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception;
|
|
76 |
RepositoryInterface updateRepositoryInterface(String repoId, String registeredBy, String comment, RepositoryInterface repositoryInterface) throws Exception;
|
|
78 | 77 |
|
79 | 78 |
} |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception; |
26 | 26 |
|
27 |
void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
27 |
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
|
28 | 28 |
|
29 |
void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
29 |
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
|
30 | 30 |
|
31 | 31 |
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/ |
32 | 32 |
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; |
... | ... | |
61 | 61 |
|
62 | 62 |
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication) throws Exception; |
63 | 63 |
|
64 |
void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
64 |
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
|
65 | 65 |
|
66 |
void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception; |
|
66 |
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception;
|
|
67 | 67 |
|
68 | 68 |
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception; |
69 | 69 |
|
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java | ||
---|---|---|
552 | 552 |
public RepositoryInterface addRepositoryInterface(String datatype, |
553 | 553 |
String repoId, |
554 | 554 |
String registeredBy, |
555 |
RepositoryInterface repositoryInterface) throws Exception { |
|
555 |
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
|
556 | 556 |
try { |
557 | 557 |
Repository e = this.getRepositoryById(repoId); |
558 | 558 |
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype); |
... | ... | |
568 | 568 |
|
569 | 569 |
ResponseEntity responseEntity = restTemplate.postForObject(uriComponents.toUri(),httpEntity,ResponseEntity.class); |
570 | 570 |
|
571 |
if(responseEntity.getStatusCode().equals(HttpStatus.OK)) { |
|
572 |
emailUtils.sendAdminRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); |
|
573 |
emailUtils.sendUserRegisterInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); |
|
571 |
if (responseEntity.getStatusCode().equals(HttpStatus.OK)) {
|
|
572 |
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
|
573 |
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
|
574 | 574 |
|
575 | 575 |
submitInterfaceValidation(e, registeredBy, repositoryInterface, false); |
576 | 576 |
return repositoryInterface; |
... | ... | |
589 | 589 |
@Override |
590 | 590 |
public RepositoryInterface updateRepositoryInterface(String repoId, |
591 | 591 |
String registeredBy, |
592 |
RepositoryInterface repositoryInterface) throws Exception { |
|
592 |
String comment, RepositoryInterface repositoryInterface) throws Exception {
|
|
593 | 593 |
|
594 | 594 |
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl()); |
595 | 595 |
this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance()); |
596 | 596 |
this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet()); |
597 | 597 |
|
598 | 598 |
Repository e = this.getRepositoryById(repoId); |
599 |
emailUtils.sendAdminUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); |
|
600 |
emailUtils.sendUserUpdateInterfaceEmail(e, repositoryInterface, SecurityContextHolder.getContext().getAuthentication()); |
|
599 |
emailUtils.sendAdminUpdateInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
|
600 |
emailUtils.sendUserUpdateInterfaceEmail(e, comment, repositoryInterface, SecurityContextHolder.getContext().getAuthentication());
|
|
601 | 601 |
submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true); |
602 | 602 |
|
603 | 603 |
return repositoryInterface; |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java | ||
---|---|---|
256 | 256 |
} |
257 | 257 |
|
258 | 258 |
@Override |
259 |
public void sendAdminRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception { |
|
259 |
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
|
260 | 260 |
try { |
261 | 261 |
String subject = "OpenAIRE new interface registration request started for " + |
262 | 262 |
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; |
... | ... | |
267 | 267 |
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" + |
268 | 268 |
"Set: " + repositoryInterface.getAccessSet() + "\n" + |
269 | 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 " + |
|
270 |
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n"; |
|
271 |
|
|
272 |
if (comment != null) |
|
273 |
comment += "\nThe users comment was '" + comment + "'\n"; |
|
274 |
|
|
275 |
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " + |
|
272 | 276 |
"has been started. You will be informed in another message once the process is finished." + |
273 | 277 |
"\n\n" + |
274 | 278 |
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" + |
... | ... | |
287 | 291 |
} |
288 | 292 |
|
289 | 293 |
@Override |
290 |
public void sendUserRegisterInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception { |
|
294 |
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
|
291 | 295 |
try { |
292 | 296 |
String subject = "OpenAIRE new interface registration request started for " + |
293 | 297 |
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; |
294 |
|
|
295 |
// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + |
|
298 |
|
|
296 | 299 |
String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" + |
297 | 300 |
"\n" + |
298 | 301 |
"We received a request to add the following interface: \n\n" + |
299 | 302 |
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" + |
300 | 303 |
"Set: " + repositoryInterface.getAccessSet() + "\n" + |
301 | 304 |
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" + |
302 |
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" + |
|
303 |
"A validation process for this interface against the OpenAIRE guidelines compatibility " + |
|
305 |
"to " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n"; |
|
306 |
|
|
307 |
if (comment != null) { |
|
308 |
comment += "\n Your comment was '" + comment + "'\n"; |
|
309 |
} |
|
310 |
|
|
311 |
message += "A validation process for this interface against the OpenAIRE guidelines compatibility " + |
|
304 | 312 |
"has been started. You will be informed in another message once the process is finished." + |
305 | 313 |
"\n\n" + |
306 | 314 |
"Please do not reply to this message\n" + |
... | ... | |
688 | 696 |
} |
689 | 697 |
|
690 | 698 |
@Override |
691 |
public void sendAdminUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception { |
|
699 |
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
|
692 | 700 |
try { |
693 | 701 |
String subject = "OpenAIRE interface update request started for " + |
694 | 702 |
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; |
... | ... | |
699 | 707 |
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" + |
700 | 708 |
"Set: " + repositoryInterface.getAccessSet() + "\n" + |
701 | 709 |
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" + |
702 |
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" + |
|
703 |
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + |
|
710 |
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n"; |
|
711 |
|
|
712 |
if (comment != null) |
|
713 |
comment += "\nThe users comment was '" + comment + "'\n"; |
|
714 |
|
|
715 |
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + |
|
704 | 716 |
"User Contact: " + authentication.getName() + " (" + ((OIDCAuthenticationToken) authentication).getUserInfo().getEmail() + ")" + |
705 | 717 |
"\n\n" + |
706 | 718 |
"Please do not reply to this message\n" + |
... | ... | |
717 | 729 |
} |
718 | 730 |
|
719 | 731 |
@Override |
720 |
public void sendUserUpdateInterfaceEmail(Repository repository, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception { |
|
732 |
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) throws Exception {
|
|
721 | 733 |
try { |
722 | 734 |
String subject = "OpenAIRE interface update request started for " + |
723 | 735 |
repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; |
... | ... | |
729 | 741 |
"Base URL: " + repositoryInterface.getBaseUrl() + "\n" + |
730 | 742 |
"Set: " + repositoryInterface.getAccessSet() + "\n" + |
731 | 743 |
"Guidelines: " + repositoryInterface.getDesiredCompatibilityLevel() + "\n\n" + |
732 |
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n" + |
|
733 |
"A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + |
|
744 |
"for " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "].\n"; |
|
745 |
|
|
746 |
if (comment != null) { |
|
747 |
comment += "\n Your comment was '" + comment + "'\n"; |
|
748 |
} |
|
749 |
|
|
750 |
message += "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + |
|
734 | 751 |
"Please do not reply to this message\n" + |
735 | 752 |
"This message has been generated automatically.\n\n" + |
736 | 753 |
"If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + |
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java | ||
---|---|---|
170 | 170 |
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype, |
171 | 171 |
@RequestParam("repoId") String repoId, |
172 | 172 |
@RequestParam("registeredBy") String registeredBy, |
173 |
@RequestParam("comment") String comment, |
|
173 | 174 |
@RequestBody RepositoryInterface repositoryInterface) throws Exception { |
174 |
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface); |
|
175 |
return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, comment, repositoryInterface);
|
|
175 | 176 |
} |
176 | 177 |
|
177 | 178 |
@RequestMapping(value = "/getUrlsOfUserRepos/{page}/{size}/",method = RequestMethod.GET, |
... | ... | |
226 | 227 |
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))") |
227 | 228 |
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId, |
228 | 229 |
@RequestParam("registeredBy") String registeredBy, |
230 |
@RequestParam("comment") String comment, |
|
229 | 231 |
@RequestBody RepositoryInterface repositoryInterface) throws Exception { |
230 |
return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface); |
|
232 |
return repositoryService.updateRepositoryInterface(repoId, registeredBy, comment, repositoryInterface);
|
|
231 | 233 |
} |
232 | 234 |
} |
Also available in: Unified diff
added the option to send emails to users