1. refactored method signatures
2. used desired compatibility level for 'Guidelines' field in emails
3. enabled async error logs
This commit is contained in:
Konstantinos Spyrou 2023-01-30 18:56:34 +02:00
parent de2ac5631f
commit d3bcea79c0
8 changed files with 94 additions and 89 deletions

View File

@ -20,7 +20,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
@Override @Override
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) { public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
//logger.error("Async error", throwable); logger.error("Async error", throwable);
} }
}; };
} }

View File

@ -26,7 +26,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -63,7 +62,7 @@ public class RepositoryController {
@ResponseBody @ResponseBody
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country, public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
@PathVariable("mode") String mode, @PathVariable("mode") String mode,
@RequestParam(value = "managed", required = false) Boolean managed) throws JSONException, IOException { @RequestParam(value = "managed", required = false) Boolean managed) {
return repositoryService.getRepositoriesByCountry(country, mode, managed); return repositoryService.getRepositoriesByCountry(country, mode, managed);
} }
@ -83,7 +82,7 @@ public class RepositoryController {
public void updateRepositoriesTerms(@RequestBody List<RepositoryTerms> repositoriesTerms) throws Exception { public void updateRepositoriesTerms(@RequestBody List<RepositoryTerms> repositoriesTerms) throws Exception {
Date date = new Date(); Date date = new Date();
if (repositoriesTerms != null) { if (repositoriesTerms != null) {
for (RepositoryTerms terms : repositoriesTerms) { for (RepositoryTerms terms : repositoriesTerms) {
Repository repository = repositoryService.getRepositoryById(terms.getId()); Repository repository = repositoryService.getRepositoryById(terms.getId());
repository.setConsentTermsOfUse(terms.getConsentTermsOfUse()); repository.setConsentTermsOfUse(terms.getConsentTermsOfUse());
repository.setFullTextDownload(terms.getFullTextDownload()); repository.setFullTextDownload(terms.getFullTextDownload());
@ -104,7 +103,7 @@ public class RepositoryController {
@RequestParam("requestSortBy") String requestSortBy, @RequestParam("requestSortBy") String requestSortBy,
@RequestParam("order") String order, @RequestParam("order") String order,
@PathVariable("page") int page, @PathVariable("page") int page,
@PathVariable("size") int pageSize) throws Exception { @PathVariable("size") int pageSize) {
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize); return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
} }
@ -113,13 +112,13 @@ public class RepositoryController {
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
@PostAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredby==null and hasAuthority('REGISTERED_USER'))") @PostAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredby==null and hasAuthority('REGISTERED_USER'))")
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException, ResourceNotFoundException { public Repository getRepositoryById(@PathVariable("id") String id) throws ResourceNotFoundException {
Repository repo = repositoryService.getRepositoryById(id); Repository repo = repositoryService.getRepositoryById(id);
if (repo != null) if (repo != null)
logger.info("Returning repository " + repo.getId() + " registered by " + repo.getRegisteredby()); logger.info("Returning repository {} registered by {}", repo.getId(), repo.getRegisteredby());
else else
logger.info("Requested repository " + id + " not found"); logger.info("Requested repository {} not found", id);
return repo; return repo;
} }
@ -142,7 +141,7 @@ public class RepositoryController {
@ResponseBody @ResponseBody
public List<Repository> getRepositoriesByName(@PathVariable("name") String name, public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
@PathVariable("page") String page, @PathVariable("page") String page,
@PathVariable("size") String size) throws JSONException { @PathVariable("size") String size) {
return repositoryService.getRepositoriesByName(name, page, size); return repositoryService.getRepositoriesByName(name, page, size);
} }
@ -150,7 +149,7 @@ public class RepositoryController {
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
@PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredby==null and hasAuthority('REGISTERED_USER'))") @PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredby==null and hasAuthority('REGISTERED_USER'))")
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException { public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) {
return repositoryService.getRepositoryInterface(id); return repositoryService.getRepositoryInterface(id);
} }
@ -160,7 +159,7 @@ public class RepositoryController {
// @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))") // @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')") @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')")
public Repository addRepository(@RequestParam("datatype") String datatype, public Repository addRepository(@RequestParam("datatype") String datatype,
@RequestBody Repository repository) throws Exception { @RequestBody Repository repository) {
return repositoryService.addRepository(datatype, repository); return repositoryService.addRepository(datatype, repository);
} }
@ -193,7 +192,7 @@ public class RepositoryController {
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)") @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) throws Exception { public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) {
return repositoryService.updateRepository(repository, authentication); return repositoryService.updateRepository(repository, authentication);
} }
@ -261,7 +260,7 @@ public class RepositoryController {
@RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET, @RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException { public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) {
return repositoryService.getListLatestUpdate(mode); return repositoryService.getListLatestUpdate(mode);
} }

View File

@ -32,38 +32,38 @@ public interface EmailUtils {
void sendUserRegistrationEmail(Repository repository, Authentication authentication); void sendUserRegistrationEmail(Repository repository, Authentication authentication);
@Async @Async
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication); void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
@Async @Async
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication); void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/ /****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
@Async @Async
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
@Async @Async
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
/****FAILURE REGISTRATION RESULTS EMAILS****/ /****FAILURE REGISTRATION RESULTS EMAILS****/
@Async @Async
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
@Async @Async
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
/****SUCCESSFUL UPDATE RESULTS EMAILS****/ /****SUCCESSFUL UPDATE RESULTS EMAILS****/
@Async @Async
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
@Async @Async
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
/****FAILURE UPDATE RESULTS EMAILS****/ /****FAILURE UPDATE RESULTS EMAILS****/
@Async @Async
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
@Async @Async
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication); void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
/****FAILURE UPDATE INTERFACE COMPLIANCE****/ /****FAILURE UPDATE INTERFACE COMPLIANCE****/
@Async @Async
@ -91,10 +91,10 @@ public interface EmailUtils {
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication); void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
@Async @Async
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication); void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
@Async @Async
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication); void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
@Async @Async
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation); void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
@ -102,6 +102,7 @@ public interface EmailUtils {
@Async @Async
void sendUponJobCompletion(String repoId, void sendUponJobCompletion(String repoId,
String repoInterfaceId, String repoInterfaceId,
String compatibility,
int scoreUsage, int scoreUsage,
int scoreContent, int scoreContent,
boolean isSuccess, boolean isSuccess,

View File

@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -21,6 +22,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component("emailUtils") @Component("emailUtils")
@Async
public class EmailUtilsImpl implements EmailUtils { public class EmailUtilsImpl implements EmailUtils {
private final static Logger logger = LoggerFactory.getLogger(EmailUtilsImpl.class); private final static Logger logger = LoggerFactory.getLogger(EmailUtilsImpl.class);
@ -203,7 +205,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) { public void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request started for " + String subject = "OpenAIRE new interface registration request started for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -212,7 +214,7 @@ public class EmailUtilsImpl implements EmailUtils {
"We received a request to add the following interface: \n\n" + "We received a request to add the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" + "Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" + "Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" + "Guidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n"; "to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) if (comment != null)
@ -235,7 +237,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) { public void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request started for " + String subject = "OpenAIRE new interface registration request started for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -243,7 +245,7 @@ public class EmailUtilsImpl implements EmailUtils {
"We received a request to add the following interface: \n\n" + "We received a request to add the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" + "Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" + "Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" + "Guidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() + "\n\n" +
"to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n"; "to " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) { if (comment != null) {
@ -265,7 +267,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request - results (success) for " + String subject = "OpenAIRE new interface registration request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -279,7 +281,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
"This message has been generated manually\n\n" + "This message has been generated manually\n\n" +
@ -294,7 +296,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request - results (success) for " + String subject = "OpenAIRE new interface registration request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -308,7 +310,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nDesired Guidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nUser Contact:" + issuerEmail + "" + "\n\nUser Contact:" + issuerEmail + "" +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
@ -324,7 +326,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request - results (failure) for " + String subject = "OpenAIRE new interface registration request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -337,7 +339,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
"This message has been generated manually\n\n" + "This message has been generated manually\n\n" +
@ -352,7 +354,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE new interface registration request - results (failure) for " + String subject = "OpenAIRE new interface registration request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -366,7 +368,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nUser Contact:" + issuerEmail + "" + "\n\nUser Contact:" + issuerEmail + "" +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
@ -382,7 +384,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request - results (success) for " + String subject = "OpenAIRE interface update request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -394,7 +396,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
"This message has been generated manually\n\n" + "This message has been generated manually\n\n" +
@ -409,7 +411,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request - results (success) for " + String subject = "OpenAIRE interface update request - results (success) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -421,7 +423,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nUser Contact:" + issuerEmail + "" + "\n\nUser Contact:" + issuerEmail + "" +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
@ -437,7 +439,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request - results (failure) for " + String subject = "OpenAIRE interface update request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -451,7 +453,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
"This message has been generated manually\n\n" + "This message has been generated manually\n\n" +
@ -466,7 +468,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) { public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request - results (failure) for " + String subject = "OpenAIRE interface update request - results (failure) for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -480,7 +482,7 @@ public class EmailUtilsImpl implements EmailUtils {
"\nOfficial Name:" + repository.getOfficialname() + "\nOfficial Name:" + repository.getOfficialname() +
"\n\nBase URL: " + repositoryInterface.getBaseurl() + "\n\nBase URL: " + repositoryInterface.getBaseurl() +
"\n\nValidation Set: " + repositoryInterface.getAccessSet() + "\n\nValidation Set: " + repositoryInterface.getAccessSet() +
"\n\nGuidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\nGuidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() +
"\n\nUser Contact:" + issuerEmail + "" + "\n\nUser Contact:" + issuerEmail + "" +
"\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId +
"\n\n\nPlease do not reply to this email\n" + "\n\n\nPlease do not reply to this email\n" +
@ -596,8 +598,11 @@ public class EmailUtilsImpl implements EmailUtils {
String subject = "OpenAIRE validator - job failure"; String subject = "OpenAIRE validator - job failure";
String message = String message =
"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." + "the validation job that was automatically submitted for the update/registration of the interface "
"This message has been generated automatically."; + repositoryInterface.getId() + " (" + repositoryInterface.getBaseurl() + ", "
+ repositoryInterface.getAccessSet() + ") of the repository " + repository.getId()
+ " (" + repository.getOfficialname() + ") failed to complete."
+ "This message has been generated automatically.";
message = createAdminMail(message); message = createAdminMail(message);
this.sendMail(this.provideAdminEmail, subject, message); this.sendMail(this.provideAdminEmail, subject, message);
@ -614,7 +619,8 @@ public class EmailUtilsImpl implements EmailUtils {
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
String message = String message =
"We received a request to update the basic information for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n\n" + "We received a request to update the basic information for " + repository.getEoscDatasourceType()
+ "[" + repository.getOfficialname() + "].\n\n" +
"Please do not reply to this message\n" + "Please do not reply to this message\n" +
"This message has been generated automatically."; "This message has been generated automatically.";
message = createAdminMail(message); message = createAdminMail(message);
@ -647,7 +653,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) { public void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request started for " + String subject = "OpenAIRE interface update request started for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -656,7 +662,7 @@ public class EmailUtilsImpl implements EmailUtils {
"We received a request to update the following interface: \n\n" + "We received a request to update the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" + "Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" + "Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" + "Guidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n"; "for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) if (comment != null)
@ -677,7 +683,7 @@ public class EmailUtilsImpl implements EmailUtils {
} }
@Override @Override
public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication) { public void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication) {
try { try {
String subject = "OpenAIRE interface update request started for " + String subject = "OpenAIRE interface update request started for " +
repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]"; repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "]";
@ -686,7 +692,7 @@ public class EmailUtilsImpl implements EmailUtils {
"We received a request to update the following interface: \n\n" + "We received a request to update the following interface: \n\n" +
"Base URL: " + repositoryInterface.getBaseurl() + "\n" + "Base URL: " + repositoryInterface.getBaseurl() + "\n" +
"Set: " + repositoryInterface.getAccessSet() + "\n" + "Set: " + repositoryInterface.getAccessSet() + "\n" +
"Guidelines: " + repositoryInterface.getCompatibilityOverride() + "\n\n" + "Guidelines: " + desiredCompatibility != null ? desiredCompatibility : repositoryInterface.getCompatibility() + "\n\n" +
"for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n"; "for " + repository.getEoscDatasourceType() + "[" + repository.getOfficialname() + "].\n";
if (comment != null) { if (comment != null) {
@ -729,6 +735,7 @@ public class EmailUtilsImpl implements EmailUtils {
public void sendUponJobCompletion( public void sendUponJobCompletion(
String repoId, String repoId,
String repoInterfaceId, String repoInterfaceId,
String compatibility,
int scoreUsage, int scoreUsage,
int scoreContent, int scoreContent,
boolean isSuccess, boolean isSuccess,
@ -745,11 +752,11 @@ public class EmailUtilsImpl implements EmailUtils {
if (!isUpdate) { if (!isUpdate) {
if (isSuccess) { if (isSuccess) {
if (scoreContent >= 50 && scoreUsage >= 50) { if (scoreContent >= 50 && scoreUsage >= 50) {
this.sendUserRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendUserRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminRegistrationResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
} else { } else {
this.sendUserRegistrationResultsFailureEmail(jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendUserRegistrationResultsFailureEmail(jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminRegistrationResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminRegistrationResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
} }
} else { } else {
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());
@ -757,11 +764,11 @@ public class EmailUtilsImpl implements EmailUtils {
} else { } else {
if (isSuccess) { if (isSuccess) {
if (scoreContent >= 50 && scoreUsage >= 50) { if (scoreContent >= 50 && scoreUsage >= 50) {
this.sendUserUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendUserUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminUpdateResultsSuccessEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
} else { } else {
this.sendUserUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendUserUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
this.sendAdminUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminUpdateResultsFailureEmail(issuerEmail, jobId, repositoryInterface, compatibility, repository, SecurityContextHolder.getContext().getAuthentication());
} }
} else { } else {
this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication()); this.sendAdminGeneralFailure(issuerEmail, jobId, repositoryInterface, repository, SecurityContextHolder.getContext().getAuthentication());

View File

@ -6,7 +6,6 @@ import eu.dnetlib.repo.manager.exception.ResourceConflictException;
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository; import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
import eu.dnetlib.repo.manager.service.security.AuthorizationService; import eu.dnetlib.repo.manager.service.security.AuthorizationService;
import org.json.JSONException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -50,7 +49,7 @@ public class InterfaceComplianceService {
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId()); List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request); emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request); emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
} catch (JSONException | ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
logger.error("Error", e); logger.error("Error", e);
} }
} }

View File

@ -16,15 +16,15 @@ public interface RepositoryService {
// TODO: move this elsewhere // TODO: move this elsewhere
Country[] getCountries(); Country[] getCountries();
List<Repository> getRepositories(List<String> ids) throws JSONException; List<Repository> getRepositories(List<String> ids);
List<Repository> getRepositories(List<String> ids, int page, int size) throws JSONException; List<Repository> getRepositories(List<String> ids, int page, int size);
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception; List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception;
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception; List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception;
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException; List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed);
// TODO: remove? // TODO: remove?
List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException, IOException; List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException, IOException;
@ -38,23 +38,23 @@ public interface RepositoryService {
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception; List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception;
RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException; RepositorySnippet getRepositorySnippetById(String id) throws ResourceNotFoundException;
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException; Repository getRepositoryById(String id) throws ResourceNotFoundException;
List<Repository> getRepositoriesByName(String name, List<Repository> getRepositoriesByName(String name,
String page, String page,
String size) throws JSONException; String size);
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName, List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
String officialName, String requestSortBy, String order, String officialName, String requestSortBy, String order,
int page, int pageSize) throws Exception; int page, int pageSize);
Integer getTotalRegisteredRepositories(); Integer getTotalRegisteredRepositories();
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException; List<RepositoryInterface> getRepositoryInterface(String id);
Repository addRepository(String datatype, Repository repository) throws Exception; Repository addRepository(String datatype, Repository repository);
void deleteRepositoryInterface(String id, String registeredBy); void deleteRepositoryInterface(String id, String registeredBy);
@ -70,7 +70,7 @@ public interface RepositoryService {
List<Timezone> getTimezones(); List<Timezone> getTimezones();
Repository updateRepository(Repository repository, Authentication authentication) throws Exception; Repository updateRepository(Repository repository, Authentication authentication);
List<String> getUrlsOfUserRepos(String user_email, List<String> getUrlsOfUserRepos(String user_email,
String page, String page,

View File

@ -21,7 +21,6 @@ import eu.dnetlib.repo.manager.utils.Converter;
import eu.dnetlib.repo.manager.utils.DateUtils; import eu.dnetlib.repo.manager.utils.DateUtils;
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.json.JSONException;
import org.mitre.openid.connect.model.OIDCAuthenticationToken; import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -40,7 +39,6 @@ import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.IOException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -92,7 +90,6 @@ public class RepositoryServiceImpl implements RepositoryService {
VocabularyLoader vocabularyLoader, VocabularyLoader vocabularyLoader,
RestTemplate restTemplate, RestTemplate restTemplate,
ObjectMapper objectMapper, ObjectMapper objectMapper,
// Converter converter,
@Lazy EmailUtils emailUtils, @Lazy EmailUtils emailUtils,
@Lazy ValidatorService validatorService, @Lazy ValidatorService validatorService,
@Lazy PiWikService piWikService, @Lazy PiWikService piWikService,
@ -161,7 +158,7 @@ public class RepositoryServiceImpl implements RepositoryService {
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus, // and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
// another way for paging must be implemented. // another way for paging must be implemented.
@Override @Override
public List<Repository> getRepositories(List<String> ids) throws JSONException { public List<Repository> getRepositories(List<String> ids) {
return getRepositories(ids, 0, 10); return getRepositories(ids, 0, 10);
} }
@ -233,7 +230,7 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override @Override
public List<RepositorySnippet> getRepositoriesByCountry(String country, public List<RepositorySnippet> getRepositoriesByCountry(String country,
String mode, String mode,
Boolean managed) throws IOException { Boolean managed) {
logger.debug("Getting repositories by country!"); logger.debug("Getting repositories by country!");
int page = 0; int page = 0;
int size = 100; int size = 100;
@ -256,7 +253,7 @@ public class RepositoryServiceImpl implements RepositoryService {
} }
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName, public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception { String officialName, String requestSortBy, String order, int page, int pageSize) {
logger.debug("Searching registered repositories"); logger.debug("Searching registered repositories");
@ -289,7 +286,7 @@ public class RepositoryServiceImpl implements RepositoryService {
} }
@Override @Override
public List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException { public List<Repository> getRepositoriesOfUser(String page, String size) {
logger.debug("Retrieving repositories of authenticated user : {}", logger.debug("Retrieving repositories of authenticated user : {}",
((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail()); ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles()); Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
@ -297,7 +294,7 @@ public class RepositoryServiceImpl implements RepositoryService {
} }
@Override @Override
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) throws JSONException { public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) {
logger.debug("Retrieving repositories of authenticated user : {}", userEmail); logger.debug("Retrieving repositories of authenticated user : {}", userEmail);
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail)); Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail));
return getRepositories(new ArrayList<>(repoIds)); return getRepositories(new ArrayList<>(repoIds));
@ -363,7 +360,7 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override @Override
public List<Repository> getRepositoriesByName(String name, public List<Repository> getRepositoriesByName(String name,
String page, String page,
String size) throws JSONException { String size) {
logger.debug("Retrieving repositories with official name : {}", name); logger.debug("Retrieving repositories with official name : {}", name);
UriComponents uriComponents = searchDatasourceUri("0", "100"); UriComponents uriComponents = searchDatasourceUri("0", "100");
@ -402,7 +399,7 @@ public class RepositoryServiceImpl implements RepositoryService {
} }
@Override @Override
public Repository addRepository(String datatype, Repository repository) throws Exception { public Repository addRepository(String datatype, Repository repository) {
logger.debug("storing '{}' repository with id: {}", datatype, repository.getId()); logger.debug("storing '{}' repository with id: {}", datatype, repository.getId());
@ -486,7 +483,7 @@ public class RepositoryServiceImpl implements RepositoryService {
} }
@Override @Override
public Repository updateRepository(Repository repository, Authentication authentication) throws Exception { public Repository updateRepository(Repository repository, Authentication authentication) {
UriComponents uriComponents = UriComponentsBuilder UriComponents uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/update/") .fromHttpUrl(baseAddress + "/ds/update/")
.build() .build()
@ -507,7 +504,7 @@ public class RepositoryServiceImpl implements RepositoryService {
return repository; return repository;
} }
private void storeRepository(Repository repository, Authentication authentication) throws Exception { private void storeRepository(Repository repository, Authentication authentication) {
Date utilDate = new Date(); Date utilDate = new Date();
Timestamp date = new Timestamp(utilDate.getTime()); Timestamp date = new Timestamp(utilDate.getTime());
@ -564,8 +561,8 @@ public class RepositoryServiceImpl implements RepositoryService {
// Explicitly update validation set (updating the interface does not allow updating the set value) // Explicitly update validation set (updating the interface does not allow updating the set value)
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet()); this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication); emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication); emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) { if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel); InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
@ -593,8 +590,8 @@ public class RepositoryServiceImpl implements RepositoryService {
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet()); this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication); emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication); emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) { if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel); InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);

View File

@ -310,10 +310,11 @@ public class ValidatorServiceImpl implements ValidatorService {
@Override @Override
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception { public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId); InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId); Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
String compatibility = null;
if (request.isPresent()) { if (request.isPresent()) {
compatibility = request.get().getDesiredCompatibilityLevel();
logger.info("Changing compatibility level. Request: {}", request); logger.info("Changing compatibility level. Request: {}", request);
if (scoreContent > 50) { if (scoreContent > 50) {
@ -321,6 +322,7 @@ public class ValidatorServiceImpl implements ValidatorService {
} }
interfaceComplianceService.delete(requestId); interfaceComplianceService.delete(requestId);
} }
emailUtils.sendUponJobCompletion(repoId,interfaceId,compatibility,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
} }
} }