|
|
@@ -42,6 +42,7 @@ import es.uv.saic.dto.TascaInformeTransferDTO;
|
|
|
import es.uv.saic.feign.CoreClient;
|
|
|
import es.uv.saic.service.DocumentService;
|
|
|
import es.uv.saic.service.PlantillaService;
|
|
|
+import feign.Headers;
|
|
|
import fr.opensagres.xdocreport.core.XDocReportException;
|
|
|
import fr.opensagres.xdocreport.core.io.internal.ByteArrayOutputStream;
|
|
|
import fr.opensagres.xdocreport.document.IXDocReport;
|
|
|
@@ -91,7 +92,6 @@ public class DownloadController {
|
|
|
* @return A FileSystemResource representing the file to download
|
|
|
*/
|
|
|
@GetMapping(value="/download/{fileName}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
- @ResponseBody
|
|
|
public ResponseEntity<byte[]> download(@PathVariable("fileName") BigInteger idInstanciaTasca, HttpServletResponse response) throws FileNotFoundException {
|
|
|
|
|
|
try {
|
|
|
@@ -120,6 +120,7 @@ public class DownloadController {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ // PARA BORRAR
|
|
|
/*
|
|
|
* Download a document by its ID
|
|
|
* @param model
|
|
|
@@ -186,7 +187,7 @@ public class DownloadController {
|
|
|
*/
|
|
|
@GetMapping(value="/download/template/{id}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
|
|
@ResponseBody
|
|
|
- public byte[] downloadTemplate(@PathVariable("id") BigInteger idTascai, HttpServletResponse response) throws IOException, XDocReportException {
|
|
|
+ public ResponseEntity<byte[]> downloadTemplate(@PathVariable("id") BigInteger idTascai, HttpServletResponse response) throws IOException, XDocReportException {
|
|
|
XDocReportRegistry.getRegistry().clear();
|
|
|
String reportId = "none";
|
|
|
InstanciaTascaDTO it = core.findInstanciaTascaById(idTascai);
|
|
|
@@ -210,7 +211,7 @@ public class DownloadController {
|
|
|
|
|
|
File f = new File(templatePath);
|
|
|
if(!f.exists()) {
|
|
|
- return new FileSystemResource(this.fileNotFound).getInputStream().readAllBytes();
|
|
|
+ return ResponseEntity.ok(new FileSystemResource(this.fileNotFound).getInputStream().readAllBytes());
|
|
|
}
|
|
|
|
|
|
InputStream in = new FileInputStream(f);
|
|
|
@@ -253,9 +254,9 @@ public class DownloadController {
|
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
report.process(context, out);
|
|
|
- response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""+tasca.getCodiEvidencia()+".docx\"");
|
|
|
|
|
|
- return out.toByteArray();
|
|
|
+ response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\""+tasca.getCodiEvidencia()+".docx\"");
|
|
|
+ return ResponseEntity.ok(out.toByteArray());
|
|
|
|
|
|
}
|
|
|
|