mooore cleanup

This commit is contained in:
Antonis Lempesis 2021-10-07 14:13:04 +00:00
parent 17c6fa5378
commit cca7a21d7b
5 changed files with 21 additions and 63 deletions

View File

@ -50,9 +50,6 @@ public class BrokerServiceImpl implements BrokerService {
private HashMap<String, Term> topics = new HashMap<String, Term>(); private HashMap<String, Term> topics = new HashMap<String, Term>();
@Autowired
private EmailUtils emailUtils;
@PostConstruct @PostConstruct
private void initDnetTopicsMap() { private void initDnetTopicsMap() {
@ -66,8 +63,7 @@ public class BrokerServiceImpl implements BrokerService {
for (JsonNode term : root.path("terms")) for (JsonNode term : root.path("terms"))
topics.put(term.path("code").textValue(), parseTerm(term)); topics.put(term.path("code").textValue(), parseTerm(term));
} catch (IOException e) { } catch (IOException e) {
LOGGER.debug("Exception on initDnetTopicsMap", e); LOGGER.error("Exception on initDnetTopicsMap", e);
emailUtils.reportException(e);
} }
} }
@ -93,8 +89,7 @@ public class BrokerServiceImpl implements BrokerService {
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); // ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
// } // }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug("Exception on getDatasourcesOfUser", e); LOGGER.error("Exception on getDatasourcesOfUser", e);
emailUtils.reportException(e);
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
System.out.println("Getting datasources of user in " + (end - start) + "ms"); System.out.println("Getting datasources of user in " + (end - start) + "ms");
@ -117,8 +112,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<List<BrowseEntry>>() { new ParameterizedTypeReference<List<BrowseEntry>>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on getTopicsForDatasource", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
@ -151,13 +144,9 @@ public class BrokerServiceImpl implements BrokerService {
} }
); );
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on advancedShowEvents", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
} }
@ -210,8 +199,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<EventsPage>() { new ParameterizedTypeReference<EventsPage>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on showEvents", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -236,8 +223,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() { new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on getSimpleSubscriptionsOfUser", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -272,8 +257,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Subscription>() { new ParameterizedTypeReference<Subscription>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on OpenaireSubscription", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
@ -296,8 +279,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Void>() { new ParameterizedTypeReference<Void>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on unsubscribe", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return new ResponseEntity<>("OK", HttpStatus.OK); return new ResponseEntity<>("OK", HttpStatus.OK);
@ -320,8 +301,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<Subscription>() { new ParameterizedTypeReference<Subscription>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on getSubscription", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -351,8 +330,6 @@ public class BrokerServiceImpl implements BrokerService {
new ParameterizedTypeReference<EventsPage>() { new ParameterizedTypeReference<EventsPage>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on getNotificationsBySubscriptionId", e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();

View File

@ -14,9 +14,6 @@ public class DashboardServiceImpl implements DashboardService {
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class); private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
@Autowired
private EmailUtils emailUtils;
@Autowired @Autowired
private RepositoryService repositoryService; private RepositoryService repositoryService;

View File

@ -169,11 +169,10 @@ public class PiWikServiceImpl implements PiWikService {
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
LOGGER.error("Error while approving piwik site: ", e); LOGGER.error("Error while approving piwik site: ", e);
emailUtils.reportException(e);
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e); LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e);
emailUtils.reportException(e); throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} }
return new ResponseEntity<>("OK", HttpStatus.OK); return new ResponseEntity<>("OK", HttpStatus.OK);
} }
@ -204,15 +203,13 @@ public class PiWikServiceImpl implements PiWikService {
emailUtils.sendUserRequestToEnableMetrics(piwikInfo); emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException uee) {
LOGGER.error("Error while creating piwikScript URL", uee); LOGGER.error("Error while creating piwikScript URL", uee);
emailUtils.reportException(uee);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (IOException ioe) { } catch (IOException ioe) {
LOGGER.error("Error while creating piwik site", ioe); LOGGER.error("Error while creating piwik site", ioe);
emailUtils.reportException(ioe);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e); LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e);
emailUtils.reportException(e); throw new RepositoryServiceException(e, RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} }
return piwikInfo; return piwikInfo;
} }

View File

@ -2,7 +2,6 @@ package eu.dnetlib.repo.manager.service;
import eu.dnetlib.usagestats.sushilite.domain.ReportItem; import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper; import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@ -10,7 +9,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
@ -24,9 +22,6 @@ public class SushiliteServiceImpl implements SushiliteService {
@Value("${services.repomanager.usagestats.sushiliteEndpoint}") @Value("${services.repomanager.usagestats.sushiliteEndpoint}")
private String usagestatsSushiliteEndpoint; private String usagestatsSushiliteEndpoint;
@Autowired
private EmailUtils emailUtils;
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class); private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
@ -63,7 +58,7 @@ public class SushiliteServiceImpl implements SushiliteService {
template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
ResponseEntity<ReportResponseWrapper> resp; ResponseEntity<ReportResponseWrapper> resp;
try {
//communicate with endpoint //communicate with endpoint
resp = template.exchange( resp = template.exchange(
builder.build().encode().toUri(), builder.build().encode().toUri(),
@ -71,11 +66,6 @@ public class SushiliteServiceImpl implements SushiliteService {
null, null,
new ParameterizedTypeReference<ReportResponseWrapper>() { new ParameterizedTypeReference<ReportResponseWrapper>() {
}); });
} catch (RestClientException e) {
LOGGER.debug("Exception on getReportResults" , e);
emailUtils.reportException(e);
throw e;
}
// check remote api's response // check remote api's response
System.out.println("sushi responded status " + resp.getStatusCode()); System.out.println("sushi responded status " + resp.getStatusCode());

View File

@ -144,13 +144,10 @@ public class ValidatorServiceImpl implements ValidatorService {
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// this.getValidationService().submitValidationJob(jobForValidation); // this.getValidationService().submitValidationJob(jobForValidation);
} catch (ValidatorServiceException e) {
LOGGER.debug("Exception on submitJobForValidation" , e);
emailUtils.reportException(e);
throw e;
} catch (Exception e) { } catch (Exception e) {
LOGGER.error(e); throw new ValidatorServiceException(e);
} }
return jobForValidation; return jobForValidation;
} }
@ -200,13 +197,16 @@ public class ValidatorServiceImpl implements ValidatorService {
@Override @Override
public List<String> getSetsOfRepository(String url) { public List<String> getSetsOfRepository(String url) {
LOGGER.debug("Getting sets of repository with url : " + url); LOGGER.debug("Getting sets of repository with url : " + url);
List<String> sets = null;
try { try {
return OaiTools.getSetsOfRepo(url); sets = OaiTools.getSetsOfRepo(url);
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug("Exception on getSetsOfRepository" , e); LOGGER.error("Exception on getSetsOfRepository" , e);
emailUtils.reportException(e);
} }
return null;
return sets;
} }
@Override @Override
@ -216,7 +216,6 @@ public class ValidatorServiceImpl implements ValidatorService {
return OaiTools.identifyRepository(url); return OaiTools.identifyRepository(url);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error while identifying repository with url: " + url, e); LOGGER.error("Error while identifying repository with url: " + url, e);
emailUtils.reportException(e);
return false; return false;
} }
} }
@ -236,7 +235,6 @@ public class ValidatorServiceImpl implements ValidatorService {
return ruleSet; return ruleSet;
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error getting ruleset", e); LOGGER.error("Error getting ruleset", e);
emailUtils.reportException(e);
return null; return null;
} }
} }
@ -284,7 +282,6 @@ public class ValidatorServiceImpl implements ValidatorService {
return interfaceInformation; return interfaceInformation;
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error getting interface information with url: " + baseUrl, e); LOGGER.error("Error getting interface information with url: " + baseUrl, e);
emailUtils.reportException(e);
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
} }
} }