brett       2004/09/29 03:56:04

  Modified:    artifact/src/main/org/apache/maven/artifact/deployer
                        RepositoryInfoBuilder.java
               artifact/src/main/org/apache/maven/deploy
                        RepositoryInfo.java
               artifact/src/main/org/apache/maven/deploy/deployers
                        FtpDeployer.java
               artifact/xdocs changes.xml properties.xml
  Log:
  ftp improvements
  
  Revision  Changes    Path
  1.9       +11 -2     
maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java
  
  Index: RepositoryInfoBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/RepositoryInfoBuilder.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RepositoryInfoBuilder.java        28 Sep 2004 09:20:40 -0000      1.8
  +++ RepositoryInfoBuilder.java        29 Sep 2004 10:56:03 -0000      1.9
  @@ -87,6 +87,10 @@
               (String) project.getContext().getVariable(
                   "maven.repo." + repository + ".mode");
                   
  +        String remoteDirectoryMode =
  +            (String) project.getContext().getVariable(
  +                "maven.repo." + repository + ".directory.mode");
  +                
           String passiveModeOn = 
               (String) project.getContext().getVariable(
                   "maven.repo." + repository + ".passiveModeOn");
  @@ -120,7 +124,11 @@
           }
   
           if (remoteMode == null) {
  -            remoteMode = "664";
  +            remoteMode = "g+w";
  +        }
  +
  +        if (remoteDirectoryMode == null) {
  +            remoteDirectoryMode = remoteMode;
           }
   
           repoInfo.setUserName(username);
  @@ -129,6 +137,7 @@
           repoInfo.setPrivateKey(privateKey);
           repoInfo.setGroup(remoteGroup);
           repoInfo.setMode(remoteMode);
  +        repoInfo.setDirectoryMode(remoteDirectoryMode);
           repoInfo.setUrl(url);
           repoInfo.setProxyHost(proxyHost);
           repoInfo.setProxyUserName(proxyUser);
  
  
  
  1.8       +14 -1     
maven-plugins/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java
  
  Index: RepositoryInfo.java
  ===================================================================
  RCS file: 
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/RepositoryInfo.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RepositoryInfo.java       28 Sep 2004 09:20:40 -0000      1.7
  +++ RepositoryInfo.java       29 Sep 2004 10:56:04 -0000      1.8
  @@ -58,6 +58,9 @@
       /** File mode. */
       private String mode;
   
  +    /** Directory mode. */
  +    private String directoryMode;
  +
       /** The passpharse of the user's private key file */
       private String passphrase;
   
  @@ -188,6 +191,16 @@
       public void setPrivateKey(String privateKey)
       {
           this.privateKey = privateKey;
  +    }
  +
  +    public String getDirectoryMode()
  +    {
  +        return directoryMode;
  +    }
  +
  +    public void setDirectoryMode( String directoryMode )
  +    {
  +        this.directoryMode = directoryMode;
       }
   
       public String getMode()
  
  
  
  1.14      +33 -13    
maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java
  
  Index: FtpDeployer.java
  ===================================================================
  RCS file: 
