Re: cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser VMSFTPEntryParser.java

2004-02-19 Thread Daniel F. Savarese

In message [EMAIL PROTECTED], [EMAIL PROTECTED] 
writes:
   FTPFile[] results;
   
   if ((socket = _openDataConnection_(FTPCommand.LIST, pathname)) 
== null)
  -return null;
  +return new FTPFile[0];

I don't think that's the right behavior.  Maybe the old behavior wasn't
the best either.  The old behavior was:
  Returns:
The list of file information contained in the current working directory.
null if the list could not be obtained or if there are no files in
the directory.

Perhaps the combination of the old and new is best, which would return
a zero-length FTPFile array if there are no files in a directory, but
would return null if the list could not be obtained.  The thing is
that if a data connection cannot be established, I don't think you
want to be left believing the directory was empty.  Alternatively, an
IOException could be thrown, but I'm not sure if that's necessary
when the control connection is still functioning.  Anyway, it's
something to think about.

daniel



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser VMSFTPEntryParser.java VMSVersioningFTPEntryParser.java

2004-01-15 Thread scohen
scohen  2004/01/15 18:15:37

  Modified:net/src/java/org/apache/commons/net/ftp
DefaultFTPFileListParser.java FTPClient.java
FTPFileEntryParser.java FTPFileListParserImpl.java
   net/src/java/org/apache/commons/net/ftp/parser
VMSFTPEntryParser.java
VMSVersioningFTPEntryParser.java
  Log:
  remove unnecessary import statements
  
  Revision  ChangesPath
  1.10  +0 -7  
jakarta-commons/net/src/java/org/apache/commons/net/ftp/DefaultFTPFileListParser.java
  
  Index: DefaultFTPFileListParser.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/DefaultFTPFileListParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DefaultFTPFileListParser.java 6 Jan 2004 19:53:58 -   1.9
  +++ DefaultFTPFileListParser.java 16 Jan 2004 02:15:37 -  1.10
  @@ -54,13 +54,6 @@
* http://www.apache.org/.
*/
   
  -import java.io.BufferedReader;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.InputStreamReader;
  -import java.util.Calendar;
  -import java.util.Vector;
  -
   import org.apache.commons.net.ftp.parser.UnixFTPEntryParser;
   
   /**
  
  
  
  1.28  +0 -1  
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java
  
  Index: FTPClient.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- FTPClient.java10 Jan 2004 23:19:51 -  1.27
  +++ FTPClient.java16 Jan 2004 02:15:37 -  1.28
  @@ -71,7 +71,6 @@
   import org.apache.commons.net.MalformedServerReplyException;
   import org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory;
   import org.apache.commons.net.ftp.parser.FTPFileEntryParserFactory;
  -import org.apache.commons.net.ftp.parser.ParserInitializationException;
   
   /***
* FTPClient encapsulates all the functionality necessary to store and
  
  
  
  1.15  +1 -2  
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParser.java
  
  Index: FTPFileEntryParser.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParser.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FTPFileEntryParser.java   10 Jan 2004 23:19:52 -  1.14
  +++ FTPFileEntryParser.java   16 Jan 2004 02:15:37 -  1.15
  @@ -56,7 +56,6 @@
   
   import java.io.BufferedReader;
   import java.io.IOException;
  -import java.io.InputStream;
   
   /**
* FTPFileEntryParser defines the interface for parsing a single FTP file
  
  
  
  1.11  +0 -10 
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileListParserImpl.java
  
  Index: FTPFileListParserImpl.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileListParserImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FTPFileListParserImpl.java12 Jan 2004 15:57:23 -  1.10
  +++ FTPFileListParserImpl.java16 Jan 2004 02:15:37 -  1.11
  @@ -54,16 +54,6 @@
* http://www.apache.org/.
*/
   
  -import java.io.InputStream;
  -import java.io.BufferedReader;
  -import java.io.IOException;
  -
  -import org.apache.oro.text.regex.Pattern;
  -import org.apache.oro.text.regex.MalformedPatternException;
  -import org.apache.oro.text.regex.PatternMatcher;
  -import org.apache.oro.text.regex.Perl5Matcher;
  -import org.apache.oro.text.regex.Perl5Compiler;
  -import org.apache.oro.text.regex.MatchResult;
   
   /**
* This abstract class implements both the older FTPFileListParser and
  
  
  
  1.17  +4 -13 
jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
  
  Index: VMSFTPEntryParser.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- VMSFTPEntryParser.java10 Jan 2004 23:38:21 -  1.16
  +++ VMSFTPEntryParser.java16 Jan 2004 02:15:37 -  1.17
  @@ -54,24 +54,15 @@
* http://www.apache.org/.
*/
   
  -import java.util.Calendar;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.StringTokenizer;
   import java.io.BufferedReader;
  -import java.io.ByteArrayInputStream;
   import java.io.IOException;
   import 

cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser VMSFTPEntryParser.java

2004-01-09 Thread dfs
dfs 2004/01/09 01:07:03

  Modified:net/src/java/org/apache/commons/net/ftp FTPClient.java
FTPFileEntryParser.java FTPFileIterator.java
FTPFileList.java FTPFileListParserImpl.java
   net/src/java/org/apache/commons/net/ftp/parser
VMSFTPEntryParser.java
  Added:   net/src/java/org/apache/commons/net/ftp
DefaultFTPFileIterator.java DefaultFTPFileList.java
  Log:
  Made FTPFileList and FTPFileIterator abstract.  Moved implementations
  into DefaultFTPFileList and DefaultFTPFileIterator.  Added
  createFTPFileList method (the name is not fixed in stone and should
  probably change) in FTPFileEntryParser to take over role
  of FTPFilelist.create.  These changes were made to allow customization
  of file list handling by entry parseres.  Finally, changed VMSFTPEntryParser
  to return an FTPFileList that filters out duplicates.
  
  Revision  ChangesPath
  1.25  +1 -1  
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java
  
  Index: FTPClient.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPClient.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- FTPClient.java6 Jan 2004 19:02:02 -   1.24
  +++ FTPClient.java9 Jan 2004 09:07:03 -   1.25
  @@ -2334,7 +2334,7 @@
   }
   
   FTPFileList list =
  -FTPFileList.create(socket.getInputStream(), parser);
  +parser.createFTPFileList(socket.getInputStream());
   
   socket.close();
   
  
  
  
  1.12  +26 -1 
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParser.java
  
  Index: FTPFileEntryParser.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileEntryParser.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FTPFileEntryParser.java   6 Jan 2004 22:24:24 -   1.11
  +++ FTPFileEntryParser.java   9 Jan 2004 09:07:03 -   1.12
  @@ -161,4 +161,29 @@
* @exception IOException thrown on any IO Error reading from the reader.
*/
   String readNextEntry(BufferedReader reader) throws IOException;
  +
  +/**
  + * Creates an codeFTPFileList/code object from a stream containing
  + * a file listing.
  + *
  + * @param stream The input stream created by reading the socket on which 
  + * the output of the LIST command was returned
  + * 
  + * @return the codeFTPFileList/code created.
  + * Will be null if the listing cannot be read from the stream.
  + * @exception IOException
  + *   Thrown on any failure to read from the stream.
  + */
  +public FTPFileList createFTPFileList(InputStream stream)
  +throws IOException;
  +
   }
  +
  +
  +/* Emacs configuration
  + * Local variables:**
  + * mode: java  **
  + * c-basic-offset:   4 **
  + * indent-tabs-mode: nil   **
  + * End:**
  + */
  
  
  
  1.7   +18 -225   
jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileIterator.java
  
  Index: FTPFileIterator.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTPFileIterator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FTPFileIterator.java  2 Jan 2004 03:39:04 -   1.6
  +++ FTPFileIterator.java  9 Jan 2004 09:07:03 -   1.7
  @@ -68,134 +68,16 @@
