01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: *
22: *
23: * $Id: ChangeToParentDir.java 11093 2007-12-21 18:22:22Z mpreston $
24: */
25: package com.bostechcorp.cbesb.runtime.ftp.interpreter;
26:
27: import java.io.IOException;
28: import java.util.Map;
29:
30: import org.apache.commons.logging.Log;
31: import org.apache.commons.logging.LogFactory;
32: import org.apache.commons.net.ftp.FTPClient;
33:
34: /**
35: * Changes the working directory to the parent of the current working directory.
36: *
37: * @author j.zhang
38: * @version 1.0.0
39: */
40: public class ChangeToParentDir extends AbstractCommandExpression {
41:
42: protected final transient Log logger = LogFactory
43: .getLog(getClass());
44:
45: // /**
46: // * The Map of parameters.
47: // */
48: // private Map paramMap = new HashMap<String, String>();
49:
50: @Override
51: /* (non-Javadoc)
52: * @see com.bostechcorp.cbesb.runtime.ftp.AbstractCommandExpression#interpret(java.util.Map)
53: */
54: public void interpret(Map<String, String> paramMap) {
55: // this.paramMap = paramMap;
56: }
57:
58: @Override
59: /* (non-Javadoc)
60: * @see com.bostechcorp.cbesb.runtime.ftp.AbstractCommandExpression#execute(org.apache.commons.net.ftp.FTPClient)
61: */
62: public Object execute(FtpExecContext context) {
63: logger.debug("changeToParentDir:");
64: FTPClient ftp = context.getFtpclient();
65: try {
66: boolean flag = ftp.changeToParentDirectory();
67: if (!flag) {
68: throw new Exception(
69: "Error to change to parent directory. Current working directory is: "
70: + ftp.printWorkingDirectory());
71: }
72: } catch (IOException ioe) {
73: // ioe.printStackTrace();
74: return ioe;
75: } catch (Exception e) {
76: // e.printStackTrace();
77: return e;
78: }
79: return true;
80: }
81: }
|