Bug fixes

This commit is contained in:
Panagiotis Kanakakis 2018-04-17 10:12:47 +00:00
parent da0136cb4b
commit 3150e48cab
6 changed files with 139 additions and 60 deletions

View File

@ -19,9 +19,8 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
private static final Logger LOGGER = Logger private static final Logger LOGGER = Logger
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class); .getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
@PostConstruct
public void init(){ public void init(){
LOGGER.debug(frontEndURI); LOGGER.debug("Front end uri : " + frontEndURI);
} }
@Override @Override

View File

@ -18,7 +18,7 @@ import java.util.Map;
@Api(description = "Broker API", tags = {"broker"}) @Api(description = "Broker API", tags = {"broker"})
public interface BrokerApi { public interface BrokerApi {
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST, @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException; DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException;

View File

@ -57,6 +57,9 @@ public class BrokerApiImpl implements BrokerApi {
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() {
@ -75,8 +78,8 @@ public class BrokerApiImpl implements BrokerApi {
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(e); LOGGER.debug("Exception on initDnetTopicsMap" , e);
e.printStackTrace(); emailUtils.reportException(e);
} }
} }
@ -108,7 +111,8 @@ public class BrokerApiImpl implements BrokerApi {
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
} }
} catch (BrokerException e) { } catch (BrokerException e) {
e.printStackTrace(); LOGGER.debug("Exception on getDatasourcesOfUser" , e);
emailUtils.reportException(e);
} }
return ret; return ret;
@ -130,6 +134,8 @@ public class BrokerApiImpl implements BrokerApi {
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);
} }
@ -163,6 +169,8 @@ public class BrokerApiImpl implements BrokerApi {
} }
); );
} 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();
@ -241,6 +249,8 @@ public class BrokerApiImpl implements BrokerApi {
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();
@ -266,7 +276,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() { new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Error " , e); LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return resp.getBody(); return resp.getBody();
@ -295,6 +306,8 @@ public class BrokerApiImpl implements BrokerApi {
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);
} }
@ -318,6 +331,8 @@ public class BrokerApiImpl implements BrokerApi {
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);
} }
} }
@ -340,6 +355,8 @@ public class BrokerApiImpl implements BrokerApi {
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();
@ -371,6 +388,8 @@ public class BrokerApiImpl implements BrokerApi {
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

@ -62,6 +62,9 @@ public class RepositoryApiImpl implements RepositoryApi {
@Autowired @Autowired
private PiWikApi piWikApi; private PiWikApi piWikApi;
@Autowired
private EmailUtils emailUtils;
private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<String, Vocabulary>(); private Map<String, Vocabulary> vocabularyMap = new ConcurrentHashMap<String, Vocabulary>();
private Map<String, String> countriesMap = new HashMap<>(); private Map<String, String> countriesMap = new HashMap<>();
@ -160,19 +163,27 @@ public class RepositoryApiImpl implements RepositoryApi {
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setCountry(countryCode); requestFilter.setCountry(countryCode);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); try{
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
while (jsonArray.length() > 0 ) { JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
resultSet.addAll(this.getRepositoriesByMode(filterKey, Converter.jsonToRepositoryList(new JSONObject(rs)))); while (jsonArray.length() > 0 ) {
page += 1; resultSet.addAll(this.getRepositoriesByMode(filterKey, Converter.jsonToRepositoryList(new JSONObject(rs))));
uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size)); page += 1;
rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); uriComponents = searchDatasource(String.valueOf(page),String.valueOf(size));
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
} jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
for (Repository r : resultSet) }
this.getRepositoryInfo(r); for (Repository r : resultSet)
this.getRepositoryInfo(r);
return resultSet;
}catch (Exception e){
LOGGER.debug("Exception on getRepositoriesByCountry" , e);
emailUtils.reportException(e);
throw e;
}
return resultSet;
} }
private void getRepositoryInfo(Repository r) throws JSONException { private void getRepositoryInfo(Repository r) throws JSONException {
@ -209,13 +220,20 @@ public class RepositoryApiImpl implements RepositoryApi {
UriComponents uriComponents = searchDatasource(page,size); UriComponents uriComponents = searchDatasource(page,size);
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setRegisteredby(userEmail); requestFilter.setRegisteredby(userEmail);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); try{
for (Repository r : repos) String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
this.getRepositoryInfo(r);
return repos; List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
for (Repository r : repos)
this.getRepositoryInfo(r);
return repos;
}catch (Exception e){
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
emailUtils.reportException(e);
throw e;
}
} }
@Override @Override
@ -226,13 +244,21 @@ public class RepositoryApiImpl implements RepositoryApi {
UriComponents uriComponents = searchDatasource("0","100"); UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setId(id); requestFilter.setId(id);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); try{
if(jsonArray.length() > 0) String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0)); JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
if (repo != null) if(jsonArray.length() > 0)
getRepositoryInfo(repo); repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
return repo; if (repo != null)
getRepositoryInfo(repo);
return repo;
}catch (Exception e){
LOGGER.debug("Exception on getRepositoryById" , e);
emailUtils.reportException(e);
throw e;
}
} }
@ -243,19 +269,19 @@ public class RepositoryApiImpl implements RepositoryApi {
UriComponents uriComponents = searchDatasource("0","100"); UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setId(id); requestFilter.setId(id);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONObject repository = new JSONObject(rs);
Aggregations aggregations = new Aggregations(); Aggregations aggregations = new Aggregations();
try { try {
LOGGER.debug(repository.getJSONArray("datasourceInfo").getJSONObject(0)); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONObject repository = new JSONObject(rs);
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
return aggregations; return aggregations;
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.debug("JSON aggregation exception ", e); LOGGER.debug("Exception on getRepositoryAggregations" , e);
emailUtils.reportException(e);
throw e; throw e;
} }
@ -270,12 +296,19 @@ public class RepositoryApiImpl implements RepositoryApi {
UriComponents uriComponents = searchDatasource("0","100"); UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setOfficialname(name); requestFilter.setOfficialname(name);
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); try{
for (Repository r : repos) String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
getRepositoryInfo(r); List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
return repos; for (Repository r : repos)
getRepositoryInfo(r);
return repos;
}catch (Exception e){
LOGGER.debug("Exception on getRepositoriesByName" , e);
emailUtils.reportException(e);
throw e;
}
} }
@Override @Override
@ -286,8 +319,15 @@ public class RepositoryApiImpl implements RepositoryApi {
.path("/{id}") .path("/{id}")
.build().expand(id).encode(); .build().expand(id).encode();
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); try{
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs)); String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
}catch (Exception e ){
LOGGER.debug("Exception on getRepositoryInterface" , e);
emailUtils.reportException(e);
throw e;
}
} }
@Override @Override
@ -308,13 +348,18 @@ public class RepositoryApiImpl implements RepositoryApi {
.fromHttpUrl(baseAddress + "/ds/update/") .fromHttpUrl(baseAddress + "/ds/update/")
.build() .build()
.encode(); .encode();
String json_repository = Converter.repositoryObjectToJson(repository);
LOGGER.debug(json_repository); try {
String json_repository = Converter.repositoryObjectToJson(repository);
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
return repository;
}catch (Exception e){
LOGGER.debug("Exception on updateRepository" , e);
emailUtils.reportException(e);
throw e;
}
HttpEntity<String> httpEntity = new HttpEntity <String> (json_repository,httpHeaders);
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
return repository;
} }
private Repository setRepositoryFeatures(String datatype, Repository repository) { private Repository setRepositoryFeatures(String datatype, Repository repository) {
@ -416,10 +461,11 @@ public class RepositoryApiImpl implements RepositoryApi {
restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class); restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class);
return repositoryInterface; return repositoryInterface;
} catch (JSONException e1) { } catch (JSONException e) {
LOGGER.debug("Error parsing json ",e1); LOGGER.debug("Exception on addRepositoryInterface" , e);
emailUtils.reportException(e);
throw e;
} }
return null;
} }
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) { private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
@ -482,10 +528,15 @@ public class RepositoryApiImpl implements RepositoryApi {
.path("/{page}/{size}") .path("/{page}/{size}")
.build().expand(page,size).encode(); .build().expand(page,size).encode();
try{
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setRegisteredby(userEmail); requestFilter.setRegisteredby(userEmail);
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class)); return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
}catch (Exception e){
LOGGER.debug("Exception on addRepositoryInterface" , e);
emailUtils.reportException(e);
throw e;
}
} }
@Override @Override
@ -602,7 +653,7 @@ public class RepositoryApiImpl implements RepositoryApi {
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("Error while getting metrics info for repository: ", e); LOGGER.error("Error while getting metrics info for repository: ", e);
//emailUtils.reportException(e); emailUtils.reportException(e);
throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR);
} }
} }
@ -678,6 +729,8 @@ public class RepositoryApiImpl implements RepositoryApi {
new ParameterizedTypeReference<MetricsNumbers>() { new ParameterizedTypeReference<MetricsNumbers>() {
}); });
} catch (RestClientException e) { } catch (RestClientException e) {
LOGGER.debug("Exception on getMetricsNumbers" , e);
emailUtils.reportException(e);
throw e; throw e;
} }

