SUPPORT-8974 send empty id list
This commit is contained in:
parent
f78f3ea446
commit
87927541cc
5 changed files with 114 additions and 60 deletions
|
|
@ -51,17 +51,44 @@ public class ConfigExecutorService {
|
|||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<ExportDataRequest> entity = new HttpEntity<>(request, headers);
|
||||
|
||||
ResponseEntity<byte[]> response = restTemplate.exchange(url.concat("/").concat("downloadCSV"),
|
||||
HttpMethod.POST, entity, byte[].class
|
||||
);
|
||||
try {
|
||||
|
||||
String content = Base64.getEncoder().encodeToString(response.getBody());
|
||||
FileModel fileModel = new FileModel();
|
||||
fileModel.setFileContent(content);
|
||||
fileModel.setFileExtension(".csv");
|
||||
fileModel.setFileName(
|
||||
request.getType() + "_" + new SimpleDateFormat("dd.MM.yyyy").format(new Date()) + ".csv");
|
||||
return fileModel;
|
||||
ResponseEntity<byte[]> response = restTemplate.exchange(url.concat("/").concat("downloadCSV"),
|
||||
HttpMethod.POST, entity, byte[].class
|
||||
);
|
||||
|
||||
String content = Base64.getEncoder().encodeToString(response.getBody());
|
||||
FileModel fileModel = new FileModel();
|
||||
fileModel.setFileContent(content);
|
||||
fileModel.setFileExtension(".csv");
|
||||
fileModel.setFileName(
|
||||
request.getType() + "_" + new SimpleDateFormat("dd.MM.yyyy").format(new Date()) + ".csv");
|
||||
return fileModel;
|
||||
|
||||
} catch (HttpClientErrorException e) {
|
||||
|
||||
if (e.getStatusCode() == HttpStatus.BAD_REQUEST) {
|
||||
Map<String, Object> responseMap = new Gson().fromJson(e.getResponseBodyAsString(),
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType()
|
||||
);
|
||||
|
||||
if (responseMap.get("details") instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> details = (Map<String, String>) responseMap.get("details");
|
||||
String detailsStr = String.join("\n", details.values());
|
||||
throw new ConfigExecutorException("eks.error.misc", new RuntimeException(detailsStr, e));
|
||||
}
|
||||
|
||||
throw new ConfigExecutorException((String) responseMap.get("details"), e);
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException("Export data failed with error", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Export data failed with error", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String call(String methodPath, ConfigExecuteRequest configExecuteRequest,
|
||||
|
|
@ -95,6 +122,13 @@ public class ConfigExecutorService {
|
|||
}.getType()
|
||||
);
|
||||
|
||||
if (responseMap.get("details") instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> details = (Map<String, String>) responseMap.get("details");
|
||||
String detailsStr = String.join("\n", details.values());
|
||||
throw new ConfigExecutorException("eks.error.misc", new RuntimeException(detailsStr, e));
|
||||
}
|
||||
|
||||
throw new ConfigExecutorException((String) responseMap.get("details"), e);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue