fixed deserialization issue caused from json to String

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

View File

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