List of usage examples for org.apache.commons.net.ftp FTPClientConfig SYST_MVS
String SYST_MVS
To view the source code for org.apache.commons.net.ftp FTPClientConfig SYST_MVS.
Click Source Link
From source file:jlib.misc.MVSFTPEntryParser.java
protected FTPClientConfig getDefaultConfiguration() { return new FTPClientConfig(FTPClientConfig.SYST_MVS, DEFAULT_DATE_FORMAT, null, null, null, null); }
From source file:com.legstar.zosjes.FtpZosClient.java
/** * No-arg constructor.//from ww w . ja v a 2 s . c o m */ public FtpZosClient() { _ftpClient = new FTPClient(); FTPClientConfig ftpConf = new FTPClientConfig(FTPClientConfig.SYST_MVS); ftpConf.setServerTimeZoneId("GMT"); _ftpClient.configure(ftpConf); }
From source file:com.savy3.util.MainframeFTPClientUtils.java
public static FTPClient getFTPConnection(Configuration conf) throws IOException { FTPClient ftp = null;/*from w ww. j a v a 2s.c o m*/ try { String username = conf.get(DBConfiguration.USERNAME_PROPERTY); String password; if (username == null) { username = "anonymous"; password = ""; } else { password = DBConfiguration.getPassword((JobConf) conf); } String connectString = conf.get(DBConfiguration.URL_PROPERTY); String server = connectString; int port = 0; String[] parts = connectString.split(":"); if (parts.length == 2) { server = parts[0]; try { port = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { LOG.warn("Invalid port number: " + e.toString()); } } if (null != mockFTPClient) { ftp = mockFTPClient; } else { ftp = new FTPClient(); } FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_MVS); ftp.configure(config); if (conf.getBoolean(JobBase.PROPERTY_VERBOSE, false)) { ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true)); } try { if (port > 0) { ftp.connect(server, port); } else { ftp.connect(server); } } catch (IOException ioexp) { throw new IOException("Could not connect to server " + server, ioexp); } int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { throw new IOException("FTP server " + server + " refused connection:" + ftp.getReplyString()); } LOG.info("Connected to " + server + " on " + (port > 0 ? port : ftp.getDefaultPort())); System.out.println("Connected to " + server + " on " + (port > 0 ? port : ftp.getDefaultPort())); if (!ftp.login(username, password)) { ftp.logout(); throw new IOException("Could not login to server " + server + ":" + ftp.getReplyString()); } // set Binary transfer mode ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.featureValue("LITERAL SITE RDW"); ftp.doCommand("SITE", "RDW"); System.out.println("reply for LITERAL" + ftp.getReplyString()); // Use passive mode as default. ftp.enterLocalPassiveMode(); } catch (IOException ioe) { if (ftp != null && ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException f) { // do nothing } } ftp = null; throw ioe; } return ftp; }
From source file:ch.cyberduck.core.ftp.FTPParserFactory.java
public CompositeFileEntryParser createFileEntryParser(final String system, final TimeZone timezone) throws ParserInitializationException { if (null != system) { String ukey = system.toUpperCase(Locale.ROOT); if (ukey.contains(FTPClientConfig.SYST_UNIX)) { return this.createUnixFTPEntryParser(timezone); } else if (ukey.contains(FTPClientConfig.SYST_VMS)) { throw new ParserInitializationException( String.format("\"%s\" is not currently a supported system.", system)); } else if (ukey.contains(FTPClientConfig.SYST_NETWARE)) { return this.createNetwareFTPEntryParser(timezone); } else if (ukey.contains(FTPClientConfig.SYST_NT)) { return this.createNTFTPEntryParser(timezone); } else if (ukey.contains(FTPClientConfig.SYST_OS2)) { return this.createOS2FTPEntryParser(timezone); } else if (ukey.contains(FTPClientConfig.SYST_OS400)) { return this.createOS400FTPEntryParser(timezone); } else if (ukey.contains(FTPClientConfig.SYST_MVS)) { return this.createUnixFTPEntryParser(timezone); }/* w ww . jav a 2s .c om*/ } // Defaulting to UNIX parser return this.createUnixFTPEntryParser(timezone); }
From source file:it.greenvulcano.util.remotefs.ftp.FTPManager.java
/** * @see it.greenvulcano.util.remotefs.RemoteManager#init(Node) *//* w ww .j av a 2 s. c o m*/ @Override public void init(Node node) throws RemoteManagerException { super.init(node); try { hostType = TargetType.valueOf(XMLConfig.get(node, "@hostType")); logger.debug("host-type : " + hostType); FTPClientConfig conf = null; switch (hostType) { case MVS: { conf = new FTPClientConfig(FTPClientConfig.SYST_MVS); break; } case NT: { conf = new FTPClientConfig(FTPClientConfig.SYST_NT); break; } case OS2: { conf = new FTPClientConfig(FTPClientConfig.SYST_OS2); break; } case OS400: { conf = new FTPClientConfig(FTPClientConfig.SYST_OS400); break; } case UNIX: { conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX); break; } case VMS: { conf = new FTPClientConfig(FTPClientConfig.SYST_VMS); break; } } ftpClient.configure(conf); ftpClient.setDefaultTimeout(connectTimeout); ftpClient.setDataTimeout(dataTimeout); } catch (Exception exc) { throw new RemoteManagerException("Initialization error", exc); } }
From source file:org.apache.sqoop.connector.mainframe.MainframeFTPClientUtils.java
public static FTPClient getFTPConnection(TransferableContext context, LinkConfiguration linkConfiguration) throws IOException { FTPClient ftp = null;//ww w . j av a2 s . co m try { String username = linkConfiguration.linkConfig.username; String password; if (username == null) { username = "anonymous"; password = ""; } else { password = linkConfiguration.linkConfig.password; } String connectString = linkConfiguration.linkConfig.uri; String server = connectString; int port = 0; String[] parts = connectString.split(":"); if (parts.length == 2) { server = parts[0]; try { port = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { LOG.warn("Invalid port number: " + e.toString()); } } if (null != mockFTPClient) { ftp = mockFTPClient; } else { ftp = new FTPClient(); } // The following section to get the system key for FTPClientConfig is just there for testing purposes String systemKey = null; String systemTypeString = context.getString("spark.mainframe.connector.system.type", "MVS"); if (systemTypeString.equals("MVS")) { systemKey = FTPClientConfig.SYST_MVS; } else if (systemTypeString.equals("UNIX")) { systemKey = FTPClientConfig.SYST_UNIX; } else { assert (false); } FTPClientConfig config = new FTPClientConfig(systemKey); ftp.configure(config); try { if (port > 0) { ftp.connect(server, port); } else { ftp.connect(server); } } catch (IOException ioexp) { throw new IOException("Could not connect to server " + server, ioexp); } int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { throw new IOException("FTP server " + server + " refused connection:" + ftp.getReplyString()); } LOG.info("Connected to " + server + " on " + (port > 0 ? port : ftp.getDefaultPort())); if (!ftp.login(username, password)) { ftp.logout(); throw new IOException("Could not login to server " + server + ":" + ftp.getReplyString()); } // set ASCII transfer mode ftp.setFileType(FTP.ASCII_FILE_TYPE); // Use passive mode as default. ftp.enterLocalPassiveMode(); } catch (IOException ioe) { if (ftp != null && ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException f) { // do nothing } } ftp = null; throw ioe; } return ftp; }
From source file:org.apache.sqoop.util.MainframeFTPClientUtils.java
public static FTPClient getFTPConnection(Configuration conf) throws IOException { FTPClient ftp = null;/*www . j a va 2s .co m*/ try { String username = conf.get(DBConfiguration.USERNAME_PROPERTY); String password; if (username == null) { username = "anonymous"; password = ""; } else { password = DBConfiguration.getPassword((JobConf) conf); } String connectString = conf.get(DBConfiguration.URL_PROPERTY); String server = connectString; int port = 0; String[] parts = connectString.split(":"); if (parts.length == 2) { server = parts[0]; try { port = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { LOG.warn("Invalid port number: " + e.toString()); } } if (null != mockFTPClient) { ftp = mockFTPClient; } else { ftp = new FTPClient(); } FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_MVS); ftp.configure(config); if (conf.getBoolean(JobBase.PROPERTY_VERBOSE, false)) { ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true)); } try { if (port > 0) { ftp.connect(server, port); } else { ftp.connect(server); } } catch (IOException ioexp) { throw new IOException("Could not connect to server " + server, ioexp); } int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { throw new IOException("FTP server " + server + " refused connection:" + ftp.getReplyString()); } LOG.info("Connected to " + server + " on " + (port > 0 ? port : ftp.getDefaultPort())); if (!ftp.login(username, password)) { ftp.logout(); throw new IOException("Could not login to server " + server + ":" + ftp.getReplyString()); } // set ASCII transfer mode ftp.setFileType(FTP.ASCII_FILE_TYPE); // Use passive mode as default. ftp.enterLocalPassiveMode(); LOG.info("System type detected: " + ftp.getSystemType()); } catch (IOException ioe) { if (ftp != null && ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException f) { // do nothing } } ftp = null; throw ioe; } return ftp; }
From source file:org.openo.nfvo.emsdriver.commons.ftp.ExtendsDefaultFTPFileEntryParserFactory.java
/** * This default implementation of the FTPFileEntryParserFactory * interface works according to the following logic: * First it attempts to interpret the supplied key as a fully * qualified classname of a class implementing the * FTPFileEntryParser interface. If that succeeds, a parser * object of this class is instantiated and is returned; * otherwise it attempts to interpret the key as an identirier * commonly used by the FTP SYST command to identify systems. * <p/>//from www . ja va 2 s . co m * If <code>key</code> is not recognized as a fully qualified * classname known to the system, this method will then attempt * to see whether it <b>contains</b> a string identifying one of * the known parsers. This comparison is <b>case-insensitive</b>. * The intent here is where possible, to select as keys strings * which are returned by the SYST command on the systems which * the corresponding parser successfully parses. This enables * this factory to be used in the auto-detection system. * <p/> * * @param key should be a fully qualified classname corresponding to * a class implementing the FTPFileEntryParser interface<br/> * OR<br/> * a string containing (case-insensitively) one of the * following keywords: * <ul> * <li>{@link FTPClientConfig#SYST_UNIX UNIX}</li> * <li>{@link FTPClientConfig#SYST_NT WINDOWS}</li> * <li>{@link FTPClientConfig#SYST_OS2 OS/2}</li> * <li>{@link FTPClientConfig#SYST_OS400 OS/400}</li> * <li>{@link FTPClientConfig#SYST_VMS VMS}</li> * <li>{@link FTPClientConfig#SYST_MVS MVS}</li> * </ul> * @return the FTPFileEntryParser corresponding to the supplied key. * @throws ParserInitializationException thrown if for any reason the factory cannot resolve * the supplied key into an FTPFileEntryParser. * @see FTPFileEntryParser */ public FTPFileEntryParser createFileEntryParser(String key) { @SuppressWarnings("rawtypes") Class parserClass = null; FTPFileEntryParser parser = null; try { parserClass = Class.forName(key); parser = (FTPFileEntryParser) parserClass.newInstance(); } catch (ClassNotFoundException e) { String ukey = null; if (null != key) { ukey = key.toUpperCase(); } if (ukey.indexOf(FTPClientConfig.SYST_UNIX) >= 0) { parser = createUnixFTPEntryParser(); } else if (ukey.indexOf(FTPClientConfig.SYST_VMS) >= 0) { parser = createVMSVersioningFTPEntryParser(); } else if (ukey.indexOf(FTPClientConfig.SYST_NT) >= 0 || ukey.indexOf("DOPRA") >= 0 || ukey.indexOf("MSDOS") >= 0) { parser = createNTFTPEntryParser(); } else if (ukey.indexOf(FTPClientConfig.SYST_OS2) >= 0) { parser = createOS2FTPEntryParser(); } else if (ukey.indexOf(FTPClientConfig.SYST_OS400) >= 0) { parser = createOS400FTPEntryParser(); } else if (ukey.indexOf(FTPClientConfig.SYST_MVS) >= 0) { parser = createMVSEntryParser(); } else { throw new ParserInitializationException("Unknown parser type: " + key); } } catch (ClassCastException e) { throw new ParserInitializationException(parserClass.getName() + " does not implement the interface " + "org.apache.commons.net.ftp.FTPFileEntryParser.", e); } catch (Throwable e) { throw new ParserInitializationException("Error initializing parser", e); } if (parser instanceof Configurable) { ((Configurable) parser).configure(this.config); } return parser; }