fixed content type missmatch error when converting response from json to string in method getRepositoriesByCountry
This commit is contained in:
parent
e551a7a783
commit
49cc3d74e8
|
@ -210,7 +210,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
|
||||
// here page should be 0
|
||||
UriComponents uriComponents = searchSnipperDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
||||
UriComponents uriComponents = searchSnippetDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
|
||||
try {
|
||||
|
@ -259,31 +259,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
logger.debug("Country code equals : {} | Filter mode equals : {}", country, filterKey);
|
||||
|
||||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
||||
UriComponents uriComponents = searchSnippetDatasource(String.valueOf(page), String.valueOf(size));
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setCountry(country);
|
||||
requestFilter.setEoscDatasourceType(filterKey);
|
||||
|
||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
if ( rs == null ) {
|
||||
logger.error("The result is null!");
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
while (jsonArray.length() > 0) {
|
||||
|
||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
||||
Map rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, Map.class);
|
||||
if (rs != null) {
|
||||
resultSet.addAll(mapper.readValue(mapper.writeValueAsString(rs.get("datasourceInfo")),
|
||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||
page += 1;
|
||||
uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
||||
rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||
if ( rs == null ) {
|
||||
logger.error("The result is null!");
|
||||
break;
|
||||
}
|
||||
|
||||
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
||||
}
|
||||
return resultSet;
|
||||
}
|
||||
|
@ -385,7 +369,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
logger.debug("Retrieving repositories with id : {}", id);
|
||||
RepositorySnippet repo;
|
||||
UriComponents uriComponents = searchSnipperDatasource("0", "100");
|
||||
UriComponents uriComponents = searchSnippetDatasource("0", "100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
||||
|
@ -818,8 +802,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
}
|
||||
}
|
||||
else if (mode.equalsIgnoreCase("cris")) {
|
||||
} else if (mode.equalsIgnoreCase("cris")) {
|
||||
if (entry.getKey().contains("openaire-cris")) {
|
||||
retMap.put(entry.getKey(), entry.getValue());
|
||||
foundData = true;
|
||||
|
@ -925,8 +908,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
dates.put("re3data", re3Date);
|
||||
|
||||
return dates;
|
||||
}
|
||||
else if (mode.equals("cris"))
|
||||
} else if (mode.equals("cris"))
|
||||
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
||||
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
||||
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||
|
@ -1010,7 +992,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
.build().expand(page, size).encode();
|
||||
}
|
||||
|
||||
private UriComponents searchSnipperDatasource(String page, String size) {
|
||||
private UriComponents searchSnippetDatasource(String page, String size) {
|
||||
|
||||
return UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
||||
|
|
Loading…
Reference in New Issue