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
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
@PostConstruct
public void init(){
LOGGER.debug(frontEndURI);
LOGGER.debug("Front end uri : " + frontEndURI);
}
@Override

View File

@ -18,7 +18,7 @@ import java.util.Map;
@Api(description = "Broker API", tags = {"broker"})
public interface BrokerApi {
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.POST,
@RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
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>();
@Autowired
private EmailUtils emailUtils;
@PostConstruct
private void initDnetTopicsMap() {
@ -75,8 +78,8 @@ public class BrokerApiImpl implements BrokerApi {
for (JsonNode term : root.path("terms") )
topics.put(term.path("code").textValue(), parseTerm(term));
} catch (IOException e) {
LOGGER.debug(e);
e.printStackTrace();
LOGGER.debug("Exception on initDnetTopicsMap" , e);
emailUtils.reportException(e);
}
}
@ -108,7 +111,8 @@ public class BrokerApiImpl implements BrokerApi {
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
}
} catch (BrokerException e) {
e.printStackTrace();
LOGGER.debug("Exception on getDatasourcesOfUser" , e);
emailUtils.reportException(e);
}
return ret;
@ -130,6 +134,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<List<BrowseEntry>>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on getTopicsForDatasource" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
@ -163,6 +169,8 @@ public class BrokerApiImpl implements BrokerApi {
}
);
} catch (RestClientException e) {
LOGGER.debug("Exception on advancedShowEvents" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
return resp.getBody();
@ -241,6 +249,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<EventsPage>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on showEvents" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
return resp.getBody();
@ -266,7 +276,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
});
} catch (RestClientException e) {
LOGGER.debug("Error " , e);
LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
return resp.getBody();
@ -295,6 +306,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<Subscription>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on OpenaireSubscription" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
@ -318,6 +331,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<Void>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on unsubscribe" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
}
@ -340,6 +355,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<Subscription>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on getSubscription" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
return resp.getBody();
@ -371,6 +388,8 @@ public class BrokerApiImpl implements BrokerApi {
new ParameterizedTypeReference<EventsPage>() {
});
} catch (RestClientException e) {
LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e);
emailUtils.reportException(e);
throw new BrokerException(e);
}
return resp.getBody();

View File

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

View File

@ -53,6 +53,9 @@ public class ValidatorApiImpl implements ValidatorApi{
private static final Logger LOGGER = Logger
.getLogger(ValidatorApiImpl.class);
@Autowired
private EmailUtils emailUtils;
@PostConstruct
private void loadRules(){
LOGGER.debug("PostConstruct method! Load rules!");
@ -89,7 +92,8 @@ public class ValidatorApiImpl implements ValidatorApi{
try {
this.getValidationService().submitValidationJob(jobForValidation);
} catch (ValidatorServiceException e) {
e.printStackTrace();
LOGGER.debug("Exception on submitJobForValidation" , e);
emailUtils.reportException(e);
}
}
@ -135,7 +139,8 @@ public class ValidatorApiImpl implements ValidatorApi{
try {
return OaiTools.getSetsOfRepo(url);
} catch (Exception e) {
e.printStackTrace();
LOGGER.debug("Exception on getSetsOfRepository" , e);
emailUtils.reportException(e);
}
return null;
}
@ -147,6 +152,7 @@ public class ValidatorApiImpl implements ValidatorApi{
return OaiTools.identifyRepository(url);
} catch (Exception e) {
LOGGER.error("Error while identifying repository with url: " + url, e);
emailUtils.reportException(e);
return false;
}
}
@ -166,6 +172,7 @@ public class ValidatorApiImpl implements ValidatorApi{
return ruleSet;
} catch (Exception e) {
LOGGER.error("Error getting ruleset", e);
emailUtils.reportException(e);
return null;
}
}
@ -201,7 +208,7 @@ public class ValidatorApiImpl implements ValidatorApi{
return interfaceInformation;
} catch (Exception 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);
}
}

View File

@ -48,7 +48,8 @@
</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}"/>
</bean>