Search in sources :

Example 11 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository in project maven-scm by apache.

the class IntegrityCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
@Override
public CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) throws ScmException {
    getLogger().info("Attempting to check-in updates from sandbox " + fileSet.getBasedir().getAbsolutePath());
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    Sandbox siSandbox = iRepo.getSandbox();
    List<ScmFile> changedFiles = siSandbox.checkInUpdates(message);
    if (siSandbox.getOverallCheckInSuccess()) {
        return new CheckInScmResult("si ci/drop", changedFiles);
    } else {
        return new CheckInScmResult(changedFiles, new ScmResult("si ci/drop", "There was a problem updating the repository", "", false));
    }
}
Also used : ScmResult(org.apache.maven.scm.ScmResult) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) ScmFile(org.apache.maven.scm.ScmFile)

Example 12 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository in project maven-scm by apache.

the class IntegrityDiffCommand method executeDiffCommand.

/**
 * Since we can't arbitrarily apply the same start and end revisions to all files in the sandbox,
 * this command will be adapted to show differences between the local version and the repository
 */
@Override
public DiffScmResult executeDiffCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) throws ScmException {
    DiffScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    APISession api = iRepo.getAPISession();
    getLogger().info("Showing differences bettween local files in " + fileSet.getBasedir().getAbsolutePath() + " and server project " + iRepo.getConfigruationPath());
    // Since the si diff command is not completely API ready, we will use the CLI for this command
    Commandline shell = new Commandline();
    shell.setWorkingDirectory(fileSet.getBasedir());
    shell.setExecutable("si");
    shell.createArg().setValue("diff");
    shell.createArg().setValue("--hostname=" + api.getHostName());
    shell.createArg().setValue("--port=" + api.getPort());
    shell.createArg().setValue("--user=" + api.getUserName());
    shell.createArg().setValue("-R");
    shell.createArg().setValue("--filter=changed:all");
    shell.createArg().setValue("--filter=format:text");
    IntegrityDiffConsumer shellConsumer = new IntegrityDiffConsumer(getLogger());
    try {
        getLogger().debug("Executing: " + shell.getCommandline());
        int exitCode = CommandLineUtils.executeCommandLine(shell, shellConsumer, new CommandLineUtils.StringStreamConsumer());
        boolean success = (exitCode == 128 ? false : true);
        ScmResult scmResult = new ScmResult(shell.getCommandline().toString(), "", "Exit Code: " + exitCode, success);
        // a NPE in org.codehaus.plexus.util.FileUtils.fileWrite(FileUtils.java:426)
        return new DiffScmResult(new ArrayList<ScmFile>(), new HashMap<String, CharSequence>(), "", scmResult);
    } catch (CommandLineException cle) {
        getLogger().error("Command Line Exception: " + cle.getMessage());
        result = new DiffScmResult(shell.getCommandline().toString(), cle.getMessage(), "", false);
    }
    return result;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult) ScmResult(org.apache.maven.scm.ScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) ScmFile(org.apache.maven.scm.ScmFile) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) APISession(org.apache.maven.scm.provider.integrity.APISession) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Example 13 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository in project maven-scm by apache.

the class IntegrityFileInfoCommand method executeFileInfoCommand.

/**
 * Even though this command is supported via the MKS JAVA API, since at this time we really don't
 * know what the SCM plugin is looking to get in return for this command, we're simply going to
 * run this command via the CLI and return the output verbatim
 */
