Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2024-09-17 15:29:32 +02:00
2 changed files with 7 additions and 25 deletions

View File

@@ -115,7 +115,6 @@ public class EmsRestConstants {
public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto"; public static final String PATH_EXPORT_ORDINI_ACQ = PATH + "exportOrdiniAcquisto";
public static final String PATH_PROCESS_REPORT = PATH + "processReport"; public static final String PATH_PROCESS_REPORT = PATH + "processReport";
public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport"; public static final String PATH_DOWNLOAD_REPORT = PATH + "downloadReport";
public static final String PATH_DOWNLOAD_REPORT_RESPONSE_ENTITY = PATH + "downloadReportResponseEntity";
public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType"; public static final String PATH_PROCESS_REPORT_TYPE = PATH + "processReportType";
public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType"; public static final String PATH_PRINT_REPORT_TYPE = PATH + "printReportType";
public static final String PATH_GET_SETUP_REPORT_TYPE = PATH + "getSetupReportType"; public static final String PATH_GET_SETUP_REPORT_TYPE = PATH + "getSetupReportType";

View File

@@ -64,24 +64,25 @@ public class EmsEngineController {
List<ServiceRestResponse> processReport(HttpServletRequest request, List<ServiceRestResponse> processReport(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String configuration, @RequestParam(CommonConstants.PROFILE_DB) String configuration,
@RequestBody JasperDTO jasperDTO) { @RequestBody JasperDTO jasperDTO) {
List<ServiceRestResponse> response = new ArrayList<ServiceRestResponse>(); List<ServiceRestResponse> response = new ArrayList<>();
try { try {
FileItem fi = new FileItem(); FileItem fi = new FileItem();
byte[] bytes = emsEngineService.processReport(jasperDTO); byte[] bytes = emsEngineService.processReport(jasperDTO);
if (bytes != null) {
if (bytes != null) {
fi.setFileb64Content(new String(Base64.encodeBase64(bytes))); fi.setFileb64Content(new String(Base64.encodeBase64(bytes)));
}
response.add(new ServiceRestResponse(EsitoType.OK, multiDBTransactionManager.getPrimaryDatasource().getProfile(), fi)); response.add(new ServiceRestResponse(EsitoType.OK, multiDBTransactionManager.getPrimaryDatasource().getProfile(), fi));
}
response.add(ServiceRestResponse.createNegativeResponse("Nessun report generato!"));
} catch (JRException e) { } catch (JRException e) {
logger.error(e + " - Cause: " + e.getCause()); logger.error(e + " - Cause: " + e.getCause());
response.add(new ServiceRestResponse(EsitoType.KO, configuration, e)); response.add(ServiceRestResponse.createNegativeResponse(configuration, e));
} catch (Exception e) { } catch (Exception e) {
logger.error(request.getRequestURI(), e); logger.error(request.getRequestURI(), e);
response.add(new ServiceRestResponse(EsitoType.KO, configuration, e)); response.add(ServiceRestResponse.createNegativeResponse(configuration, e));
} }
return response; return response;
} }
@@ -104,24 +105,6 @@ public class EmsEngineController {
} }
} }
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_REPORT_RESPONSE_ENTITY, method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<byte[]> downloadReportResponseEntity(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
@RequestParam String fileName,
@RequestBody JasperDTO jasperDTO) throws Exception {
byte[] bytes = emsEngineService.processReport(jasperDTO);
String mimeType = mimeTypesHandler.getContentType(fileName).toString();
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(mimeType))
.contentLength(bytes != null ? bytes.length : 0)
.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"")
.body(bytes);
}
@RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST) @RequestMapping(value = EmsRestConstants.PATH_PROCESS_REPORT_TYPE, method = RequestMethod.POST)
public @ResponseBody public @ResponseBody
ServiceRestResponse processReportTypeList(HttpServletRequest request, ServiceRestResponse processReportTypeList(HttpServletRequest request,