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));
}
}
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;
}
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;
}
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));
}
}
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;
}
Aggregations