root/Weektaken2/Weektaak3/ESB/src/hanze/ga/wt3/ftp/FTPApp2QChannel.java
| 366 | 368 | ||
|---|---|---|---|
6 | import java.io.StringReader; | 6 | import java.io.StringReader; |
7 | import java.io.StringWriter; | 7 | import java.io.StringWriter; |
8 | 8 | ||
9 | import org.apache.commons.net.ftp.FTPFile; | ||
10 | |||
11 | public class FTPApp2QChannel extends App2Q { | 9 | public class FTPApp2QChannel extends App2Q { |
12 | 10 | ||
13 | private String ftpAddress; | 11 | private String ftpAddress; |
... | ... | ||
16 | private String ftpPassword; | 14 | private String ftpPassword; |
17 | private ESBFTP ftpClient; | 15 | private ESBFTP ftpClient; |
18 | 16 | ||
19 | @Override | 17 | public String getFtpAddress() { |
20 | public void run() { | 18 | return ftpAddress; |
21 | try { | ||
22 | while (true) { | ||
23 | this.readAndProcessFTP(); | ||
24 | Thread.sleep(10000); | ||
25 | } | ||
26 | } catch (InterruptedException e) { | ||
27 | e.printStackTrace(); | ||
28 | } | ||
29 | } | 19 | } |
30 | 20 | ||
21 | public String getFtpInitDir() { | ||
22 | return ftpInitDir; | ||
23 | } | ||
24 | |||
25 | public String getFtpPassword() { | ||
26 | return ftpPassword; | ||
27 | } | ||
28 | |||
29 | public String getFtpUserName() { | ||
30 | return ftpUserName; | ||
31 | } | ||
32 | |||
31 | private void readAndProcessFTP() { | 33 | private void readAndProcessFTP() { |
32 | // Maak FTP-verbinding klaar | 34 | // Maak FTP-verbinding klaar |
33 | this.ftpClient = new ESBFTP(this.getFtpAddress(), this.getFtpUserName(), this | 35 | this.ftpClient = new ESBFTP(this.getFtpAddress(), this.getFtpUserName(), this |
... | ... | ||
45 | } | 47 | } |
46 | } | 48 | } |
47 | 49 | ||
48 | private String undoFilter(String fileContents) { | 50 | @Override |
49 | StringWriter stringWriter = new StringWriter(); | 51 | public void run() { |
50 | FromIBGFilter fromFilter = new FromIBGFilter(); | 52 | try { |
51 | fromFilter.doFilter(new StringReader(fileContents), stringWriter); | 53 | while (true) { |
52 | 54 | this.readAndProcessFTP(); | |
53 | return stringWriter.toString(); | 55 | Thread.sleep(10000); |
56 | } | ||
57 | } catch (InterruptedException e) { | ||
58 | e.printStackTrace(); | ||
59 | } | ||
54 | } | 60 | } |
55 | 61 | ||
56 | public String getFtpAddress() { | ||
57 | return ftpAddress; | ||
58 | } | ||
59 | |||
60 | public void setFtpAddress(String ftpAddress) { | 62 | public void setFtpAddress(String ftpAddress) { |
61 | this.ftpAddress = ftpAddress; | 63 | this.ftpAddress = ftpAddress; |
62 | } | 64 | } |
63 | 65 | ||
64 | public String getFtpInitDir() { | ||
65 | return ftpInitDir; | ||
66 | } | ||
67 | |||
68 | public void setFtpInitDir(String ftpInitDir) { | 66 | public void setFtpInitDir(String ftpInitDir) { |
69 | this.ftpInitDir = ftpInitDir; | 67 | this.ftpInitDir = ftpInitDir; |
70 | } | 68 | } |
71 | 69 | ||
72 | public String getFtpUserName() { | 70 | public void setFtpPassword(String ftpPassword) { |
73 | return ftpUserName; | 71 | this.ftpPassword = ftpPassword; |
74 | } | 72 | } |
75 | 73 | ||
76 | public void setFtpUserName(String ftpUserName) { | 74 | public void setFtpUserName(String ftpUserName) { |
77 | this.ftpUserName = ftpUserName; | 75 | this.ftpUserName = ftpUserName; |
78 | } | 76 | } |
79 | 77 | ||
80 | public String getFtpPassword() { | 78 | private String undoFilter(String fileContents) { |
81 | return ftpPassword; | 79 | StringWriter stringWriter = new StringWriter(); |
82 | } | 80 | FromIBGFilter fromFilter = new FromIBGFilter(); |
81 | fromFilter.doFilter(new StringReader(fileContents), stringWriter); | ||
83 | 82 | ||
84 | public void setFtpPassword(String ftpPassword) { | 83 | return stringWriter.toString(); |
85 | this.ftpPassword = ftpPassword; | ||
86 | } | 84 | } |
87 | 85 | ||
88 | } | 86 | } |
Download diff