Search in sources :

Example 6 with UnEditScmResult

use of org.apache.maven.scm.command.unedit.UnEditScmResult in project maven-scm by apache.

the class StarteamUnEditCommand method executeUnEditCommand.

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

Example 7 with UnEditScmResult

use of org.apache.maven.scm.command.unedit.UnEditScmResult in project maven-scm by apache.

the class TfsUnEditCommand method executeUnEditCommand.

protected ScmResult executeUnEditCommand(ScmProviderRepository r, ScmFileSet f) throws ScmException {
    FileListConsumer out = new FileListConsumer();
    ErrorStreamConsumer err = new ErrorStreamConsumer();
    TfsCommand command = createCommand(r, f);
    int status = command.execute(out, err);
    if (status != 0 || err.hasBeenFed()) {
        return new UnEditScmResult(command.getCommandString(), "Error code for TFS unedit command - " + status, err.getOutput(), false);
    }
    return new UnEditScmResult(command.getCommandString(), out.getFiles());
}
Also used : FileListConsumer(org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) ErrorStreamConsumer(org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer)

Example 8 with UnEditScmResult

use of org.apache.maven.scm.command.unedit.UnEditScmResult in project maven-scm by apache.

the class JazzUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeUnEditCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing unedit command...");
    }
    DebugLoggerConsumer uneditConsumer = new DebugLoggerConsumer(getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    JazzScmCommand uneditCmd = createUneditCommand(repo, fileSet);
    int status = uneditCmd.execute(uneditConsumer, errConsumer);
    if (status != 0) {
        return new UnEditScmResult(uneditCmd.getCommandString(), "Error code for Jazz SCM unedit command - " + status, errConsumer.getOutput(), false);
    }
    return new UnEditScmResult(uneditCmd.getCommandString(), "Successfully Completed.", uneditConsumer.getOutput(), true);
}
Also used : ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) DebugLoggerConsumer(org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)

Example 9 with UnEditScmResult

use of org.apache.maven.scm.command.unedit.UnEditScmResult in project maven-scm by apache.

the class IntegrityUnEditCommand method executeUnEditCommand.

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

Example 10 with UnEditScmResult

use of org.apache.maven.scm.command.unedit.UnEditScmResult in project maven-scm by apache.

the class SynergyUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing unedit command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        File waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
        File destPath = new File(waPath, repo.getProjectName());
        for (File f : fileSet.getFileList()) {
            File source = new File(fileSet.getBasedir(), f.getPath());
            File dest = new File(destPath, f.getPath());
            SynergyUtil.delete(getLogger(), dest, ccmAddr, true);
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Copy file [" + dest + "] to [" + source + "].");
                }
                try {
                    FileUtils.copyFile(dest, source);
                } catch (IOException e) {
                    throw new ScmException("Unable to restore file in output folder", e);
                }
            }
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> files = new ArrayList<ScmFile>();
    for (File f : fileSet.getFileList()) {
        files.add(new ScmFile(f.getPath(), ScmFileStatus.UNKNOWN));
    }
    return new UnEditScmResult("", files);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)12 File (java.io.File)2 IOException (java.io.IOException)2 ScmException (org.apache.maven.scm.ScmException)2 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmFile (org.apache.maven.scm.ScmFile)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)1 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)1 IntegrityUnEditCommand (org.apache.maven.scm.provider.integrity.command.unedit.IntegrityUnEditCommand)1 IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)1 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)1 DebugLoggerConsumer (org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)1 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)1 JazzUnEditCommand (org.apache.maven.scm.provider.jazz.command.unedit.JazzUnEditCommand)1