Search in sources :

Example 1 with StarteamScmProviderRepository

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);
    }
}
Also used : ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) IOException(java.io.IOException) ScmException(org.apache.maven.scm.ScmException)

Example 2 with StarteamScmProviderRepository

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());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) File(java.io.File)

Example 3 with StarteamScmProviderRepository

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));
}
Also used : ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 4 with StarteamScmProviderRepository

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);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)

Example 5 with StarteamScmProviderRepository

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());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult)

Aggregations

StarteamScmProviderRepository (org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)24 Commandline (org.codehaus.plexus.util.cli.Commandline)22 StarteamCommandLineUtils (org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils)11 ScmRepository (org.apache.maven.scm.repository.ScmRepository)11 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)11 File (java.io.File)6 ScmException (org.apache.maven.scm.ScmException)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)6 IOException (java.io.IOException)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)1