use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.
the class CommitPresenter method loadSelectionChanges.
private void loadSelectionChanges() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
service.status(project.getLocation(), toRelative(project, resources), null, false, false, false, true, false, null).then(new Operation<CLIOutputResponse>() {
@Override
public void apply(CLIOutputResponse response) throws OperationException {
List<StatusItem> statusItems = parseChangesList(response);
view.setChangesList(statusItems);
cache.put(Changes.SELECTION, statusItems);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.error(CommitPresenter.class, error.getMessage());
}
});
}
use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.
the class SubversionApi method propdel.
/**
* Perform an "svn propdel" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws ServerException
* if there is a Subversion issue
*/
public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> uArgs = defaultArgs();
addDepth(uArgs, request.getDepth().getValue());
uArgs.add("propdel");
uArgs.add(request.getName());
final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.
the class SubversionApi method move.
/**
* Perform an "svn move" 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 move(final MoveRequest request) throws IOException, SubversionException, UnauthorizedException {
Predicate<String> sourcePredicate = new Predicate<String>() {
@Override
public boolean apply(String input) {
return input.startsWith("file://");
}
};
//for security reason we should forbid file protocol
if (Iterables.any(request.getSource(), sourcePredicate) || 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("move");
final List<String> paths = new ArrayList<>();
paths.addAll(request.getSource());
paths.add(request.getDestination());
final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths, 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.shared.CLIOutputResponse in project che by eclipse.
the class SubversionApi method resolve.
/**
* Perform an "svn resolve" 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 CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
Map<String, String> resolutions = request.getConflictResolutions();
List<CLIOutputResponse> results = new ArrayList<>();
for (String path : resolutions.keySet()) {
final List<String> uArgs = defaultArgs();
addDepth(uArgs, request.getDepth());
addOption(uArgs, "--accept", resolutions.get(path));
uArgs.add("resolve");
final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(path));
CLIOutputResponse outputResponse = DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
results.add(outputResponse);
}
return DtoFactory.getInstance().createDto(CLIOutputResponseList.class).withCLIOutputResponses(results);
}
use of org.eclipse.che.plugin.svn.shared.CLIOutputResponse in project che by eclipse.
the class SubversionApi method propset.
/**
* Perform an "svn propset" based on the request.
*
* @param request
* the request
* @return the response
* @throws IOException
* if there is a problem executing the command
* @throws ServerException
* if there is a Subversion issue
*/
public CLIOutputResponse propset(final PropertySetRequest request) throws IOException, ServerException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> uArgs = defaultArgs();
if (request.isForce()) {
uArgs.add("--force");
}
addDepth(uArgs, request.getDepth().getValue());
uArgs.add("propset");
uArgs.add(request.getName());
String value = request.getValue();
Path valueFile = null;
if (value.contains("\n")) {
try {
valueFile = java.nio.file.Files.createTempFile("svn-propset-value-", null);
java.nio.file.Files.write(valueFile, value.getBytes());
uArgs.add("-F");
uArgs.add(valueFile.toString());
} catch (IOException e) {
uArgs.add(value);
}
} else {
uArgs.add(value);
}
final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Aggregations