ftp improvements

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
brett 2004-09-29 10:56:04 +00:00
parent 6859e07a9d
commit 360948ac36
5 changed files with 73 additions and 17 deletions

View File

@ -27,7 +27,7 @@ import org.apache.maven.project.Project;
* Perform mapping between project's properties and attributes of DeployRequest class.
*
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: RepositoryInfoBuilder.java,v 1.8 2004/09/28 09:20:40 brett Exp $
* @version $Id: RepositoryInfoBuilder.java,v 1.9 2004/09/29 10:56:03 brett Exp $
*/
public class RepositoryInfoBuilder
{
@ -87,6 +87,10 @@ public class RepositoryInfoBuilder
(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 @@ public class RepositoryInfoBuilder
}
if (remoteMode == null) {
remoteMode = "664";
remoteMode = "g+w";
}
if (remoteDirectoryMode == null) {
remoteDirectoryMode = remoteMode;
}
repoInfo.setUserName(username);
@ -129,6 +137,7 @@ public class RepositoryInfoBuilder
repoInfo.setPrivateKey(privateKey);
repoInfo.setGroup(remoteGroup);
repoInfo.setMode(remoteMode);
repoInfo.setDirectoryMode(remoteDirectoryMode);
repoInfo.setUrl(url);
repoInfo.setProxyHost(proxyHost);
repoInfo.setProxyUserName(proxyUser);

View File

@ -23,7 +23,7 @@ package org.apache.maven.deploy;
* perform a deployment.
*
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: RepositoryInfo.java,v 1.7 2004/09/28 09:20:40 brett Exp $
* @version $Id: RepositoryInfo.java,v 1.8 2004/09/29 10:56:04 brett Exp $
*/
public class RepositoryInfo
{
@ -58,6 +58,9 @@ public class RepositoryInfo
/** File mode. */
private String mode;
/** Directory mode. */
private String directoryMode;
/** The passpharse of the user's private key file */
private String passphrase;
@ -190,6 +193,16 @@ public class RepositoryInfo
this.privateKey = privateKey;
}
public String getDirectoryMode()
{
return directoryMode;
}
public void setDirectoryMode( String directoryMode )
{
this.directoryMode = directoryMode;
}
public String getMode()
{
return mode;

View File

@ -42,7 +42,7 @@ import org.apache.maven.deploy.exceptions.TransferFailedException;
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @author <a href="mailto:michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id: FtpDeployer.java,v 1.13 2004/09/28 09:20:40 brett Exp $
* @version $Id: FtpDeployer.java,v 1.14 2004/09/29 10:56:04 brett Exp $
*
* @todo review exception handling
* @todo don't spool to System.out
@ -54,6 +54,7 @@ public class FtpDeployer extends AbstractDeployer
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 @@ public class FtpDeployer extends AbstractDeployer
{
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,21 +173,30 @@ public class FtpDeployer extends AbstractDeployer
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);
@ -192,6 +204,14 @@ public class FtpDeployer extends AbstractDeployer
}
private void handleCommand( boolean response ) throws TransferFailedException
{
if ( !response )
{
throw new TransferFailedException( "Error executing FTP command" );
}
}
/**
* Description of the Class
*/

View File

@ -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>

View File

@ -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>