use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method exportPath.
/**
* Perform an "svn export" based on the request.
*
* @param projectPath
* project path
* @param path
* exported path
* @param revision
* specified revision to export
* @return Response which contains hyperlink with download url
* @throws IOException
* if there is a problem executing the command
* @throws ServerException
* if there is an exporting issue
*/
public Response exportPath(@NotNull final String projectPath, @NotNull final String path, String revision) throws IOException, ServerException, UnauthorizedException {
final File project = new File(projectPath);
final List<String> uArgs = defaultArgs();
if (!isNullOrEmpty(revision)) {
addOption(uArgs, "--revision", revision);
}
uArgs.add("--force");
uArgs.add("export");
File tempDir = null;
File zip = null;
try {
tempDir = Files.createTempDir();
final CommandLineResult result = runCommand(null, uArgs, project, Arrays.asList(path, tempDir.getAbsolutePath()));
if (result.getExitCode() != 0) {
LOG.warn("Svn export process finished with exit status {}", result.getExitCode());
throw new ServerException("Export failed");
}
zip = new File(Files.createTempDir(), "export.zip");
ZipUtils.zipDir(tempDir.getPath(), tempDir, zip, IoUtil.ANY_FILTER);
} finally {
if (tempDir != null) {
IoUtil.deleteRecursive(tempDir);
}
}
final Response.ResponseBuilder responseBuilder = Response.ok(new DeleteOnCloseFileInputStream(zip), MediaType.ZIP.toString()).lastModified(new Date(zip.lastModified())).header(HttpHeaders.CONTENT_LENGTH, Long.toString(zip.length())).header("Content-Disposition", "attachment; filename=\"export.zip\"");
return responseBuilder.build();
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method copy.
/**
* Perform an "svn copy" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws SubversionException
* if there is a Subversion issue
*/
public CLIOutputResponse copy(final CopyRequest request) throws IOException, SubversionException, UnauthorizedException {
//for security reason we should forbid file protocol
if (request.getSource().startsWith("file://") || request.getDestination().startsWith("file://")) {
throw new SubversionException("Url is not acceptable");
}
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
if (!isNullOrEmpty(request.getComment())) {
addOption(cliArgs, "--message", "\"" + request.getComment() + "\"");
}
// Command Name
cliArgs.add("copy");
final CommandLineResult result = runCommand(null, cliArgs, projectPath, Arrays.asList(request.getSource(), request.getDestination()), request.getUsername(), request.getPassword());
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method showDiff.
/**
* Perform an "svn diff" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws SubversionException
* if there is a Subversion issue
*/
public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> uArgs = defaultArgs();
addOption(uArgs, "--revision", request.getRevision());
uArgs.add("diff");
final CommandLineResult result = runCommand(null, uArgs, projectPath, request.getPaths(), request.getUsername(), request.getPassword());
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method status.
/**
* Perform an "svn status" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws SubversionException
* if there is a Subversion issue
*/
public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
// Flags
addFlag(cliArgs, "--ignore-externals", request.isIgnoreExternals());
addFlag(cliArgs, "--no-ignore", request.isShowIgnored());
addFlag(cliArgs, "--quiet", !request.isShowUnversioned());
addFlag(cliArgs, "--show-updates", request.isShowUpdates());
addFlag(cliArgs, "--verbose", request.isVerbose());
// Options
addOptionList(cliArgs, "--changelist", request.getChangeLists());
addOption(cliArgs, "--depth", request.getDepth());
// Command Name
cliArgs.add("status");
final CommandLineResult result = runCommand(null, cliArgs, projectPath, addWorkingCopyPathIfNecessary(request.getPaths()));
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method merge.
/**
* Merges target with specified URL.
*
* @param request
* merge request
* @return merge response
* @throws IOException
* @throws SubversionException
*/
public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
// Command Name
cliArgs.add("merge");
cliArgs.add(request.getSourceURL());
List<String> paths = new ArrayList<String>();
paths.add(request.getTarget());
final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths);
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Aggregations