You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/16 01:35:13 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java MimeMail.java TelnetTask.java

donaldp     01/12/15 16:35:13

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net
                        FTP.java MimeMail.java TelnetTask.java
  Log:
  BuildException -> TaskException
  
  Removed uneeded imports.
  
  Processed code through style formatter.
  
  Revision  Changes    Path
  1.3       +96 -96    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FTP.java	2001/12/15 14:55:59	1.2
  +++ FTP.java	2001/12/16 00:35:13	1.3
  @@ -6,6 +6,7 @@
    * the LICENSE file.
    */
   package org.apache.tools.ant.taskdefs.optional.net;
  +
   import com.oroinc.net.ftp.FTPClient;
   import com.oroinc.net.ftp.FTPFile;
   import com.oroinc.net.ftp.FTPReply;
  @@ -21,7 +22,7 @@
   import java.io.OutputStream;
   import java.util.Locale;
   import java.util.Vector;
  -import org.apache.tools.ant.BuildException;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.FileScanner;
   import org.apache.tools.ant.Project;
  @@ -52,7 +53,7 @@
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    */
   public class FTP
  -     extends Task
  +    extends Task
   {
       protected final static int SEND_FILES = 0;
       protected final static int GET_FILES = 1;
  @@ -66,7 +67,7 @@
           "deleting",
           "listing",
           "making directory"
  -        };
  +    };
   
       protected final static String[] COMPLETED_ACTION_STRS = {
           "sent",
  @@ -74,7 +75,7 @@
           "deleted",
           "listed",
           "created directory"
  -        };
  +    };
       private boolean binary = true;
       private boolean passive = false;
       private boolean verbose = false;
  @@ -100,10 +101,10 @@
        * "mkdir" and "list".
        *
        * @param action The new Action value
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void setAction( Action action )
  -        throws BuildException
  +        throws TaskException
       {
           this.action = action.getAction();
       }
  @@ -146,10 +147,10 @@
        * other actions.
        *
        * @param listing The new Listing value
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void setListing( File listing )
  -        throws BuildException
  +        throws TaskException
       {
           this.listing = listing;
       }
  @@ -232,7 +233,6 @@
           this.server = server;
       }
   
  -
       /**
        * set the failed transfer flag
        *
  @@ -276,10 +276,10 @@
       /**
        * Runs the task.
        *
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void execute()
  -        throws BuildException
  +        throws TaskException
       {
           checkConfiguration();
   
  @@ -294,7 +294,7 @@
               ftp.connect( server, port );
               if( !FTPReply.isPositiveCompletion( ftp.getReplyCode() ) )
               {
  -                throw new BuildException( "FTP connection failed: " + ftp.getReplyString() );
  +                throw new TaskException( "FTP connection failed: " + ftp.getReplyString() );
               }
   
               log( "connected", Project.MSG_VERBOSE );
  @@ -302,7 +302,7 @@
   
               if( !ftp.login( userid, password ) )
               {
  -                throw new BuildException( "Could not login to FTP server" );
  +                throw new TaskException( "Could not login to FTP server" );
               }
   
               log( "login succeeded", Project.MSG_VERBOSE );
  @@ -312,7 +312,7 @@
                   ftp.setFileType( com.oroinc.net.ftp.FTP.IMAGE_FILE_TYPE );
                   if( !FTPReply.isPositiveCompletion( ftp.getReplyCode() ) )
                   {
  -                    throw new BuildException(
  +                    throw new TaskException(
                           "could not set transfer type: " +
                           ftp.getReplyString() );
                   }
  @@ -324,7 +324,7 @@
                   ftp.enterLocalPassiveMode();
                   if( !FTPReply.isPositiveCompletion( ftp.getReplyCode() ) )
                   {
  -                    throw new BuildException(
  +                    throw new TaskException(
                           "could not enter into passive mode: " +
                           ftp.getReplyString() );
                   }
  @@ -347,19 +347,19 @@
                       ftp.changeWorkingDirectory( remotedir );
                       if( !FTPReply.isPositiveCompletion( ftp.getReplyCode() ) )
                       {
  -                        throw new BuildException(
  +                        throw new TaskException(
                               "could not change remote directory: " +
                               ftp.getReplyString() );
                       }
                   }
  -                log( ACTION_STRS[action] + " files" );
  +                log( ACTION_STRS[ action ] + " files" );
                   transferFiles( ftp );
               }
   
           }
           catch( IOException ex )
           {
  -            throw new BuildException( "error during FTP transfer: " + ex );
  +            throw new TaskException( "error during FTP transfer: " + ex );
           }
           finally
           {
  @@ -390,10 +390,10 @@
        * @param dir Description of Parameter
        * @param filename Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void getFile( FTPClient ftp, String dir, String filename )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           OutputStream outstream = null;
           try
  @@ -426,14 +426,14 @@
                   }
                   else
                   {
  -                    throw new BuildException( s );
  +                    throw new TaskException( s );
                   }
   
               }
               else
               {
                   log( "File " + file.getAbsolutePath() + " copied from " + server,
  -                    Project.MSG_VERBOSE );
  +                     Project.MSG_VERBOSE );
                   transferred++;
               }
           }
  @@ -462,10 +462,10 @@
        * @param remoteFile Description of Parameter
        * @return The UpToDate value
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected boolean isUpToDate( FTPClient ftp, File localFile, String remoteFile )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           log( "checking date for " + remoteFile, Project.MSG_VERBOSE );
   
  @@ -486,12 +486,12 @@
               }
               else
               {
  -                throw new BuildException( "could not date test remote file: " +
  -                    ftp.getReplyString() );
  +                throw new TaskException( "could not date test remote file: " +
  +                                         ftp.getReplyString() );
               }
           }
   
  -        long remoteTimestamp = files[0].getTimestamp().getTime().getTime();
  +        long remoteTimestamp = files[ 0 ].getTimestamp().getTime().getTime();
           long localTimestamp = localFile.lastModified();
           if( this.action == SEND_FILES )
           {
  @@ -506,32 +506,32 @@
       /**
        * Checks to see that all required parameters are set.
        *
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void checkConfiguration()
  -        throws BuildException
  +        throws TaskException
       {
           if( server == null )
           {
  -            throw new BuildException( "server attribute must be set!" );
  +            throw new TaskException( "server attribute must be set!" );
           }
           if( userid == null )
           {
  -            throw new BuildException( "userid attribute must be set!" );
  +            throw new TaskException( "userid attribute must be set!" );
           }
           if( password == null )
           {
  -            throw new BuildException( "password attribute must be set!" );
  +            throw new TaskException( "password attribute must be set!" );
           }
   
           if( ( action == LIST_FILES ) && ( listing == null ) )
           {
  -            throw new BuildException( "listing attribute must be set for list action!" );
  +            throw new TaskException( "listing attribute must be set for list action!" );
           }
   
           if( action == MK_DIR && remotedir == null )
           {
  -            throw new BuildException( "remotedir attribute must be set for mkdir action!" );
  +            throw new TaskException( "remotedir attribute must be set for mkdir action!" );
           }
       }
   
  @@ -542,10 +542,10 @@
        * @param ftp Description of Parameter
        * @param filename Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void createParents( FTPClient ftp, String filename )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           Vector parents = new Vector();
           File dir = new File( filename );
  @@ -559,11 +559,11 @@
   
           for( int i = parents.size() - 1; i >= 0; i-- )
           {
  -            dir = ( File )parents.elementAt( i );
  +            dir = (File)parents.elementAt( i );
               if( !dirCache.contains( dir ) )
               {
                   log( "creating remote directory " + resolveFile( dir.getPath() ),
  -                    Project.MSG_VERBOSE );
  +                     Project.MSG_VERBOSE );
                   ftp.makeDirectory( resolveFile( dir.getPath() ) );
                   // Both codes 550 and 553 can be produced by FTP Servers
                   //  to indicate that an attempt to create a directory has
  @@ -573,7 +573,7 @@
                       ( result != 550 ) && ( result != 553 ) &&
                       !ignoreNoncriticalErrors )
                   {
  -                    throw new BuildException(
  +                    throw new TaskException(
                           "could not create directory: " +
                           ftp.getReplyString() );
                   }
  @@ -588,10 +588,10 @@
        * @param ftp Description of Parameter
        * @param filename Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void delFile( FTPClient ftp, String filename )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           if( verbose )
           {
  @@ -608,7 +608,7 @@
               }
               else
               {
  -                throw new BuildException( s );
  +                throw new TaskException( s );
               }
           }
           else
  @@ -629,17 +629,17 @@
        * @param bw Description of Parameter
        * @param filename Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void listFile( FTPClient ftp, BufferedWriter bw, String filename )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           if( verbose )
           {
               log( "listing " + filename );
           }
   
  -        FTPFile ftpfile = ftp.listFiles( resolveFile( filename ) )[0];
  +        FTPFile ftpfile = ftp.listFiles( resolveFile( filename ) )[ 0 ];
           bw.write( ftpfile.toString() );
           bw.newLine();
   
  @@ -652,10 +652,10 @@
        * @param ftp The FTP client connection
        * @param dir The directory to create (format must be correct for host type)
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void makeRemoteDir( FTPClient ftp, String dir )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           if( verbose )
           {
  @@ -671,8 +671,8 @@
               int rc = ftp.getReplyCode();
               if( !( ignoreNoncriticalErrors && ( rc == 550 || rc == 553 || rc == 521 ) ) )
               {
  -                throw new BuildException( "could not create directory: " +
  -                    ftp.getReplyString() );
  +                throw new TaskException( "could not create directory: " +
  +                                         ftp.getReplyString() );
               }
   
               if( verbose )
  @@ -702,7 +702,7 @@
       protected String resolveFile( String file )
       {
           return file.replace( System.getProperty( "file.separator" ).charAt( 0 ),
  -            remoteFileSep.charAt( 0 ) );
  +                             remoteFileSep.charAt( 0 ) );
       }
   
       /**
  @@ -718,10 +718,10 @@
        * @param dir Description of Parameter
        * @param filename Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void sendFile( FTPClient ftp, String dir, String filename )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           InputStream instream = null;
           try
  @@ -752,7 +752,7 @@
                   }
                   else
                   {
  -                    throw new BuildException( s );
  +                    throw new TaskException( s );
                   }
   
               }
  @@ -760,8 +760,8 @@
               {
   
                   log( "File " + file.getAbsolutePath() +
  -                    " copied to " + server,
  -                    Project.MSG_VERBOSE );
  +                     " copied to " + server,
  +                     Project.MSG_VERBOSE );
                   transferred++;
               }
           }
  @@ -789,10 +789,10 @@
        * @param fs Description of Parameter
        * @return Description of the Returned Value
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected int transferFiles( FTPClient ftp, FileSet fs )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           FileScanner ds;
   
  @@ -811,7 +811,7 @@
           String dir = null;
           if( ( ds.getBasedir() == null ) && ( ( action == SEND_FILES ) || ( action == GET_FILES ) ) )
           {
  -            throw new BuildException( "the dir attribute must be set for send and get actions" );
  +            throw new TaskException( "the dir attribute must be set for send and get actions" );
           }
           else
           {
  @@ -835,36 +835,36 @@
   
           for( int i = 0; i < dsfiles.length; i++ )
           {
  -            switch ( action )
  +            switch( action )
               {
  -            case SEND_FILES:
  -            {
  -                sendFile( ftp, dir, dsfiles[i] );
  -                break;
  -            }
  +                case SEND_FILES:
  +                    {
  +                        sendFile( ftp, dir, dsfiles[ i ] );
  +                        break;
  +                    }
   
  -            case GET_FILES:
  -            {
  -                getFile( ftp, dir, dsfiles[i] );
  -                break;
  -            }
  +                case GET_FILES:
  +                    {
  +                        getFile( ftp, dir, dsfiles[ i ] );
  +                        break;
  +                    }
   
  -            case DEL_FILES:
  -            {
  -                delFile( ftp, dsfiles[i] );
  -                break;
  -            }
  +                case DEL_FILES:
  +                    {
  +                        delFile( ftp, dsfiles[ i ] );
  +                        break;
  +                    }
   
  -            case LIST_FILES:
  -            {
  -                listFile( ftp, bw, dsfiles[i] );
  -                break;
  -            }
  +                case LIST_FILES:
  +                    {
  +                        listFile( ftp, bw, dsfiles[ i ] );
  +                        break;
  +                    }
   
  -            default:
  -            {
  -                throw new BuildException( "unknown ftp action " + action );
  -            }
  +                default:
  +                    {
  +                        throw new TaskException( "unknown ftp action " + action );
  +                    }
               }
           }
   
  @@ -882,24 +882,24 @@
        *
        * @param ftp Description of Parameter
        * @exception IOException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       protected void transferFiles( FTPClient ftp )
  -        throws IOException, BuildException
  +        throws IOException, TaskException
       {
           transferred = 0;
           skipped = 0;
   
           if( filesets.size() == 0 )
           {
  -            throw new BuildException( "at least one fileset must be specified." );
  +            throw new TaskException( "at least one fileset must be specified." );
           }
           else
           {
               // get files from filesets
               for( int i = 0; i < filesets.size(); i++ )
               {
  -                FileSet fs = ( FileSet )filesets.elementAt( i );
  +                FileSet fs = (FileSet)filesets.elementAt( i );
                   if( fs != null )
                   {
                       transferFiles( ftp, fs );
  @@ -907,10 +907,10 @@
               }
           }
   
  -        log( transferred + " files " + COMPLETED_ACTION_STRS[action] );
  +        log( transferred + " files " + COMPLETED_ACTION_STRS[ action ] );
           if( skipped != 0 )
           {
  -            log( skipped + " files were not successfully " + COMPLETED_ACTION_STRS[action] );
  +            log( skipped + " files were not successfully " + COMPLETED_ACTION_STRS[ action ] );
           }
       }
   
  @@ -919,7 +919,7 @@
   
           private final static String[] validActions = {
               "send", "put", "recv", "get", "del", "delete", "list", "mkdir"
  -            };
  +        };
   
           public int getAction()
           {
  @@ -971,12 +971,12 @@
               if( includes == null )
               {
                   // No includes supplied, so set it to 'matches all'
  -                includes = new String[1];
  -                includes[0] = "**";
  +                includes = new String[ 1 ];
  +                includes[ 0 ] = "**";
               }
               if( excludes == null )
               {
  -                excludes = new String[0];
  +                excludes = new String[ 0 ];
               }
   
               filesIncluded = new Vector();
  @@ -994,7 +994,7 @@
               }
               catch( IOException e )
               {
  -                throw new BuildException( "Unable to scan FTP server: ", e );
  +                throw new TaskException( "Unable to scan FTP server: ", e );
               }
           }
   
  @@ -1016,7 +1016,7 @@
   
                   for( int i = 0; i < newfiles.length; i++ )
                   {
  -                    FTPFile file = newfiles[i];
  +                    FTPFile file = newfiles[ i ];
                       if( !file.getName().equals( "." ) && !file.getName().equals( ".." ) )
                       {
                           if( file.isDirectory() )
  @@ -1078,7 +1078,7 @@
               }
               catch( IOException e )
               {
  -                throw new BuildException( "Error while communicating with FTP server: ", e );
  +                throw new TaskException( "Error while communicating with FTP server: ", e );
               }
           }
       }
  
  
  
  1.3       +32 -38    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java
  
  Index: MimeMail.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/MimeMail.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MimeMail.java	2001/12/15 14:55:59	1.2
  +++ MimeMail.java	2001/12/16 00:35:13	1.3
  @@ -6,15 +6,16 @@
    * the LICENSE file.
    */
   package org.apache.tools.ant.taskdefs.optional.net;
  +
   import java.io.File;
   import java.io.FileInputStream;
  -import java.io.IOException;// Standard SDK imports
  +import java.io.IOException;
   import java.util.Properties;
  -import java.util.Vector;//imported for data source and handler
  +import java.util.Vector;
   import javax.activation.DataHandler;
   import javax.activation.FileDataSource;
   import javax.mail.Message;
  -import javax.mail.MessagingException;//imported for the mail api
  +import javax.mail.MessagingException;
   import javax.mail.Session;
   import javax.mail.Transport;
   import javax.mail.internet.AddressException;
  @@ -22,13 +23,12 @@
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.MimeMultipart;
  -import org.apache.tools.ant.BuildException;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.DirectoryScanner;
  -import org.apache.tools.ant.Project;// Ant imports
  +import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.types.FileSet;
   
  -
   /**
    * A task to send SMTP email. This version has near identical syntax to the
    * SendEmail task, but is MIME aware. It also requires Sun's mail.jar and
  @@ -102,16 +102,17 @@
       /**
        * Creates new instance
        */
  -    public MimeMail() { }
  -
  +    public MimeMail()
  +    {
  +    }
   
       // helper method to add recipients
       private static void addRecipients( MimeMessage msg,
                                          Message.RecipientType recipType,
                                          String addrUserName,
                                          String addrList
  -                                        )
  -        throws MessagingException, BuildException
  +                                       )
  +        throws MessagingException, TaskException
       {
           if( ( null == addrList ) || ( addrList.trim().length() <= 0 ) )
               return;
  @@ -121,13 +122,13 @@
               InternetAddress[] addrArray = InternetAddress.parse( addrList );
   
               if( ( null == addrArray ) || ( 0 == addrArray.length ) )
  -                throw new BuildException( "Empty " + addrUserName + " recipients list was specified" );
  +                throw new TaskException( "Empty " + addrUserName + " recipients list was specified" );
   
               msg.setRecipients( recipType, addrArray );
           }
           catch( AddressException ae )
           {
  -            throw new BuildException( "Invalid " + addrUserName + " recipient list" );
  +            throw new TaskException( "Invalid " + addrUserName + " recipient list" );
           }
       }
   
  @@ -151,7 +152,6 @@
           this.ccList = ccList;
       }
   
  -
       /**
        * Sets the FailOnError attribute of the MimeMail object
        *
  @@ -162,7 +162,6 @@
           this.failOnError = failOnError;
       }
   
  -
       /**
        * Sets the "from" parameter of this build task.
        *
  @@ -173,7 +172,6 @@
           this.from = from;
       }
   
  -
       /**
        * Sets the mailhost parameter of this build task.
        *
  @@ -184,7 +182,6 @@
           this.mailhost = mailhost;
       }
   
  -
       /**
        * Sets the message parameter of this build task.
        *
  @@ -200,7 +197,6 @@
           this.messageFile = messageFile;
       }
   
  -
       /**
        * set type of the text message, plaintext by default but text/html or
        * text/xml is quite feasible
  @@ -247,10 +243,10 @@
        *
        * @exception MessagingException Description of Exception
        * @exception AddressException Description of Exception
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void doMail()
  -        throws MessagingException, AddressException, BuildException
  +        throws MessagingException, AddressException, TaskException
       {
           Properties props = new Properties();
           props.put( "mail.smtp.host", mailhost );
  @@ -284,8 +280,8 @@
           //first a message
           if( messageFile != null )
           {
  -            int size = ( int )messageFile.length();
  -            byte data[] = new byte[size];
  +            int size = (int)messageFile.length();
  +            byte data[] = new byte[ size ];
   
               try
               {
  @@ -296,7 +292,7 @@
               }
               catch( IOException e )
               {
  -                throw new BuildException( "Error", e );
  +                throw new TaskException( "Error", e );
               }
           }
   
  @@ -309,7 +305,7 @@
   
           for( int i = 0; i < filesets.size(); i++ )
           {
  -            FileSet fs = ( FileSet )filesets.elementAt( i );
  +            FileSet fs = (FileSet)filesets.elementAt( i );
               if( fs != null )
               {
                   DirectoryScanner ds = fs.getDirectoryScanner( project );
  @@ -318,16 +314,16 @@
   
                   for( int j = 0; j < dsfiles.length; j++ )
                   {
  -                    File file = new File( baseDir, dsfiles[j] );
  +                    File file = new File( baseDir, dsfiles[ j ] );
                       MimeBodyPart body;
                       body = new MimeBodyPart();
                       if( !file.exists() || !file.canRead() )
                       {
  -                        throw new BuildException( "File \"" + file.getAbsolutePath()
  -                             + "\" does not exist or is not readable." );
  +                        throw new TaskException( "File \"" + file.getAbsolutePath()
  +                                                 + "\" does not exist or is not readable." );
                       }
                       log( "Attaching " + file.toString() + " - " + file.length() + " bytes",
  -                        Project.MSG_VERBOSE );
  +                         Project.MSG_VERBOSE );
                       FileDataSource fileData = new FileDataSource( file );
                       DataHandler fileDataHandler = new DataHandler( fileData );
                       body.setDataHandler( fileDataHandler );
  @@ -342,15 +338,14 @@
           Transport.send( msg );
       }
   
  -
       /**
  -     * Executes this build task. throws org.apache.tools.ant.BuildException if
  +     * Executes this build task. throws org.apache.tools.ant.TaskException if
        * there is an error during task execution.
        *
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void execute()
  -        throws BuildException
  +        throws TaskException
       {
           try
           {
  @@ -361,7 +356,7 @@
           {
               if( failOnError )
               {
  -                throw new BuildException( "Error", e );
  +                throw new TaskException( "Error", e );
               }
               else
               {
  @@ -371,32 +366,31 @@
           }
       }
   
  -
       /**
        * verify parameters
        *
  -     * @throws BuildException if something is invalid
  +     * @throws TaskException if something is invalid
        */
       public void validate()
       {
           if( from == null )
           {
  -            throw new BuildException( "Attribute \"from\" is required." );
  +            throw new TaskException( "Attribute \"from\" is required." );
           }
   
           if( ( toList == null ) && ( ccList == null ) && ( bccList == null ) )
           {
  -            throw new BuildException( "Attribute \"toList\", \"ccList\" or \"bccList\" is required." );
  +            throw new TaskException( "Attribute \"toList\", \"ccList\" or \"bccList\" is required." );
           }
   
           if( message == null && filesets.isEmpty() && messageFile == null )
           {
  -            throw new BuildException( "FileSet, \"message\", or \"messageFile\" is required." );
  +            throw new TaskException( "FileSet, \"message\", or \"messageFile\" is required." );
           }
   
           if( message != null && messageFile != null )
           {
  -            throw new BuildException( "Only one of \"message\" or \"messageFile\" may be specified." );
  +            throw new TaskException( "Only one of \"message\" or \"messageFile\" may be specified." );
           }
       }
   }
  
  
  
  1.3       +23 -22    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
  
  Index: TelnetTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TelnetTask.java	2001/12/15 14:55:59	1.2
  +++ TelnetTask.java	2001/12/16 00:35:13	1.3
  @@ -6,6 +6,7 @@
    * the LICENSE file.
    */
   package org.apache.tools.ant.taskdefs.optional.net;
  +
   import com.oroinc.net.telnet.TelnetClient;
   import java.io.IOException;
   import java.io.InputStream;
  @@ -13,7 +14,7 @@
   import java.util.Calendar;
   import java.util.Enumeration;
   import java.util.Vector;
  -import org.apache.tools.ant.BuildException;
  +import org.apache.myrmidon.api.TaskException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   
  @@ -21,7 +22,7 @@
    * Class to provide automated telnet protocol support for the Ant build tool
    *
    * @author <a href="mailto:ScottCarlson@email.com">ScottCarlson@email.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   
   public class TelnetTask extends Task
  @@ -136,7 +137,7 @@
   
       public TelnetSubTask createRead()
       {
  -        TelnetSubTask task = ( TelnetSubTask )new TelnetRead();
  +        TelnetSubTask task = (TelnetSubTask)new TelnetRead();
           telnetTasks.addElement( task );
           return task;
       }
  @@ -149,7 +150,7 @@
        */
       public TelnetSubTask createWrite()
       {
  -        TelnetSubTask task = ( TelnetSubTask )new TelnetWrite();
  +        TelnetSubTask task = (TelnetSubTask)new TelnetWrite();
           telnetTasks.addElement( task );
           return task;
       }
  @@ -158,24 +159,24 @@
        * Verify that all parameters are included. Connect and possibly login
        * Iterate through the list of Reads and writes
        *
  -     * @exception BuildException Description of Exception
  +     * @exception TaskException Description of Exception
        */
       public void execute()
  -        throws BuildException
  +        throws TaskException
       {
           /**
            * A server name is required to continue
            */
           if( server == null )
  -            throw new BuildException( "No Server Specified" );
  +            throw new TaskException( "No Server Specified" );
           /**
            * A userid and password must appear together if they appear. They are
            * not required.
            */
           if( userid == null && password != null )
  -            throw new BuildException( "No Userid Specified" );
  +            throw new TaskException( "No Userid Specified" );
           if( password == null && userid != null )
  -            throw new BuildException( "No Password Specified" );
  +            throw new TaskException( "No Password Specified" );
   
           /**
            * Create the telnet client object
  @@ -187,7 +188,7 @@
           }
           catch( IOException e )
           {
  -            throw new BuildException( "Can't connect to " + server );
  +            throw new TaskException( "Can't connect to " + server );
           }
           /**
            * Login if userid and password were specified
  @@ -200,9 +201,9 @@
           Enumeration tasksToRun = telnetTasks.elements();
           while( tasksToRun != null && tasksToRun.hasMoreElements() )
           {
  -            TelnetSubTask task = ( TelnetSubTask )tasksToRun.nextElement();
  +            TelnetSubTask task = (TelnetSubTask)tasksToRun.nextElement();
               if( task instanceof TelnetRead && defaultTimeout != null )
  -                ( ( TelnetRead )task ).setDefaultTimeout( defaultTimeout );
  +                ( (TelnetRead)task ).setDefaultTimeout( defaultTimeout );
               task.execute( telnet );
           }
       }
  @@ -249,7 +250,7 @@
               }
               catch( Exception e )
               {
  -                throw new BuildException( "Error", e );
  +                throw new TaskException( "Error", e );
               }
           }
   
  @@ -284,7 +285,7 @@
                   {
                       while( sb.toString().indexOf( s ) == -1 )
                       {
  -                        sb.append( ( char )is.read() );
  +                        sb.append( (char)is.read() );
                       }
                   }
                   else
  @@ -299,19 +300,19 @@
                               Thread.sleep( 250 );
                           }
                           if( is.available() == 0 )
  -                            throw new BuildException( "Response Timed-Out" );
  -                        sb.append( ( char )is.read() );
  +                            throw new TaskException( "Response Timed-Out" );
  +                        sb.append( (char)is.read() );
                       }
                   }
                   log( sb.toString(), Project.MSG_INFO );
               }
  -            catch( BuildException be )
  +            catch( TaskException be )
               {
                   throw be;
               }
               catch( Exception e )
               {
  -                throw new BuildException( "Error", e );
  +                throw new TaskException( "Error", e );
               }
           }
       }
  @@ -348,7 +349,7 @@
           }
   
           public void execute( AntTelnetClient telnet )
  -            throws BuildException
  +            throws TaskException
           {
               telnet.waitForString( taskString, timeout );
           }
  @@ -375,9 +376,9 @@
           }
   
           public void execute( AntTelnetClient telnet )
  -            throws BuildException
  +            throws TaskException
           {
  -            throw new BuildException( "Shouldn't be able instantiate a SubTask directly" );
  +            throw new TaskException( "Shouldn't be able instantiate a SubTask directly" );
           }
       }
   
  @@ -396,7 +397,7 @@
           }
   
           public void execute( AntTelnetClient telnet )
  -            throws BuildException
  +            throws TaskException
           {
               telnet.sendString( taskString, echoString );
           }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>