Skip to content

Commit

Permalink
Change Class "org.apache.commons.net.ftp.parser.MVSFTPEntryParser" to
Browse files Browse the repository at this point in the history
support more datasets #182

- Javadoc
- Simplify
- Don't scan entry twice
  • Loading branch information
garydgregory committed Sep 13, 2023
1 parent 0d7c9cc commit 2134962
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="David Costanzo, Gary Gregory" issue="NET-722">
Javadoc for FtpClient.setControlKeepAliveReplyTimeout(Duration) says timeout is in milliseconds.
</action>
<action type="fix" dev="ggregory" due-to="haegar9766, Gary Gregory">
Change class org.apache.commons.net.ftp.parser.MVSFTPEntryParser to support more datasets #182.
</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot">
Bump commons-parent from 54 to 62 #132, #137, #153.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,10 @@ public class MVSFTPEntryParser extends ConfigurableFTPFileEntryParserImpl {
* 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.
Expand All @@ -239,19 +232,20 @@ protected FTPClientConfig getDefaultConfiguration() {
}

/**
* Parse entries representing a dataset list.
* <p>
* Parses entries representing a dataset list.
* <pre>
* Format of ZOS/MVS file list: 1 2 3 4 5 6 7 8 9 10
* Volume Unit Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname
* B10142 3390 2006/03/20 2 31 F 80 80 PS MDI.OKL.WORK
* ARCIVE Not Direct Access Device KJ.IOP998.ERROR.PL.UNITTEST
* B1N231 3390 2006/03/20 1 15 VB 256 27998 PO PLU
* B1N231 3390 2006/03/20 1 15 VB 256 27998 PO-E PLB
* Migrated HLQ.DATASET.NAME
* <p>
* </pre>
* <pre>
* ----------------------------------- Group within Regex [1] Volume [2] Unit [3] Referred [4] Ext: number of extents [5] Used [6] Recfm: Record format [7]
* Lrecl: Logical record length [8] BlkSz: Block size [9] Dsorg: Dataset organisation. Many exists but only support: PS, PO, PO-E [10] Dsname: Dataset name
* <p>
* </pre>
*
* @param entry zosDirectoryEntry
* @return null: entry was not parsed.
Expand All @@ -277,18 +271,13 @@ private FTPFile parseFileList(final String entry) {
return file;
}

if (entry.startsWith("Migrated") || entry.startsWith("ARCIVE")) {
final boolean migrated = entry.startsWith("Migrated");
if (migrated || entry.startsWith("ARCIVE")) {
// Type of file is unknown for migrated datasets
final FTPFile file = new FTPFile();
file.setRawListing(entry);
file.setType(FTPFile.UNKNOWN_TYPE);

if (entry.startsWith("Migrated")) {
file.setName(entry.split("\\s+")[1]);
} else {
file.setName(entry.split("\\s+")[5]);
}

file.setName(entry.split("\\s+")[migrated ? 1 : 5]);
return file;
}

Expand Down Expand Up @@ -397,7 +386,7 @@ private FTPFile parseJeslevel2List(final String entry) {
}

/**
* Parse entries within a partitioned dataset.
* Parses entries within a partitioned dataset.
*
* Format of a memberlist within a PDS:
*
Expand Down Expand Up @@ -454,7 +443,7 @@ private FTPFile parseMemberList(final String entry) {
}

/**
* preParse is called as part of the interface. Per definition, it is called before the parsing takes place. Three kinds of lists are recognized:
* Pre-parses is called as part of the interface. Per definition, it is called before the parsing takes place. Three kinds of lists are recognized:
* <ul>
* <li>z/OS-MVS File lists,</li>
* <li>z/OS-MVS Member lists,</li>
Expand Down Expand Up @@ -497,7 +486,7 @@ public List<String> preParse(final List<String> orig) {
}

/**
* Explicitly set the type of listing being processed.
* Sets the type of listing being processed.
*
* @param type The listing type.
*/
Expand Down

0 comments on commit 2134962

Please sign in to comment.