* @see org.apache.commons.net.ftp.FTPFileList
* @see org.apache.commons.net.ftp.FTPFileEntryParser
*/
  -public class FTPFileIterator
  +public abstract class FTPFileIterator
   {
   /**
  - * a vector of strings, each representing a possibly valid ftp file
  - * entry
  - */
  -private Vector rawlines;
  -
  -/**
  - * the parser to which this iterator delegates its parsing duties
  - */
  -private FTPFileEntryParser parser;
  -
  -/**
  - * constant shorthand for the situation where the raw listing has not 
  - * yet been scanned
  - */
  -private static final int UNINIT = -1;
  -
  -/**
  - * constant shorthand for the situation where the raw listing has been 
  - * scanned and found to have no valid entry.
  - */
  -private static final int DIREMPTY = -2;
  -
  -/**
  - * this iterator's current position within coderawlines/code.
  - */
  -private int itemptr = 0;
  -
  -/**
  - * number within coderawlines/code of the first valid file entry.
  - */
  -private int firstGoodEntry = UNINIT;
  -
  -/**
  - * Package-private 

cvs commit: jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser VMSFTPEntryParser.java

2004-01-01 Thread scohen
scohen  2004/01/01 12:49:49

  Modified:net/src/java/examples ExtendedNNTPOps.java
   net/src/java/org/apache/commons/net/ftp/parser
VMSFTPEntryParser.java
  Log:
  refactor back to JDK 1.1 compatibility.
  HashMap - Hashtable
  ArrayList - [] or use StringTokenizer to avoid having to fall back to deprecated 
methods in ORO.
  
  Revision  ChangesPath
  1.3   +8 -5  jakarta-commons/net/src/java/examples/ExtendedNNTPOps.java
  
  Index: ExtendedNNTPOps.java
  ===
  RCS file: /home/cvs/jakarta-commons/net/src/java/examples/ExtendedNNTPOps.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtendedNNTPOps.java  23 Sep 2003 02:53:56 -  1.2
  +++ ExtendedNNTPOps.java  1 Jan 2004 20:49:48 -   1.3
  @@ -58,7 +58,6 @@
   import java.io.IOException;
   import java.io.Reader;
   import java.io.PrintWriter;
  -import java.util.ArrayList;
   import java.util.StringTokenizer;
   
   import org.apache.commons.net.io.DotTerminatedMessageReader;
  @@ -143,9 +142,8 @@
int highArticleNumber)
   throws IOException 
   {
  -ArrayList articles = new ArrayList();
   Reader reader = null;
  -
  +Article[] articles = new Article[0];
   reader = (DotTerminatedMessageReader)
   client.retrieveArticleInfo(lowArticleNumber, highArticleNumber);
   
  @@ -156,6 +154,11 @@
   // Extract the article information
   // Mandatory format (from NNTP RFC 2980) is :
   // Subject\tAuthor\tDate\tID\tReference(s)\tByte Count\tLine Count
  +
  +int count = st.countTokens();
  +articles = new Article[count];
  +int index = 0;
  +
   while (st.hasMoreTokens()) {
   StringTokenizer stt = new StringTokenizer(st.nextToken(), \t);
   Article article = new Article();
  @@ -165,13 +168,13 @@
   article.setDate(stt.nextToken());
   article.setArticleId(stt.nextToken());
   article.addHeaderField(References, stt.nextToken());
  -articles.add(article);
  +articles[index++] = article;
   }
   } else {
   return null;
   }

  -return (Article[]) articles.toArray(new Article[articles.size()]);
  +return articles;
   }

   private String readerToString(Reader reader) 
  
  
  
  1.9   +18 -14
jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java
  
  Index: VMSFTPEntryParser.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/parser/VMSFTPEntryParser.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- VMSFTPEntryParser.java30 Dec 2003 03:58:52 -  1.8
  +++ VMSFTPEntryParser.java1 Jan 2004 20:49:48 -   1.9
  @@ -3,7 +3,7 @@
   /* 
* The Apache Software License, Version 1.1
*
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2004 The Apache Software Foundation.  All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
  @@ -55,8 +55,9 @@
*/
   
   import java.util.Calendar;
  -import java.util.HashMap;
  -import java.util.ArrayList;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import java.util.StringTokenizer;
   import java.io.BufferedReader;
   import java.io.ByteArrayInputStream;
   import java.io.IOException;
  @@ -209,7 +210,7 @@
   files = super.parseFileList(listingStream);
   } else {
   FTPFile[] tempFiles = super.parseFileList(listingStream);
  -HashMap filesHash = new HashMap();
  +Hashtable filesHash = new Hashtable();
   String fileName;
   
   for (int index = 0; index  tempFiles.length; index++) {
  @@ -218,8 +219,14 @@
   filesHash.put(fileName, (FTPFile) tempFiles[index]);
   }
   }
  +files = new FTPFile[filesHash.size()];
  +Enumeration e = filesHash.keys();
  +int index = 0;
  +while (e.hasMoreElements()) {
  +FTPFile ftpf = (FTPFile) filesHash.get(e.nextElement());
  +files[index++] = ftpf;
  +}
   
  -files = (FTPFile[]) filesHash.values().toArray(new FTPFile[0]);
   }
   
   return files;
  @@ -256,18 +263,15 @@
   String owner = group(9);
   String grp;
   String user;
  -