use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method info.
/**
* Returns information about specified target.
*
* @param request
* request
* @return response containing list of subversion items
* @throws SubversionException
*/
public InfoResponse info(final InfoRequest request) throws SubversionException, UnauthorizedException {
final List<String> args = defaultArgs();
if (request.getRevision() != null && !request.getRevision().trim().isEmpty()) {
addOption(args, "--revision", request.getRevision());
}
if (request.getChildren()) {
addOption(args, "--depth", "immediates");
}
args.add("info");
List<String> paths = new ArrayList<>();
paths.add(request.getTarget());
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), addWorkingCopyPathIfNecessary(paths), request.getUsername(), request.getPassword());
final InfoResponse response = DtoFactory.getInstance().createDto(InfoResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrorOutput(result.getStderr());
if (result.getExitCode() == 0) {
List<SubversionItem> items = new ArrayList<>();
response.withItems(items);
Iterator<String> iterator = result.getStdout().iterator();
List<String> itemProperties = new ArrayList<>();
while (iterator.hasNext()) {
String propertyLine = iterator.next();
if (propertyLine.isEmpty()) {
// create Subversion item filling properties from the list
String repositoryRoot = getRepositoryRoot(itemProperties);
String relativeUrl = getRelativeUrl(itemProperties);
final SubversionItem item = DtoFactory.getInstance().createDto(SubversionItem.class).withPath(InfoUtils.getPath(itemProperties)).withName(InfoUtils.getName(itemProperties)).withURL(InfoUtils.getUrl(itemProperties)).withRelativeURL(relativeUrl).withRepositoryRoot(repositoryRoot).withRepositoryUUID(InfoUtils.getRepositoryUUID(itemProperties)).withRevision(InfoUtils.getRevision(itemProperties)).withNodeKind(InfoUtils.getNodeKind(itemProperties)).withSchedule(InfoUtils.getSchedule(itemProperties)).withLastChangedRev(InfoUtils.getLastChangedRev(itemProperties)).withLastChangedDate(InfoUtils.getLastChangedDate(itemProperties)).withProjectUri(recognizeProjectUri(repositoryRoot, relativeUrl));
items.add(item);
// clear item properties
itemProperties.clear();
} else {
// add property line to property list
itemProperties.add(propertyLine);
}
}
} else {
response.withErrorOutput(result.getStderr());
}
return response;
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method revert.
/**
* Perform an "svn revert" 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 revert(RevertRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
addOption(cliArgs, "--depth", request.getDepth());
cliArgs.add("revert");
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 proplist.
/**
* Perform an "svn proplist" 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 proplist(final PropertyListRequest request) throws IOException, ServerException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> uArgs = defaultArgs();
uArgs.add("proplist");
final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
List<String> output;
if (result.getStdout() != null && result.getStdout().size() > 0) {
output = result.getStdout().subList(1, result.getStdout().size());
} else {
output = result.getStdout();
}
return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(output);
}
use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.
the class SubversionApi method remove.
/**
* Perform an "svn remove" 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 remove(final RemoveRequest request) throws IOException, SubversionException, UnauthorizedException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
// Command Name
cliArgs.add("remove");
final CommandLineResult result = runCommand(null, cliArgs, projectPath, 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 doSwitch.
/**
* Perform a "svn switch" based on the request.
*
* @param request
* the switch request
* @return the response
* @throws ApiException
* if there is a Subversion issue
*/
public CLIOutputWithRevisionResponse doSwitch(final SwitchRequest request) throws ApiException {
final File projectPath = new File(request.getProjectPath());
final List<String> cliArgs = defaultArgs();
// Flags
addFlag(cliArgs, "--ignore-externals", request.isIgnoreExternals());
addFlag(cliArgs, "--ignore-ancestry", request.isIgnoreAncestry());
addFlag(cliArgs, "--relocate", request.isRelocate());
addFlag(cliArgs, "--force", request.isForce());
// Options
addOption(cliArgs, "--depth", request.getDepth());
addOption(cliArgs, "--set-depth", request.getSetDepth());
addOption(cliArgs, "--revision", request.getRevision());
addOption(cliArgs, "--accept", request.getAccept());
// Command Name
cliArgs.add("switch");
CommandLineResult result = runCommand(null, cliArgs, projectPath, singletonList(request.getLocation()), request.getUsername(), request.getPassword());
return newDto(CLIOutputWithRevisionResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr()).withRevision(SubversionUtils.getUpdateRevision(result.getStdout()));
}
Aggregations