|
Commons Net example source code file (MVSFTPEntryParser.java)
The Commons Net MVSFTPEntryParser.java source code
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.text.ParseException;
import java.util.List;
import org.apache.commons.net.ftp.FTPClientConfig;
import org.apache.commons.net.ftp.FTPFile;
/**
* Implementation of FTPFileEntryParser and FTPFileListParser for IBM zOS/MVS
* Systems.
*
* @author <a href="henrik.sorensen@balcab.ch">Henrik Sorensen
* @author <a href="jnadler@srcginc.com">Jeff Nadler
* @author <a href="wnoto@openfinance.com">William Noto
*
* @version $Id: MVSFTPEntryParser.java 1081476 2011-03-14 17:09:59Z sebb $
* @see org.apache.commons.net.ftp.FTPFileEntryParser FTPFileEntryParser (for
* usage instructions)
*/
public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
static final int UNKNOWN_LIST_TYPE = -1;
static final int FILE_LIST_TYPE = 0;
static final int MEMBER_LIST_TYPE = 1;
static final int UNIX_LIST_TYPE = 2;
static final int JES_LEVEL_1_LIST_TYPE = 3;
static final int JES_LEVEL_2_LIST_TYPE = 4;
private int isType = UNKNOWN_LIST_TYPE;
/**
* Fallback parser for Unix-style listings
*/
private UnixFTPEntryParser unixFTPEntryParser;
/**
* Dates are ignored for file lists, but are used for member lists where
* possible
*/
static final String DEFAULT_DATE_FORMAT = "yyyy/MM/dd HH:mm"; // 2001/09/18
// 13:52
/**
* Matches these entries: Volume Unit Referred Ext Used Recfm Lrecl BlkSz
* Dsorg Dsname B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK
*
*/
static final String FILE_LIST_REGEX = "\\S+\\s+" + // volume
// ignored
"\\S+\\s+" + // unit - ignored
"\\S+\\s+" + // access date - ignored
"\\S+\\s+" + // extents -ignored
"\\S+\\s+" + // used - ignored
"[FV]\\S*\\s+" + // recfm - must start with F or V
"\\S+\\s+" + // logical record length -ignored
"\\S+\\s+" + // block size - ignored
"(PS|PO|PO-E)\\s+" + // Dataset organisation. Many exist
// but only support: PS, PO, PO-E
"(\\S+)\\s*"; // Dataset Name (file name)
/**
* Matches these entries: Name VV.MM Created Changed Size Init Mod Id
* TBSHELF 01.03 2002/09/12 2002/10/11 09:37 11 11 0 KIL001
*/
static final String MEMBER_LIST_REGEX = "(\\S+)\\s+" + // name
"\\S+\\s+" + // version, modification (ignored)
"\\S+\\s+" + // create date (ignored)
"(\\S+)\\s+" + // modification date
"(\\S+)\\s+" + // modification time
"\\S+\\s+" + // size in lines (ignored)
"\\S+\\s+" + // size in lines at creation(ignored)
"\\S+\\s+" + // lines modified (ignored)
"\\S+\\s*"; // id of user who modified (ignored)
/**
* Matches these entries, note: no header: IBMUSER1 JOB01906 OUTPUT 3 Spool
* Files 012345678901234567890123456789012345678901234 1 2 3 4
*/
static final String JES_LEVEL_1_LIST_REGEX = "(\\S+)\\s+" + // job
// name
// ignored
"(\\S+)\\s+" + // job number
"(\\S+)\\s+" + // job status (OUTPUT,INPUT,ACTIVE)
"(\\S+)\\s+" + // number of spool files
"(\\S+)\\s+" + // Text "Spool" ignored
"(\\S+)\\s*" // Text "Files" ignored
;
/**
* JES INTERFACE LEVEL 2 parser Matches these entries: JOBNAME JOBID OWNER
* STATUS CLASS IBMUSER1 JOB01906 IBMUSER OUTPUT A RC=0000 3 spool files
* IBMUSER TSU01830 IBMUSER OUTPUT TSU ABEND=522 3 spool files
* 012345678901234567890123456789012345678901234 1 2 3 4
* 012345678901234567890123456789012345678901234567890
*/
static final String JES_LEVEL_2_LIST_REGEX = "(\\S+)\\s+" + // job
// name
// ignored
"(\\S+)\\s+" + // job number
"(\\S+)\\s+" + // owner ignored
"(\\S+)\\s+" + // job status (OUTPUT,INPUT,ACTIVE) ignored
"(\\S+)\\s+" + // job class ignored
"(\\S+).*" // rest ignored
;
/*
* ---------------------------------------------------------------------
* Very brief and incomplete description of the zOS/MVS-filesystem. (Note:
* "zOS" is the operating system on the mainframe, and is the new name for
* MVS)
*
* The filesystem on the mainframe does not have hierarchal structure as for
* example the unix filesystem. For a more comprehensive description, please
* refer to the IBM manuals
*
* @LINK:
* http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/dgt2d440/CONTENTS
*
*
* Dataset names =============
*
* A dataset name consist of a number of qualifiers separated by '.', each
* qualifier can be at most 8 characters, and the total length of a dataset
* can be max 44 characters including the dots.
*
*
* Dataset organisation ====================
*
* A dataset represents a piece of storage allocated on one or more disks.
* The structure of the storage is described with the field dataset
* organinsation (DSORG). There are a number of dataset organisations, but
* only two are usable for FTP transfer.
*
* DSORG: PS: sequential, or flat file PO: partitioned dataset PO-E:
* extended partitioned dataset
*
* The PS file is just a flat file, as you would find it on the unix file
* system.
*
* The PO and PO-E files, can be compared to a single level directory
* structure. A PO file consist of a number of dataset members, or files if
* you will. It is possible to CD into the file, and to retrieve the
* individual members.
*
*
* Dataset record format =====================
*
* The physical layout of the dataset is described on the dataset itself.
* There are a number of record formats (RECFM), but just a few is relavant
* for the FTP transfer.
*
* Any one beginning with either F or V can safely used by FTP transfer. All
* others should only be used with great care, so this version will just
* ignore the other record formats. F means a fixed number of records per
* allocated storage, and V means a variable number of records.
*
*
* Other notes ===========
*
* The file system supports automatically backup and retrieval of datasets.
* If a file is backed up, the ftp LIST command will return: ARCIVE Not
* Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST
*
*
* Implementation notes ====================
*
* Only datasets that have dsorg PS, PO or PO-E and have recfm beginning
* with F or V, is fully parsed.
*
* The following fields in FTPFile is used: FTPFile.Rawlisting: Always set.
* FTPFile.Type: DIRECTORY_TYPE or FILE_TYPE or UNKNOWN FTPFile.Name: name
* FTPFile.Timestamp: change time or null
*
*
*
* Additional information ======================
*
* The MVS ftp server supports a number of features via the FTP interface.
* The features are controlled with the FTP command quote site filetype=<SEQ|JES|DB2>
* SEQ is the default and used for normal file transfer JES is used to
* interact with the Job Entry Subsystem (JES) similar to a job scheduler
* DB2 is used to interact with a DB2 subsystem
*
* This parser supports SEQ and JES.
*
*
*
*
*
*
*/
/**
* The sole constructor for a MVSFTPEntryParser object.
*
*/
public MVSFTPEntryParser() {
super(""); // note the regex is set in preParse.
super.configure(null); // configure parser with default configurations
}
/**
* Parses a line of an z/OS - MVS FTP server file listing and converts it
* into a usable format in the form of an <code> FTPFile instance.
* If the file listing line doesn't describe a file, then
* <code> null is returned. Otherwise a
Other Commons Net examples (source code examples)Here is a short list of links related to this Commons Net MVSFTPEntryParser.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.