1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ifremer.coser.web.actions.source;
23
24 import fr.ifremer.coser.result.result.FileResult;
25 import fr.ifremer.coser.result.request.ExtractRawDataRequest;
26 import org.apache.struts2.convention.annotation.Action;
27 import org.apache.struts2.convention.annotation.Result;
28
29 import java.io.InputStream;
30
31
32
33
34
35
36
37
38
39
40 public class SourceDataAction extends SourceAction {
41
42
43 private static final long serialVersionUID = 3385467755357775199L;
44
45 protected boolean accepted;
46
47 protected FileResult result;
48
49 public void setAccepted(boolean accepted) {
50 this.accepted = accepted;
51 }
52
53
54 public boolean isAccepted() {
55 return accepted;
56 }
57
58 @Action(results = {@Result(type = "stream", params = {"contentType", "application/zip", "contentDisposition", "attachment; filename=\"${filename}\""})})
59 public String execute() {
60
61 ExtractRawDataRequest request = requestBuilder(ExtractRawDataRequest.class).
62 addFacade(facade).
63 addZone(zone).
64 toRequest();
65 result = getService().toFirstFileResult(request);
66 return SUCCESS;
67 }
68
69 public String getFilename() {
70 return "source.zip";
71 }
72
73 public InputStream getInputStream() {
74 return result.getInputStream();
75 }
76
77 }