/**
* Copyright (c) 2010 Perforce Software. All rights reserved.
*/
package com.perforce.maven.scm.provider.p4.command.login;
import org.apache.maven.scm.CommandParameters;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.command.login.AbstractLoginCommand;
import org.apache.maven.scm.command.login.LoginScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import com.perforce.maven.scm.provider.p4.command.P4ClientExecutor;
import com.perforce.maven.scm.provider.p4.command.P4Command;
import com.perforce.maven.scm.provider.p4.repository.P4ScmProviderRepository;
import com.perforce.p4java.exception.P4JavaException;
import com.perforce.p4java.option.server.LoginOptions;
/**
* The class uses the Perforce login command to log into Perforce server.
*/
public class P4LoginCommand extends AbstractLoginCommand implements P4Command {
/** The Constant command. */
public static final String command = "Perforce login command";
/**
* @see org.apache.maven.scm.command.login.AbstractLoginCommand#executeLoginCommand
* (org.apache.maven.scm.provider.ScmProviderRepository,
* org.apache.maven.scm.ScmFileSet,
* org.apache.maven.scm.CommandParameters)
*/
public LoginScmResult executeLoginCommand(ScmProviderRepository repo,
ScmFileSet files, CommandParameters params) throws ScmException {
boolean isSuccess = false;
P4LoginResult p4Result = new P4LoginResult();
String status = null;
P4ScmProviderRepository p4Repo = (P4ScmProviderRepository) repo;
P4ClientExecutor executor = new P4ClientExecutor(p4Repo, files,
getLogger());
try {
// String password = repo.getPassword();
// Get the password
String password = executor.getP4Passwd();
LoginOptions loginOptions = new LoginOptions();
executor.getServer().login(password, loginOptions);
status = executor.getServer().getLoginStatus();
if (!status.matches("invalid or unset")) {
isSuccess = true;
}
} catch (P4JavaException e) {
if (getLogger().isErrorEnabled()) {
getLogger().error(e);
}
throw new ScmException(e.getLocalizedMessage(), e);
}
return new LoginScmResult(command, isSuccess ? "Login successful"
: "Login failed", status, isSuccess);
}
}
# |
Change |
User |
Description |
Committed |
|
#2
|
10055 |
Matt Attaway |
Pull over numerous changes from @dantran's branch. |
|
|
#1
|
8496 |
Matt Attaway |
Move P4Ant and P4Maven into their proper homes |
|
|
//public/perforce/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/login/P4LoginCommand.java |
#1
|
8270 |
Matt Attaway |
Initial add of P4Maven source code |
|
|