@Override
public ScmResult executeFileInfoCommand(ScmProviderRepository repository, File workingDirectory, String filename) throws ScmException {
    getLogger().info("Attempting to display scm file information for file: " + filename);
    if (null == filename || filename.length() == 0) {
        throw new ScmException("A single filename is required to execute the fileinfo command!");
    }
    ScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    APISession api = iRepo.getAPISession();
    Commandline shell = new Commandline();
    shell.setWorkingDirectory(workingDirectory);
    shell.setExecutable("si");
    shell.createArg().setValue("memberinfo");
    shell.createArg().setValue("--hostname=" + api.getHostName());
    shell.createArg().setValue("--port=" + api.getPort());
    shell.createArg().setValue("--user=" + api.getUserName());
    shell.createArg().setValue('"' + filename + '"');
    IntegrityFileInfoConsumer shellConsumer = new IntegrityFileInfoConsumer(getLogger());
    try {
        getLogger().debug("Executing: " + shell.getCommandline());
        int exitCode = CommandLineUtils.executeCommandLine(shell, shellConsumer, new CommandLineUtils.StringStreamConsumer());
        boolean success = (exitCode == 128 ? false : true);
        result = new ScmResult(shell.getCommandline().toString(), "", "Exit Code: " + exitCode, success);
    } catch (CommandLineException cle) {
        getLogger().error("Command Line Exception: " + cle.getMessage());
        result = new ScmResult(shell.getCommandline().toString(), cle.getMessage(), "", false);
    }
    return result;
}
Also used : ScmException(org.apache.maven.scm.ScmException) ScmResult(org.apache.maven.scm.ScmResult) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) APISession(org.apache.maven.scm.provider.integrity.APISession) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 14 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository in project maven-scm by apache.

the class IntegrityAddCommand method executeAddCommand.

/**
 * {@inheritDoc}
 */
@Override
public AddScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
    getLogger().info("Attempting to add new files from directory " + fileSet.getBasedir().getAbsolutePath());
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    Sandbox siSandbox = iRepo.getSandbox();
    String excludes = Sandbox.formatFilePatterns(fileSet.getExcludes());
    String includes = Sandbox.formatFilePatterns(fileSet.getIncludes());
    String msg = ((null == message || message.length() == 0) ? System.getProperty("message") : message);
    List<ScmFile> addedFiles = siSandbox.addNonMembers(excludes, includes, msg);
    if (siSandbox.getOverallAddSuccess()) {
        return new AddScmResult("si add", addedFiles);
    } else {
        return new AddScmResult(addedFiles, new ScmResult("si add", "There was a problem adding files to the repository", "", false));
    }
}
Also used : AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ScmResult(org.apache.maven.scm.ScmResult) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) ScmFile(org.apache.maven.scm.ScmFile)

Example 15 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository in project maven-scm by apache.

the class IntegrityChangeLogCommand method executeChangeLogCommand.

/**
 * {@inheritDoc}
 */
@Override
public ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
    // First lets validate the date range provided
    if (null == startDate || null == endDate) {
        throw new ScmException("Both 'startDate' and 'endDate' must be specified!");
    }
    if (startDate.after(endDate)) {
        throw new ScmException("'stateDate' is not allowed to occur after 'endDate'!");
    }
    getLogger().info("Attempting to obtain change log for date range: '" + Sandbox.RLOG_DATEFORMAT.format(startDate) + "' to '" + Sandbox.RLOG_DATEFORMAT.format(endDate) + "'");
    ChangeLogScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    try {
        result = new ChangeLogScmResult(iRepo.getSandbox().getChangeLog(startDate, endDate), new ScmResult("si rlog", "", "", true));
    } 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 ChangeLogScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    }
    return result;
}
Also used : ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) ScmException(org.apache.maven.scm.ScmException) APIException(com.mks.api.response.APIException) ScmResult(org.apache.maven.scm.ScmResult) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult)

Aggregations

IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)20 APIException (com.mks.api.response.APIException)15 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)15 Response (com.mks.api.response.Response)11 ScmResult (org.apache.maven.scm.ScmResult)11 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)11 ScmException (org.apache.maven.scm.ScmException)8 ScmFile (org.apache.maven.scm.ScmFile)8 ArrayList (java.util.ArrayList)6 WorkItem (com.mks.api.response.WorkItem)4 File (java.io.File)4 APISession (org.apache.maven.scm.provider.integrity.APISession)3 Project (org.apache.maven.scm.provider.integrity.Project)3 Result (com.mks.api.response.Result)2 WorkItemIterator (com.mks.api.response.WorkItemIterator)2 Member (org.apache.maven.scm.provider.integrity.Member)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1