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