Search in sources :

Example 1 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class IntegrityScmProvider method edit.

/**
 * Maps to si makewritable
 */
@Override
protected EditScmResult edit(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    IntegrityEditCommand command = new IntegrityEditCommand();
    command.setLogger(getLogger());
    return (EditScmResult) command.execute(repository, fileSet, params);
}
Also used : UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) IntegrityEditCommand(org.apache.maven.scm.provider.integrity.command.edit.IntegrityEditCommand)

Example 2 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class EditMojo method execute.

/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException {
    super.execute();
    try {
        ScmRepository repository = getScmRepository();
        EditScmResult result = getScmManager().edit(repository, getFileSet());
        checkResult(result);
    } catch (IOException e) {
        throw new MojoExecutionException("Cannot run edit command : ", e);
    } catch (ScmException e) {
        throw new MojoExecutionException("Cannot run edit command : ", e);
    }
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) IOException(java.io.IOException)

Example 3 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class TfsScmProvider method edit.

protected EditScmResult edit(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    TfsEditCommand command = new TfsEditCommand();
    command.setLogger(getLogger());
    return (EditScmResult) command.execute(repository, fileSet, parameters);
}
Also used : TfsEditCommand(org.apache.maven.scm.provider.tfs.command.TfsEditCommand) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult)

Example 4 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class IntegrityEditCommand method executeEditCommand.

/**
 * {@inheritDoc}
 */
@Override
public EditScmResult executeEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    getLogger().info("Attempting make files writeable in Sandbox " + fileSet.getBasedir().getAbsolutePath());
    EditScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    try {
        Sandbox siSandbox = iRepo.getSandbox();
        Response res = siSandbox.makeWriteable();
        int exitCode = res.getExitCode();
        boolean success = (exitCode == 0 ? true : false);
        result = new EditScmResult(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 EditScmResult(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) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 5 with EditScmResult

use of org.apache.maven.scm.command.edit.EditScmResult in project maven-scm by apache.

the class StarteamEditCommand method executeEditCommand.

// ----------------------------------------------------------------------
// AbstractEditCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected ScmResult executeEditCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamEditConsumer consumer = new StarteamEditConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    List<File> editFiles = fileSet.getFileList();
    if (editFiles.size() == 0) {
        Commandline cl = createCommandLine(repository, fileSet);
        int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            return new EditScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
        }
    } else {
        // edit only interested files already on the local disk
        for (int i = 0; i < editFiles.size(); ++i) {
            ScmFileSet editFile = new ScmFileSet(fileSet.getBasedir(), (File) editFiles.get(i));
            Commandline cl = createCommandLine(repository, editFile);
            int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
            if (exitCode != 0) {
                return new EditScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
            }
        }
    }
    return new EditScmResult(null, consumer.getEditedFiles());
}
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) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) File(java.io.File)

Aggregations

EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)17 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)5 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 ScmException (org.apache.maven.scm.ScmException)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ScmFile (org.apache.maven.scm.ScmFile)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 LinkedList (java.util.LinkedList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 ClearCaseEditCommand (org.apache.maven.scm.provider.clearcase.command.edit.ClearCaseEditCommand)1 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)1 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)1 IntegrityEditCommand (org.apache.maven.scm.provider.integrity.command.edit.IntegrityEditCommand)1 IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)1