fixed deserialization issue caused from json to String

This commit is contained in:
Konstantinos Spyrou 2023-01-19 12:28:31 +02:00
parent 0674a3c031
commit f88d9b8381
1 changed files with 3 additions and 5 deletions

View File

@ -287,16 +287,14 @@ public class RepositoryServiceImpl implements RepositoryService {
requestFilter.setEnglishname(englishName);
try {
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
Map rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, Map.class);
if (rs == null) {
logger.error("DSM response is null : [url={}]", uriComponents.toUri());
} else {
JSONObject response = new JSONObject(rs);
JSONArray jsonArray = (JSONArray) response.get("datasourceInfo");
Header header = mapper.readValue(response.get("header").toString(), Header.class);
Header header = mapper.readValue(mapper.writeValueAsString(rs.get("header")), Header.class);
snippets = Paging.of(header,
mapper.readValue(
String.valueOf(jsonArray),
mapper.writeValueAsString(rs.get("datasourceInfo")),
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
}