Revize a612ffab
Přidáno uživatelem Lukas Cerny před téměř 6 roky(ů)
server/src/main/java/cz/zcu/yamanager/business/mock/FileServiceMock.java | ||
---|---|---|
1 | 1 |
package cz.zcu.yamanager.business.mock; |
2 | 2 |
|
3 |
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream; |
|
4 | 3 |
import cz.zcu.yamanager.business.FileExportResult; |
5 | 4 |
import cz.zcu.yamanager.business.FileImportResult; |
6 | 5 |
import cz.zcu.yamanager.business.FileService; |
... | ... | |
17 | 16 |
import org.springframework.stereotype.Component; |
18 | 17 |
|
19 | 18 |
import java.io.ByteArrayInputStream; |
19 |
import java.io.ByteArrayOutputStream; |
|
20 | 20 |
import java.io.IOException; |
21 | 21 |
import java.util.ArrayList; |
22 | 22 |
import java.util.Iterator; |
... | ... | |
77 | 77 |
|
78 | 78 |
cos.close(); |
79 | 79 |
|
80 |
ByteOutputStream output = new ByteOutputStream();
|
|
80 |
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
81 | 81 |
|
82 | 82 |
document.save(output); |
83 | 83 |
document.close(); |
84 | 84 |
|
85 |
return new FileExportResult("export.pdf", output.getBytes());
|
|
85 |
return new FileExportResult("export.pdf", output.toByteArray());
|
|
86 | 86 |
|
87 | 87 |
} catch (IOException ioex) { |
88 | 88 |
throw new RESTFullException("", ""); |
server/src/main/java/cz/zcu/yamanager/ws/rest/ApiController.java | ||
---|---|---|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
private <T> ResponseEntity handle(Language language, RESTGetHandler<T> handler) { |
73 |
return handleWithHeader(language, handler, null, null);
|
|
73 |
return handle(language, handler, null, null); |
|
74 | 74 |
} |
75 | 75 |
|
76 |
private <T> ResponseEntity handleWithHeader(Language language, RESTGetHandler<T> handler, Function<T, String[]> header, Function<T, Object> bodyValue) {
|
|
76 |
private <T> ResponseEntity handle(Language language, RESTGetHandler<T> handler, Function<T, String[]> header, Function<T, Object> bodyValue) { |
|
77 | 77 |
try { |
78 | 78 |
T result = handler.get(); |
79 | 79 |
|
... | ... | |
263 | 263 |
public ResponseEntity exportPDFFile( |
264 | 264 |
@RequestParam(value = "lang", required = false) String lang) |
265 | 265 |
{ |
266 |
return handleWithHeader(getLanguage(lang),
|
|
266 |
return handle(getLanguage(lang), |
|
267 | 267 |
() -> fileService.createPDFFile(), |
268 | 268 |
(res) -> new String[]{HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + res.getName() + "\""}, |
269 | 269 |
(res) -> res.getBytes() |
Také k dispozici: Unified diff
Fix import package