use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class SubversionClientServiceImpl method info.
@Override
public Promise<InfoResponse> info(Path project, String target, String revision, boolean children, Credentials credentials) {
final InfoRequest request = dtoFactory.createDto(InfoRequest.class).withProjectPath(project.toString()).withTarget(target).withRevision(revision).withChildren(children);
if (credentials != null) {
request.setUsername(credentials.getUsername());
request.setPassword(credentials.getPassword());
}
return asyncRequestFactory.createPostRequest(getBaseUrl() + "/info", request).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(InfoResponse.class));
}
use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class SubversionApi method listTags.
/**
* Returns list of the tags of the project.
*
* @param request
* the request
*
* @see #list(ListRequest)
* @see #info(InfoRequest)
*/
public ListResponse listTags(final ListRequest request) throws ApiException {
InfoResponse info = info(newDto(InfoRequest.class).withProjectPath(request.getProjectPath()).withTarget(".").withPassword(request.getPassword()).withUsername(request.getUsername()));
final List<String> args = defaultArgs();
args.add("list");
String repositoryRoot = getRepositoryRoot(info.getOutput());
String projectRelativeUrl = getRelativeUrl(info.getOutput());
String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl);
String branchesPath = projectUri == null ? "^/tags" : (projectUri + "/tags");
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(branchesPath), request.getUsername(), request.getPassword());
return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout().stream().filter(s -> s.endsWith("/")).map(s -> s.substring(0, s.length() - 1)).collect(Collectors.toList())).withErrorOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class SubversionApi method listBranches.
/**
* Returns list of the branches of the project.
*
* @param request
* the request
*
* @see #list(ListRequest)
* @see #info(InfoRequest)
*/
public ListResponse listBranches(final ListRequest request) throws ApiException {
InfoResponse info = info(newDto(InfoRequest.class).withProjectPath(request.getProjectPath()).withTarget(".").withPassword(request.getPassword()).withUsername(request.getUsername()));
final List<String> args = defaultArgs();
args.add("list");
String repositoryRoot = getRepositoryRoot(info.getOutput());
String projectRelativeUrl = getRelativeUrl(info.getOutput());
String projectUri = recognizeProjectUri(repositoryRoot, projectRelativeUrl);
String path = projectUri == null ? "^/branches" : (projectUri + "/branches");
final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(path), request.getUsername(), request.getPassword());
return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout().stream().filter(s -> s.endsWith("/")).map(s -> s.substring(0, s.length() - 1)).collect(Collectors.toList())).withErrorOutput(result.getStderr());
}
use of org.eclipse.che.plugin.svn.shared.InfoResponse 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.shared.InfoResponse in project che by eclipse.
the class SwitchPresenter method showWindow.
public void showWindow() {
final Project project = appContext.getRootProject();
checkState(project != null);
switchView.showWindow();
switchView.setSwitchButtonEnabled(false);
invalidateLoadedData();
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(appContext.getRootProject().getLocation(), ".", "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (!response.getItems().isEmpty()) {
SubversionItem subversionItem = response.getItems().get(0);
projectUri = subversionItem.getProjectUri();
}
defaultViewInitialization();
handleSwitchButton();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
projectUri = "^";
Path location = appContext.getRootProject().getLocation();
notificationManager.notify(constants.infoRequestError(location.toString()), error.getMessage(), FAIL, EMERGE_MODE);
defaultViewInitialization();
handleSwitchButton();
}
});
}
Aggregations