use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class ShowLogPresenter method showLog.
/**
* Fetches the count of revisions and opens the popup.
*/
public void showLog() {
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(!Arrays.isNullOrEmpty(resources));
checkState(resources.length == 1);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
SubversionItem subversionItem = response.getItems().get(0);
view.setRevisionCount(subversionItem.getRevision());
view.rangeField().setValue("1:" + subversionItem.getRevision());
view.show();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class MergePresenter method merge.
/**
* Prepares to merging and opens Merge dialog.
*/
public void merge() {
view.enableMergeButton(false);
view.sourceCheckBox().setValue(false);
final Project project = appContext.getRootProject();
checkState(project != null);
final Resource[] resources = appContext.getResources();
checkState(resources != null && resources.length == 1);
performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<InfoResponse>() {
@Override
public Promise<InfoResponse> perform(Credentials credentials) {
return service.info(project.getLocation(), toRelative(project, resources[0]).toString(), "HEAD", false, credentials);
}
}, null).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
mergeTarget = response.getItems().get(0);
view.targetTextBox().setValue(mergeTarget.getRelativeURL());
String repositoryRoot = mergeTarget.getRepositoryRoot();
service.info(project.getLocation(), repositoryRoot, "HEAD", true).then(new Operation<InfoResponse>() {
@Override
public void apply(InfoResponse response) throws OperationException {
if (!response.getErrorOutput().isEmpty()) {
printErrors(response.getErrorOutput(), constants.commandInfo());
notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE);
return;
}
sourceURL = response.getItems().get(0).getURL();
SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0));
List<Node> children = new ArrayList<>();
if (response.getItems().size() > 1) {
for (int i = 1; i < response.getItems().size(); i++) {
SubversionItem item = response.getItems().get(i);
if (!"file".equals(item.getNodeKind())) {
children.add(new SubversionItemNode(item));
}
}
}
subversionTreeNode.setChildren(children);
view.setRootNode(subversionTreeNode);
view.show();
validateSourceURL();
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
use of org.eclipse.che.plugin.svn.shared.InfoResponse in project che by eclipse.
the class SubversionApiITest method testInfo.
@Test
public void testInfo() throws Exception {
subversionApi.checkout(DtoFactory.getInstance().createDto(CheckoutRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withUrl(repoUrl).withDepth("immediates"));
InfoResponse response = subversionApi.info(DtoFactory.getInstance().createDto(InfoRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withTarget(".").withRevision("HEAD"));
assertEquals(response.getItems().size(), 1);
SubversionItem subversionItem = response.getItems().get(0);
assertEquals(subversionItem.getProjectUri(), repoUrl.substring(0, repoUrl.length() - 1));
}
Aggregations