Search in sources :

Example 11 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class HgScmProvider method remove.

/**
 * {@inheritDoc}
 */
public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    HgRemoveCommand command = new HgRemoveCommand();
    command.setLogger(getLogger());
    return (RemoveScmResult) command.execute(repository, fileSet, parameters);
}
Also used : HgRemoveCommand(org.apache.maven.scm.provider.hg.command.remove.HgRemoveCommand) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 12 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class IntegrityRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
@Override
public RemoveScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    getLogger().info("Attempting to un-register sandbox in directory " + fileSet.getBasedir().getAbsolutePath());
    RemoveScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    try {
        Sandbox siSandbox = iRepo.getSandbox();
        Response res = siSandbox.drop();
        int exitCode = res.getExitCode();
        boolean success = (exitCode == 0 ? true : false);
        result = new RemoveScmResult(res.getCommandString(), "", "Exit Code: " + exitCode, success);
    } catch (APIException aex) {
        ExceptionHandler eh = new ExceptionHandler(aex);
        getLogger().error("MKS API Exception: " + eh.getMessage());
        getLogger().info(eh.getCommand() + " exited with return code " + eh.getExitCode());
        result = new RemoveScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    }
    return result;
}
Also used : Response(com.mks.api.response.Response) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) APIException(com.mks.api.response.APIException) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 13 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class SvnRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    if (fileSet.getFileList().isEmpty()) {
        throw new ScmException("You must provide at least one file/directory to remove");
    }
    Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList());
    SvnRemoveConsumer consumer = new SvnRemoveConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
        }
    }
    int exitCode;
    try {
        exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new RemoveScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
    }
    return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 14 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class SynergyScmProvider method remove.

/**
 * {@inheritDoc}
 */
public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    SynergyRemoveCommand command = new SynergyRemoveCommand();
    command.setLogger(getLogger());
    return (RemoveScmResult) command.execute(repository, fileSet, parameters);
}
Also used : SynergyRemoveCommand(org.apache.maven.scm.provider.synergy.command.remove.SynergyRemoveCommand) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 15 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult 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

RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)20 File (java.io.File)7 ScmException (org.apache.maven.scm.ScmException)6 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)3 CommandParameters (org.apache.maven.scm.CommandParameters)2 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)2 ScmResult (org.apache.maven.scm.ScmResult)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 ScmRepository (org.apache.maven.scm.repository.ScmRepository)2 Test (org.junit.Test)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1