use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.
the class StarteamScmProvider method makeProviderScmRepository.
// ----------------------------------------------------------------------
// ScmProvider Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) throws ScmRepositoryException {
String user = null;
String password = null;
int index = scmSpecificUrl.indexOf('@');
String rest = scmSpecificUrl;
if (index != -1) {
String userAndPassword = scmSpecificUrl.substring(0, index);
rest = scmSpecificUrl.substring(index + 1);
index = userAndPassword.indexOf(':');
if (index != -1) {
user = userAndPassword.substring(0, index);
password = userAndPassword.substring(index + 1);
} else {
user = userAndPassword;
}
}
String[] tokens = StringUtils.split(rest, Character.toString(delimiter));
String host;
int port;
String path;
if (tokens.length == 3) {
host = tokens[0];
port = Integer.valueOf(tokens[1]).intValue();
path = tokens[2];
} else if (tokens.length == 2) {
if (getLogger().isWarnEnabled()) {
getLogger().warn("Your scm URL use a deprecated format. The new format is :" + STARTEAM_URL_FORMAT);
}
host = tokens[0];
if (tokens[1].indexOf('/') == -1) {
throw new ScmRepositoryException("Invalid SCM URL: The url has to be on the form: " + STARTEAM_URL_FORMAT);
}
int at = tokens[1].indexOf('/');
port = new Integer(tokens[1].substring(0, at)).intValue();
path = tokens[1].substring(at);
} else {
throw new ScmRepositoryException("Invalid SCM URL: The url has to be on the form: " + STARTEAM_URL_FORMAT);
}
try {
return new StarteamScmProviderRepository(user, password, host, port, path);
} catch (Exception e) {
throw new ScmRepositoryException("Invalid SCM URL: The url has to be on the form: " + STARTEAM_URL_FORMAT);
}
}
use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.
the class StarteamAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
// work around until maven-scm-api allow this
String issue = System.getProperty("maven.scm.issue");
if (getLogger().isInfoEnabled()) {
getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
}
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
StarteamAddConsumer consumer = new StarteamAddConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
for (File fileToBeAdded : fileSet.getFileList()) {
ScmFileSet scmFile = new ScmFileSet(fileSet.getBasedir(), fileToBeAdded);
Commandline cl = createCommandLine(repository, scmFile, issue);
int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
if (exitCode != 0) {
return new AddScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
}
}
return new AddScmResult(null, consumer.getAddedFiles());
}
use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.
the class StarteamChangeLogCommand method executeChangeLogCommand.
// ----------------------------------------------------------------------
// AbstractChangeLogCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repo, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
if ((branch != null || StringUtils.isNotEmpty((branch == null) ? null : branch.getName())) && (getLogger().isWarnEnabled())) {
getLogger().warn("This provider doesn't support changelog with on a given branch.");
}
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
// TODO: revision
Commandline cl = createCommandLine(repository, fileSet, startDate);
StarteamChangeLogConsumer consumer = new StarteamChangeLogConsumer(fileSet.getBasedir(), getLogger(), startDate, endDate, datePattern);
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new ChangeLogScmResult(cl.toString(), "The 'stcmd' command failed.", stderr.getOutput(), false);
}
return new ChangeLogScmResult(cl.toString(), new ChangeLogSet(consumer.getModifications(), startDate, endDate));
}
use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.
the class StarteamUnEditCommandTest method testCommandLine.
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
private void testCommandLine(String scmUrl, ScmFileSet fileName, String commandLine) throws Exception {
ScmRepository repo = getScmManager().makeScmRepository(scmUrl);
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
Commandline cl = StarteamUnEditCommand.createCommandLine(repository, fileName);
assertCommandLine(commandLine, null, cl);
}
use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.
the class StarteamCheckOutCommand method executeCheckOutCommand.
// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
/**
* {@inheritDoc}
*/
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
if (fileSet.getFileList().size() != 0) {
throw new ScmException("This provider doesn't support checking out subsets of a directory");
}
if (getLogger().isInfoEnabled()) {
getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
}
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
StarteamCheckOutConsumer consumer = new StarteamCheckOutConsumer(getLogger(), fileSet.getBasedir());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
Commandline cl = createCommandLine(repository, fileSet, version);
int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
if (exitCode != 0) {
return new CheckOutScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
}
return new CheckOutScmResult(cl.toString(), consumer.getCheckedOutFiles());
}
Aggregations