/home/cvs/maven-plugins/artifact/src/main/org/apache/maven/deploy/deployers/FtpDeployer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FtpDeployer.java  28 Sep 2004 09:20:40 -0000      1.13
  +++ FtpDeployer.java  29 Sep 2004 10:56:04 -0000      1.14
  @@ -54,6 +54,7 @@
       public final static String PROTOCOL = "ftp://";;
   
       private FTPClient ftp = null;
  +    private RepositoryInfo repoInfo = null;
       private static final Log LOG = LogFactory.getLog(FtpDeployer.class);
   
       /* (non-Javadoc)
  @@ -129,15 +130,17 @@
               {
                   ftp.enterLocalPassiveMode();
               }
  -            
  -            ftp.changeWorkingDirectory(repoInfo.getBasedir());
  -
  +            handleCommand( ftp.changeWorkingDirectory(repoInfo.getBasedir()));
           }
           catch (IOException e)
           {
               throw new AuthenticationException("Cannot login to remote system",e);
           }
  -
  +        catch (TransferFailedException e)
  +        {
  +            throw new AuthenticationException("Cannot locate base directory", e );
  +        }
  +        this.repoInfo = repoInfo;
       }
   
       /* (non-Javadoc)
  @@ -170,27 +173,44 @@
               String[] dirs = StringUtils.split(request.dirname(), "/");
               for (int i = 0; i < dirs.length; i++)
               {
  -                ftp.makeDirectory(dirs[i]);
  -                ftp.changeWorkingDirectory(dirs[i]);
  +                if ( !ftp.changeWorkingDirectory(dirs[i])) {
  +                    handleCommand( ftp.makeDirectory(dirs[i]));
  +                    // Ignore errors
  +                    ftp.sendSiteCommand( "CHGRP " + repoInfo.getGroup() + " " + 
dirs[i] );
  +                    ftp.sendSiteCommand( "CHMOD " + repoInfo.getDirectoryMode() + " 
" + dirs[i] );
  +                    handleCommand( ftp.changeWorkingDirectory(dirs[i]));
  +                }
               }
  -            ftp.storeFile(
  +            handleCommand( ftp.storeFile(
                   request.filename(),
  -                new FileInputStream(request.getSrcFile()));
  -            // TODO: test first, then mark MPARTIFACT-24 complete
  -            //ftp.executeSiteCommand( "CHGRP " + request.getGroup() + " " + 
request.filename() );
  -            //ftp.executeSiteCommand( "CHMOD " + request.getMode() + " " + 
request.filename() );
  +                new FileInputStream(request.getSrcFile())));
  +            // Ignore errors
  +            ftp.sendSiteCommand( "CHGRP " + repoInfo.getGroup() + " " + 
request.filename() );
  +            ftp.sendSiteCommand( "CHMOD " + repoInfo.getMode() + " " + 
request.filename() );
               for (int i = 0; i < dirs.length; i++)
               {
  -               ftp.changeWorkingDirectory("..");
  +                handleCommand( ftp.changeWorkingDirectory(".."));
               }
   
           }
  +        catch (TransferFailedException e)
  +        {
  +            throw e;
  +        }
           catch (Exception e)
           {
               throw new TransferFailedException(e.getMessage(),e);
           }
   
       }
  +
  +    private void handleCommand( boolean response ) throws TransferFailedException
  +    {
  +        if ( !response )
  +        {
  +            throw new TransferFailedException( "Error executing FTP command" );
  +        }
  +    }    
   
       /**
        * Description of the Class
  
  
  
  1.31      +2 -0      maven-plugins/artifact/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/xdocs/changes.xml,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- changes.xml       28 Sep 2004 09:20:40 -0000      1.30
  +++ changes.xml       29 Sep 2004 10:56:04 -0000      1.31
  @@ -26,6 +26,7 @@
     </properties>
     <body>
       <release version="1.4.1" date="in CVS">
  +      <action dev="brett" type="fix">Improve error handling in FTPDeployer</action>
         <action dev="brett" type="fix" issue="MPARTIFACT-38">Allow scpexe protocol to 
work better with args</action>
         <action dev="brett" type="fix" issue="MPARTIFACT-34">Check return code of 
spawned external processes</action>
         <action dev="brett" type="fix" issue="MPARTIFACT-32">Remove old snapshots 
that were created with symlinks before deployment.</action>
  @@ -36,6 +37,7 @@
         <action dev="brett" type="fix" issue="MPARTIFACT-30">Fix group setting for 
scp deployer</action>
         <action dev="brett" type="fix" issue="MPARTIFACT-12">Add mode setting for 
remote repository</action>
         <action dev="brett" type="fix" issue="MPARTIFACT-11">Fix group setting for 
SFTP deployer</action>
  +      <action dev="brett" type="fix" issue="MPARTIFACT-24">Fix group setting for 
FTP deployer</action>
       </release>
       <release version="1.4" date="2004-07-10">
         <action dev="brett" type="fix" issue="MPARTIFACT-23">Add overwrite option to 
unzip - necessary to run in batch mode</action>
  
  
  
  1.12      +13 -1     maven-plugins/artifact/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/artifact/xdocs/properties.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- properties.xml    28 Sep 2004 09:20:40 -0000      1.11
  +++ properties.xml    29 Sep 2004 10:56:04 -0000      1.12
  @@ -108,7 +108,19 @@
             <td>
               The remote file mode (UNIX permissions) to which
               the artifact will be set to after it 
  -            is deployed. Default is <code>664</code>.
  +            is deployed. Default is <code>g+w</code>.
  +          </td>
  +          <td>Yes</td>
  +        </tr>
  +        <tr>
  +          <td>maven.repo.x.directory.mode</td>
  +          <td>
  +            The remote directory mode (UNIX permissions) 
  +            when directories are created while deploying the artifact.
  +            Default is <code>maven.repo.x.mode</code>.
  +            <b>Warning:</b> if you are using an octal file permission,
  +            you should not use the default value for this as you should
  +            add the executable permission for directories.
             </td>
             <td>Yes</td>
           </tr>
  
  
  

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

Reply via email to