use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class SynergyAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing add command...");
}
SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
if (getLogger().isDebugEnabled()) {
getLogger().debug("basedir: " + fileSet.getBasedir());
}
if (message == null || message.equals("")) {
message = "Maven SCM Synergy provider: adding file(s) to project " + repo.getProjectSpec();
}
String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
try {
int taskNum = SynergyUtil.createTask(getLogger(), message, repo.getProjectRelease(), true, ccmAddr);
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 source : fileSet.getFileList()) {
File dest = new File(destPath, SynergyUtil.removePrefix(fileSet.getBasedir(), source));
if (!source.equals(dest)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Copy file [" + source + "] to Synergy Work Area [" + dest + "].");
}
try {
FileUtils.copyFile(source, dest);
} catch (IOException e) {
throw new ScmException("Unable to copy file in Work Area", e);
}
}
SynergyUtil.create(getLogger(), dest, message, ccmAddr);
}
SynergyUtil.checkinTask(getLogger(), taskNum, message, ccmAddr);
} finally {
SynergyUtil.stop(getLogger(), ccmAddr);
}
List<ScmFile> scmFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
for (File f : fileSet.getFileList()) {
scmFiles.add(new ScmFile(f.getPath(), ScmFileStatus.ADDED));
}
return new AddScmResult("", scmFiles);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class AccuRevAddCommand method executeAccurevCommand.
/**
* Add.
*
* @todo handle the "binary" parameter. AccuRev does a reasonable job of detecting this itself.
*/
protected ScmResult executeAccurevCommand(AccuRevScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException, AccuRevException {
AccuRev accuRev = repository.getAccuRev();
String message = parameters.getString(CommandParameter.MESSAGE, "");
File basedir = fileSet.getBasedir();
List<File> relativeFiles = fileSet.getFileList();
List<File> addedFiles = accuRev.add(basedir, relativeFiles, message);
if (addedFiles != null) {
List<ScmFile> resultFiles = getScmFiles(addedFiles, ScmFileStatus.ADDED);
return new AddScmResult(accuRev.getCommandLines(), resultFiles);
} else {
return new AddScmResult(accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false);
}
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class LocalScmProvider method add.
/**
* {@inheritDoc}
*/
public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
LocalAddCommand command = new LocalAddCommand();
command.setLogger(getLogger());
return (AddScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class LocalAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;
List<ScmFile> fileList = new ArrayList<ScmFile>();
for (File file : fileSet.getFileList()) {
String path = file.getPath().replace('\\', '/');
localRepo.addFile(path);
fileList.add(new ScmFile(path, ScmFileStatus.ADDED));
}
// TODO: Also, ensure it is tested from the update test
return new AddScmResult(null, fileList);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class LocalMkdirCommand method executeMkdirCommand.
protected MkdirScmResult executeMkdirCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) throws ScmException {
LocalScmProviderRepository repo = (LocalScmProviderRepository) repository;
List<ScmFile> createdDirs = new ArrayList<ScmFile>();
// create/commit the directory directly in the repository
if (!createInLocal) {
File file = (File) fileSet.getFileList().get(0);
File modulePath = new File(repo.getRoot(), repo.getModule());
File dir = new File(modulePath, file.getName());
if (dir.exists()) {
return new MkdirScmResult(null, "Directory already exists!", "Directory already exists.", false);
} else {
if (getLogger().isInfoEnabled()) {
getLogger().info("Creating directory in '" + modulePath.getAbsolutePath() + "'");
}
FileUtils.mkdir(dir.getAbsolutePath());
createdDirs.add(new ScmFile(dir.getPath(), ScmFileStatus.ADDED));
}
} else {
// add the directory, but not commit
LocalAddCommand addCmd = new LocalAddCommand();
addCmd.setLogger(getLogger());
CommandParameters parameters = new CommandParameters();
parameters.setString(CommandParameter.MESSAGE, message);
parameters.setString(CommandParameter.BINARY, "false");
String path = ((File) fileSet.getFileList().get(0)).getPath();
if (repo.isFileAdded(path)) {
return new MkdirScmResult(null, "Directory already exists!", "Directory already exists.", false);
}
AddScmResult result = (AddScmResult) addCmd.execute(repository, fileSet, parameters);
createdDirs.addAll(result.getAddedFiles());
}
return new MkdirScmResult(null, createdDirs);
}
Aggregations