1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ftp.server;
12
13 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
14 import org.apache.commons.logging.Log;
15 import org.apache.commons.logging.LogFactory;
16 import org.apache.ftpserver.ftplet.FileObject;
17 import org.apache.ftpserver.ftplet.FileSystemView;
18 import org.apache.ftpserver.ftplet.FtpException;
19
20 public class FileView implements FileSystemView
21 {
22
23 protected final Log logger = LogFactory.getLog(getClass());
24 private CountDownLatch started = new CountDownLatch(1);
25 private ServerState state;
26
27 public FileView(ServerState state)
28 {
29 this.state = state;
30 }
31
32 public void flagStarted(int count)
33 {
34 started.countDown();
35 }
36
37 public FileObject getHomeDirectory() throws FtpException
38 {
39 return new Directory("/", state);
40 }
41
42 public FileObject getCurrentDirectory() throws FtpException
43 {
44 return new Directory("/", state);
45 }
46
47 public boolean changeDirectory(String dir) throws FtpException
48 {
49 return true;
50 }
51
52 public FileObject getFileObject(String name) throws FtpException
53 {
54 logger.debug("request for: " + name);
55 if (state.getDownloadNames().contains(name))
56 {
57 return new DownloadFile(name, state);
58 }
59
60 else if (null != name && name.endsWith("/"))
61 {
62 return new Directory(name, state);
63 }
64 else
65 {
66 return new UploadFile(name, state);
67 }
68 }
69
70 public boolean isRandomAccessible() throws FtpException
71 {
72 return true;
73 }
74
75 public void dispose()
76 {
77
78 }
79
80 }