Search in sources :

Example 1 with StarteamCheckInConsumer

use of org.apache.maven.scm.provider.starteam.command.checkin.StarteamCheckInConsumer in project maven-scm by apache.

the class StarteamRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException {
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamCheckInConsumer consumer = new StarteamCheckInConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    List<File> remvoveFiles = fileSet.getFileList();
    if (remvoveFiles.size() == 0) {
        Commandline cl = createCommandLine(repository, fileSet);
        int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            return new RemoveScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
        }
    } else {
        // update only interested files already on the local disk
        for (int i = 0; i < remvoveFiles.size(); ++i) {
            File fileToBeRemoved = (File) remvoveFiles.get(i);
            ScmFileSet scmFileSet = new ScmFileSet(fileSet.getBasedir(), fileToBeRemoved);
            Commandline cl = createCommandLine(repository, scmFileSet);
            int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
            if (exitCode != 0) {
                return new RemoveScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
            }
        }
    }
    return new RemoveScmResult(null, consumer.getCheckedInFiles());
}
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) StarteamCheckInConsumer(org.apache.maven.scm.provider.starteam.command.checkin.StarteamCheckInConsumer) File(java.io.File) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Aggregations

File (java.io.File)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1 StarteamCommandLineUtils (org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils)1 StarteamCheckInConsumer (org.apache.maven.scm.provider.starteam.command.checkin.StarteamCheckInConsumer)1 StarteamScmProviderRepository (org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)1 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)1 Commandline (org.codehaus.plexus.util.cli.Commandline)1