KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > command > impl > ftp > CdupCommand


1 /**
2  * Command CDUP.
3  * See FTP spec for details on the command.
4  */

5 package com.coldcore.coloradoftp.command.impl.ftp;
6
7 import com.coldcore.coloradoftp.command.Reply;
8 import com.coldcore.coloradoftp.command.impl.AbstractCommand;
9 import com.coldcore.coloradoftp.factory.ObjectFactory;
10 import com.coldcore.coloradoftp.factory.ObjectName;
11 import com.coldcore.coloradoftp.filesystem.FileSystem;
12 import com.coldcore.coloradoftp.session.Session;
13 import org.apache.log4j.Logger;
14
15 public class CdupCommand extends AbstractCommand {
16
17   private static Logger log = Logger.getLogger(CdupCommand.class);
18
19
20   public Reply execute() {
21     Reply reply = getReply();
22     if (!testLogin()) return reply;
23
24     Session session = controlConnection.getSession();
25     FileSystem fileSystem = (FileSystem) ObjectFactory.getObject(ObjectName.FILESYSTEM);
26     String JavaDoc curDir = fileSystem.getCurrentDirectory(session);
27     String JavaDoc cdup = fileSystem.getParent(curDir, session);
28     fileSystem.changeDirectory(cdup, session);
29
30     reply.setCode("250");
31     reply.setText("Directory changed.");
32     return reply;
33   }
34 }
35
Popular Tags