001: /**
002: *
003: * Copyright (C) 2007 Enterprise Distributed Technologies Ltd
004: *
005: * www.enterprisedt.com
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * Bug fixes, suggestions and comments should be should posted on
022: * http://www.enterprisedt.com/forums/index.php
023: *
024: * Change Log:
025: *
026: * $Log: AdvancedFTPSettings.java,v $
027: * Revision 1.1 2007-12-18 07:52:06 bruceb
028: * 2.0 changes
029: *
030: *
031: */package com.enterprisedt.net.ftp;
032:
033: import java.util.Locale;
034:
035: /**
036: * Holds advanced configuration options not likely to be used for
037: * basic FTP operations. These options must be set prior to establishing
038: * connections, otherwise they have no effect until a new connection is made.
039: *
040: * @author Bruce Blackshaw
041: * @version $Revision: 1.1 $
042: */
043: public class AdvancedFTPSettings extends AdvancedSettings {
044:
045: /**
046: * Constructor
047: *
048: * @param context context that settings are kept in
049: */
050: AdvancedFTPSettings(ConnectionContext context) {
051: super (context);
052: }
053:
054: /**
055: * Get the data transfer mode. This only applies to the FTP and FTPS
056: * protocols.
057: *
058: * @return the data transfer mode of the master context
059: */
060: public FTPConnectMode getConnectMode() {
061: return context.getConnectMode();
062: }
063:
064: /**
065: * Set the data transfer mode to either active (PORT) or passive (PASV).
066: * Only applicable to FTP/S. Setting applies to all subsequent transfers
067: * that are initiated.
068: *
069: * @param mode data transfer mode to set
070: * @throws FTPException
071: */
072: public void setConnectMode(FTPConnectMode mode) throws FTPException {
073: context.setConnectMode(mode);
074: }
075:
076: /**
077: * Set strict checking of FTP return codes. If strict
078: * checking is on (the default) code must exactly match the expected
079: * code. If strict checking is off, only the first digit must match.
080: *
081: * @param strict true for strict checking, false for loose checking
082: */
083: public void setStrictReturnCodes(boolean strict) {
084: context.setStrictReturnCodes(strict);
085: }
086:
087: /**
088: * Determine if strict checking of return codes is switched on. If it is
089: * (the default), all return codes must exactly match the expected code.
090: * If strict checking is off, only the first digit must match.
091: *
092: * @return true if strict return code checking, false if non-strict.
093: */
094: public boolean isStrictReturnCodes() {
095: return context.isStrictReturnCodes();
096: }
097:
098: /**
099: * Set the list of locales to be tried for date parsing of directory listings
100: *
101: * @param locales locales to use
102: */
103: public void setParserLocales(Locale[] locales) {
104: context.setParserLocales(locales);
105: }
106:
107: /**
108: * Get the current parser locales used for directory listing parsing
109: *
110: * @return Locale[]
111: */
112: public Locale[] getParserLocales() {
113: return context.getParserLocales();
114: }
115:
116: /**
117: * Is automatic substitution of the remote host IP set to
118: * be on for passive mode connections?
119: *
120: * @return true if set on, false otherwise
121: */
122: public boolean isAutoPassiveIPSubstitution() {
123: return context.isAutoPassiveIPSubstitution();
124: }
125:
126: /**
127: * Set automatic substitution of the remote host IP on if
128: * in passive mode
129: *
130: * @param autoPassiveIPSubstitution true if set to on, false otherwise
131: */
132: public void setAutoPassiveIPSubstitution(
133: boolean autoPassiveIPSubstitution) {
134: context.setAutoPassiveIPSubstitution(autoPassiveIPSubstitution);
135: }
136:
137: /**
138: * Force a certain range of ports to be used in active mode. This is
139: * generally so that a port range can be configured in a firewall. Note
140: * that if lowest == highest, a single port will be used. This works well
141: * for uploads, but downloads generally require multiple ports, as most
142: * servers fail to create a connection repeatedly for the same port.
143: *
144: * @param lowest Lower limit of range (should be >= 1024).
145: * @param highest Upper limit of range.(should be <= 65535)
146: */
147: public void setActivePortRange(int lowest, int highest) {
148: context.setActivePortRange(lowest, highest);
149: }
150:
151: /**
152: * Get the lower limit of the port range for active mode.
153: *
154: * @return lower limit, or -1 if not set
155: */
156: public int getActiveLowPort() {
157: return context.getActiveLowPort();
158: }
159:
160: /**
161: * Get the upper limit of the port range for active mode.
162: *
163: * @return upper limit, or -1 if not set
164: */
165: public int getActiveHighPort() {
166: return context.getActiveHighPort();
167: }
168:
169: /**
170: * We can force PORT to send a fixed IP address, which can be useful with certain
171: * NAT configurations.
172: *
173: * @param activeIP IP address to force, in 192.168.1.0 form or in IPV6 form, e.g.
174: * 1080::8:800:200C:417A
175: */
176: public void setActiveIPAddress(String activeIP) {
177:
178: context.setActiveIPAddress(activeIP);
179: }
180:
181: /**
182: * The active IP address being used, or null if not used
183: * @return IP address as a string or null
184: */
185: public String getActiveIPAddress() {
186: return context.getActiveIPAddress();
187: }
188:
189: /**
190: * Get class that holds fragments of server messages that indicate a file was
191: * not found. New messages can be added.
192: * <p>
193: * The fragments are used when it is necessary to examine the message
194: * returned by a server to see if it is saying a file was not found.
195: * If an FTP server is returning a different message that still clearly
196: * indicates a file was not found, use this property to add a new server
197: * fragment to the repository via the add method. It would be helpful to
198: * email support at enterprisedt dot com to inform us of the message so
199: * it can be added to the next build.
200: *
201: * @return messages class
202: */
203: public FileNotFoundStrings getFileNotFoundMessages() {
204: return context.getFileNotFoundMessages();
205: }
206:
207: /**
208: * Get class that holds fragments of server messages that indicate a transfer completed.
209: * New messages can be added.
210: * <p>
211: * The fragments are used when it is necessary to examine the message
212: * returned by a server to see if it is saying a transfer completed.
213: * If an FTP server is returning a different message that still clearly
214: * indicates a transfer failed, use this property to add a new server
215: * fragment to the repository via the add method. It would be helpful to
216: * email support at enterprisedt dot com to inform us of the message so
217: * it can be added to the next build.
218: *
219: * @return messages class
220: */
221: public TransferCompleteStrings getTransferCompleteMessages() {
222: return context.getTransferCompleteMessages();
223: }
224:
225: /**
226: * Get class that holds fragments of server messages that indicate a
227: * directory is empty. New messages can be added.
228: * <p>
229: * The fragments are used when it is necessary to examine the message
230: * returned by a server to see if it is saying a directory is empty.
231: * If an FTP server is returning a different message that still clearly
232: * indicates a directory is empty, use this property to add a new server
233: * fragment to the repository via the add method. It would be helpful to
234: * email support at enterprisedt dot com to inform us of the message so
235: * it can be added to the next build.
236: *
237: * @return messages class
238: */
239: public DirectoryEmptyStrings getDirectoryEmptyMessages() {
240: return context.getDirectoryEmptyMessages();
241: }
242: }
|