1 package fr.ifremer.quadrige3.ui.swing.synchro.action;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import fr.ifremer.quadrige3.synchro.vo.SynchroProgressionStatus;
28 import fr.ifremer.quadrige3.ui.swing.synchro.SynchroUIHandler;
29
30 import java.io.File;
31
32
33
34
35
36
37 public class ImportSynchroDownloadAction extends AbstractDownloadAction {
38
39
40
41
42
43
44 public ImportSynchroDownloadAction(SynchroUIHandler handler) {
45 super(handler);
46 }
47
48
49 @Override
50 public boolean initAction() {
51 super.initAction();
52
53 getModel().setStatus(SynchroProgressionStatus.RUNNING);
54 getModel().saveImportContext();
55
56 return true;
57 }
58
59
60 @Override
61 public File getTargetDirectory() {
62 return getModel().getImportDirectory();
63 }
64
65
66 @Override
67 public String getUrlPath() {
68 boolean isAnonymous = getContext().isAuthenticatedAsLocalUser();
69 return isAnonymous ? "/service/import/files/anonymous" : "/service/import/files";
70 }
71
72
73 @Override
74 public void doneAction() {
75 super.doneAction();
76
77 getModel().setStatus(SynchroProgressionStatus.SUCCESS);
78
79 getModel().saveImportContext();
80
81
82 if (isWait()) {
83 return;
84 }
85
86 getHandler().showValidApplyPopup();
87
88 }
89
90
91 @Override
92 public void failedAction(Throwable ex) {
93 super.failedAction(ex);
94
95 getModel().saveImportContext();
96
97 }
98
99 }