Improve performance and error-handling in "InterfaceComplianceService.cleanUp()".
This commit is contained in:
parent
64fdff095d
commit
842468a175
|
@ -39,19 +39,26 @@ public class InterfaceComplianceService {
|
|||
@Scheduled(cron = "0 0 0 * * *") // every day at 00:00
|
||||
public void cleanUp() {
|
||||
Set<InterfaceComplianceRequest> requests = getOutdated();
|
||||
for (InterfaceComplianceRequest request : requests) {
|
||||
for ( InterfaceComplianceRequest request : requests )
|
||||
{
|
||||
String repoId = request.getRepositoryId();
|
||||
String interfaceId = request.getInterfaceId();
|
||||
try {
|
||||
Map<String, RepositoryInterface> repositoryInterfaceMap = repositoryService.getRepositoryInterface(request.getRepositoryId())
|
||||
Map<String, RepositoryInterface> repositoryInterfaceMap = repositoryService.getRepositoryInterface(repoId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ApiDetails::getId, i -> i));
|
||||
Repository repo = repositoryService.getRepositoryById(request.getRepositoryId());
|
||||
RepositoryInterface iFace = repositoryInterfaceMap.get(request.getInterfaceId());
|
||||
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
|
||||
RepositoryInterface iFace = repositoryInterfaceMap.get(interfaceId);
|
||||
if ( iFace == null ) {
|
||||
logger.error("The repository-interface \"" + interfaceId + "\" does not exist! | the request had the \"repoId\": \"" + repoId + "\"");
|
||||
continue;
|
||||
}
|
||||
Repository repo = repositoryService.getRepositoryById(repoId);
|
||||
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(repoId);
|
||||
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
|
||||
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
logger.error("Error", e);
|
||||
}
|
||||
logger.error("Error for request with \"repoId\": \"" + repoId + "\" and \"interfaceId\": \"" + interfaceId + "\"", e);
|
||||
} // Continue to the next request.
|
||||
}
|
||||
repository.deleteAll(requests);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue