Hi List, This is my first post to this list ...
I have been chasing some problems when using the optional ant task FTP to access a MVS type host. Part of the problem is the MVSFTPEntryParser.java seems to be only halfway implemented. Here is a updated version of org/apache/commons/net/ftp/parser/MVSFTPEntryParser.java for review, note there is a lot of debug info, and further note, I am not really a java programmer but are willing to learn, so just shoot on whatever is moving ... looking forward to hear your comments. Henrik
/* * Copyright 2005 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.net.ftp.parser; import java.util.List; import java.util.StringTokenizer; import org.apache.commons.net.ftp.FTPClientConfig; import org.apache.commons.net.ftp.FTPFile; /** * Implementation of FTPFileEntryParser and FTPFileListParser for IBM MVS Systems. * * @author <a href="[EMAIL PROTECTED]">Jeff Nadler</a> * @author <a href="[EMAIL PROTECTED]">William Noto</a> * @version $Id$ * @see org.apache.commons.net.ftp.FTPFileEntryParser FTPFileEntryParser (for usage instructions) */ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl { /** * This is the regular expression used by this parser. */ private static final String REGEX = "(.*)\\s+([^\\s]+)\\s*"; /** * Although this parser is now ignoring dates, someone may someday * figure out a way to accomodate this and this appears to be the * format used. For now, it won't be used. * SMC 2005/04/08 */ static final String DEFAULT_DATE_FORMAT = "yyyy/MM/dd"; // 2001/11/09 // This is not at all the tightest possible regexp for MVS LIST // output, but I'm not a mainframe guru so I have little idea what the // range of valid values are. I just needed to get the filename (Dsname); // note that no other FTPFile fields can be filled in with the results of // a LIST on MVS. The 'Referred' date seems to be 'last accessed date' // and not 'last modified date' so I didn't bother parsing it. // // Of course it works perfectly as-is and it distinguishes header lines from // file results so that's the important thing. // // This parser should be used when SYST returns: // 'MVS is the operating system of this server. FTP Server is running on z/OS.' // // Also note that there is no concept of directories in MVS, just datasets, // which have names composed of four dot separated names of up to 8 chars. // As a result, FTPFile.FILE_TYPE is always used. -JN 6/2004 jnadler<at>srcginc<dotcom> // Sample LIST results from MVS: // //Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname //FPFS42 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM023.D061704 //FPFS41 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.RPTBM056.D061704 //FPFS25 3390 2004/06/23 1 1 FB 128 6144 PS INCOMING.WTM204.D061704 /* Format of ZOS files: * Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname B10142 3390 2006/03/20 2 31 F 80 80 PS CMN.CREF.WORK ARCIVE Not Direct Access Device NI.NI6860.ERROR.PL.UNITTEST B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU B1N192 3390 2006/03/03 1 10 U 13680 13680 PS RZ1.A74A7198.BACKUP B11298 3390 2006/03/20 1 1 FB 150 6000 PS RZ1.BRODCAST.DATA B11199 3390 2006/03/03 1 10 U 13680 13680 PS RZ1.ISR8062.BACKUP ARCIVE Not Direct Access Device SQLXPLR.CNTL B11256 3390 2006/03/17 1 62 FB 80 27920 PO TBOX.TABLES ARCIVE Not Direct Access Device WOK.NI.NI6860.EXCEL.DIFFER * */ // last two tokens describe file: // 'PS': sequential file // 'PO': PDS // 'PO-E': PDS Library // ' ': unknown, probably archived. /* * Format of a PDS * 0 1 2 3 4 5 6 7 8 * Name VV.MM Created Changed Size Init Mod Id TBSHELF 01.03 2002/09/12 2002/10/11 09:37 11 11 0 A338692 TBTOOL 01.12 2002/09/12 2004/11/26 19:54 51 28 0 A338692 * */ /** * The sole constructor for a MVSFTPEntryParser object. * * @exception IllegalArgumentException * Thrown if the regular expression is unparseable. Should not be seen * under normal conditions. It it is seen, this is a sign that * <code>REGEX</code> is not a valid regular expression. */ public MVSFTPEntryParser() { super(REGEX); } /** * Parses a line of an MVS FTP server file listing and converts it into a * usable format in the form of an <code> FTPFile </code> instance. If the * file listing line doesn't describe a file, <code> null </code> is * returned, otherwise a <code> FTPFile </code> instance representing the * files in the directory is returned. * <p> * @param entry A line of text from the file listing * @return An FTPFile instance corresponding to the supplied entry */ public FTPFile parseFTPEntry(String entry) { FTPFile f = null; String zosDirectoryEntry[]=new String[10] ; System.out.println("MVSFTPEntryParser entry "+entry); StringTokenizer tok = new StringTokenizer(entry); //$NON-NLS-1$ int tokCount; tokCount=0; while (tok.hasMoreTokens()) { String token = tok.nextToken(); zosDirectoryEntry[tokCount]=token; //System.out.println("MVSFTPEntryParser token ["+tokCount+"] "+token); tokCount++; } if (tokCount>0) { // TODO: skip recfm=u, skip archived, check vsam ... if(tokCount==10) { if ( zosDirectoryEntry[0].equalsIgnoreCase("Volume") &&zosDirectoryEntry[9].equalsIgnoreCase("Dsname") ) return null; /* skip header */ f = new FTPFile(); f.setRawListing(entry); f.setName(zosDirectoryEntry[9]); //DSORG if (zosDirectoryEntry[8].equals("PS")) f.setType(FTPFile.FILE_TYPE); else if (zosDirectoryEntry[8].equals("PO") ||zosDirectoryEntry[8].equals("PO-E") ) f.setType(FTPFile.DIRECTORY_TYPE); else f.setType(FTPFile.UNKNOWN_TYPE); //System.out.println("Name "+f.getName()+", type "+f.getType()+", rawlisting "+f.getRawListing()); return (f); } else if(tokCount==9) { if ( zosDirectoryEntry[0].equalsIgnoreCase("Name") &&zosDirectoryEntry[8].equalsIgnoreCase("Id") ) return null; /* skip header */ f = new FTPFile(); f.setRawListing(entry); f.setName(zosDirectoryEntry[0]); f.setType(FTPFile.FILE_TYPE); // System.out.println("Name "+f.getName()+", type "+f.getType()+", rawlisting "+f.getRawListing()); return f; } } return null; } public List preParse(List org) {System.out.println("MVSFTPEntryParser ... preParse .. List org: "+org); return org; } /* * @return */ protected FTPClientConfig getDefaultConfiguration() { return new FTPClientConfig( FTPClientConfig.SYST_MVS, DEFAULT_DATE_FORMAT, null, null, null, null); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]