View File

@ -53,6 +53,9 @@ public class ValidatorApiImpl implements ValidatorApi{
private static final Logger LOGGER = Logger private static final Logger LOGGER = Logger
.getLogger(ValidatorApiImpl.class); .getLogger(ValidatorApiImpl.class);
@Autowired
private EmailUtils emailUtils;
@PostConstruct @PostConstruct
private void loadRules(){ private void loadRules(){
LOGGER.debug("PostConstruct method! Load rules!"); LOGGER.debug("PostConstruct method! Load rules!");
@ -89,7 +92,8 @@ public class ValidatorApiImpl implements ValidatorApi{
try { try {
this.getValidationService().submitValidationJob(jobForValidation); this.getValidationService().submitValidationJob(jobForValidation);
} catch (ValidatorServiceException e) { } catch (ValidatorServiceException e) {
e.printStackTrace(); LOGGER.debug("Exception on submitJobForValidation" , e);
emailUtils.reportException(e);
} }
} }
@ -135,7 +139,8 @@ public class ValidatorApiImpl implements ValidatorApi{
try { try {
return OaiTools.getSetsOfRepo(url); return OaiTools.getSetsOfRepo(url);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOGGER.debug("Exception on getSetsOfRepository" , e);
emailUtils.reportException(e);
} }
return null; return null;
} }
@ -147,6 +152,7 @@ public class ValidatorApiImpl implements ValidatorApi{
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;
} }
} }
@ -166,6 +172,7 @@ public class ValidatorApiImpl implements ValidatorApi{
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;
} }
} }
@ -201,7 +208,7 @@ public class ValidatorApiImpl implements ValidatorApi{
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); emailUtils.reportException(e);
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
} }
} }

View File

@ -48,7 +48,8 @@
</util:map> </util:map>
<bean class="eu.dnetlib.repo.manager.service.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect"> <bean class="eu.dnetlib.repo.manager.service.config.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect"
init-method="init">
<property name="frontEndURI" value="${webapp.dev.front}"/> <property name="frontEndURI" value="${webapp.dev.front}"/>
</bean> </bean>