Aggiornato servizio readRemoteFile
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-01-31 16:59:34 +01:00
parent 2e41494b9d
commit f036947e1c

View File

@@ -1,10 +1,12 @@
package it.integry.ems.utility.controller;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.integry.common.var.CommonConstants;
import it.integry.ems.response.EsitoType;
import it.integry.ems.response.ServiceRestResponse;
import it.integry.ems.response.StatusResponse;
import it.integry.ems.service.HttpRestWrapper;
import it.integry.ems.status.ServiceChecker;
import it.integry.ems.utility.dto.C2EArgDTO;
import it.integry.ems.utility.dto.PdfDTO;
@@ -129,20 +131,22 @@ public class UtilityController {
@RequestMapping(value = EmsRestConstants.PATH_READ_REMOTE_FILE, method = RequestMethod.POST)
public @ResponseBody
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) {
ServiceRestResponse response;
try {
if (body.has("url")) {
String url = body.get("url").asText();
response = ServiceRestResponse.createPositiveResponse(UtilityService.readRemoteFile(url));
} else {
throw new Exception("La proprieta' \"url\" non è presente nel json");
}
} catch (Exception e) {
response = ServiceRestResponse.createNegativeResponse();
response.setErrorMessage(e.getMessage());
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) throws Exception {
if (body.has("url")) {
String url = body.get("url").asText();
StringBuilder responseString = new StringBuilder();
final int status = HttpRestWrapper.callGenericGet(url, null, null, responseString, null);
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(responseString.toString());
boolean success = node.get("success").asBoolean();
return ServiceRestResponse.createPositiveResponse(success);
} else {
throw new Exception("La proprieta' \"url\" non è presente nel json");
}
return response;
}
@RequestMapping(value = EmsRestConstants.PATH_MIGRATE_GEOLOCATION_FOR_RLAVR, method = RequestMethod.GET)