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

View File

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

View File

@ -169,11 +169,10 @@ public class PiWikServiceImpl implements PiWikService {
} catch (EmptyResultDataAccessException e) {
LOGGER.error("Error while approving piwik site: ", e);
emailUtils.reportException(e);
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (Exception 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);
}
@ -204,15 +203,13 @@ public class PiWikServiceImpl implements PiWikService {
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
} catch (UnsupportedEncodingException uee) {
LOGGER.error("Error while creating piwikScript URL", uee);
emailUtils.reportException(uee);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (IOException ioe) {
LOGGER.error("Error while creating piwik site", ioe);
emailUtils.reportException(ioe);
throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} catch (Exception 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;
}

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

View File

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