Search in sources :

Example 1 with CLIOutputWithRevisionResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse in project che by eclipse.

the class UpdatePresenter method doUpdate.

protected void doUpdate(final String revision, final String depth, final boolean ignoreExternals, final UpdateToRevisionView view) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    final StatusNotification notification = new StatusNotification(constants.updateToRevisionStarted(revision), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputWithRevisionResponse>() {

        @Override
        public Promise<CLIOutputWithRevisionResponse> perform(Credentials credentials) {
            notification.setStatus(PROGRESS);
            notification.setTitle(constants.updateToRevisionStarted(revision));
            return service.update(project.getLocation(), toRelative(project, resources), revision, depth, ignoreExternals, "postpone", credentials);
        }
    }, notification).then(new Operation<CLIOutputWithRevisionResponse>() {

        @Override
        public void apply(CLIOutputWithRevisionResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUpdate());
            notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision())));
            notification.setStatus(SUCCESS);
            if (view != null) {
                view.close();
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setTitle(constants.updateFailed());
            notification.setStatus(FAIL);
        }
    });
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with CLIOutputWithRevisionResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse in project che by eclipse.

the class SubversionApiITest method testSwitchToBranch.

@Test
public void testSwitchToBranch() throws Exception {
    subversionApi.checkout(DtoFactory.getInstance().createDto(CheckoutRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withUrl(repoUrl + "/trunk"));
    CLIOutputWithRevisionResponse response = subversionApi.doSwitch(DtoFactory.getInstance().createDto(SwitchRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withLocation("^/branches/2.0").withIgnoreAncestry(true));
    assertTrue(response.getRevision() > -1);
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) Test(org.junit.Test)

Example 3 with CLIOutputWithRevisionResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse in project che by eclipse.

the class SubversionApiITest method testSwitchToTrunk.

@Test
public void testSwitchToTrunk() throws Exception {
    subversionApi.checkout(DtoFactory.getInstance().createDto(CheckoutRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withUrl(repoUrl + "/tags/1.0"));
    CLIOutputWithRevisionResponse response = this.subversionApi.doSwitch(DtoFactory.getInstance().createDto(SwitchRequest.class).withProjectPath(tmpDir.toFile().getAbsolutePath()).withLocation("^/trunk").withIgnoreAncestry(true));
    assertTrue(response.getRevision() > -1);
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) Test(org.junit.Test)

Example 4 with CLIOutputWithRevisionResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse in project che by eclipse.

the class SubversionClientServiceImpl method doSwitch.

@Override
public Promise<CLIOutputWithRevisionResponse> doSwitch(String location, Path project, String revision, String depth, String setDepth, String accept, boolean ignoreExternals, boolean ignoreAncestry, boolean relocate, boolean force, @Nullable Credentials credentials) {
    SwitchRequest request = dtoFactory.createDto(SwitchRequest.class).withLocation(location).withProjectPath(project.toString()).withDepth(depth).withSetDepth(setDepth).withRelocate(relocate).withIgnoreExternals(ignoreExternals).withIgnoreAncestry(ignoreAncestry).withRevision(revision).withAccept(accept).withForce(force);
    if (credentials != null) {
        request.setUsername(credentials.getUsername());
        request.setPassword(credentials.getPassword());
    }
    return asyncRequestFactory.createPostRequest(getBaseUrl() + "/switch", request).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputWithRevisionResponse.class));
}
Also used : SwitchRequest(org.eclipse.che.plugin.svn.shared.SwitchRequest) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse)

Example 5 with CLIOutputWithRevisionResponse

use of org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse in project che by eclipse.

the class SubversionClientServiceImpl method update.

@Override
public Promise<CLIOutputWithRevisionResponse> update(Path project, Path[] paths, String revision, String depth, boolean ignoreExternals, String accept, Credentials credentials) {
    final UpdateRequest request = dtoFactory.createDto(UpdateRequest.class).withProjectPath(project.toString()).withPaths(toList(paths)).withRevision(revision).withDepth(depth).withIgnoreExternals(ignoreExternals).withAccept(accept);
    if (credentials != null) {
        request.setUsername(credentials.getUsername());
        request.setPassword(credentials.getPassword());
    }
    return asyncRequestFactory.createPostRequest(getBaseUrl() + "/update", request).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputWithRevisionResponse.class));
}
Also used : UpdateRequest(org.eclipse.che.plugin.svn.shared.UpdateRequest) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse)

Aggregations

CLIOutputWithRevisionResponse (org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse)11 CheckoutRequest (org.eclipse.che.plugin.svn.shared.CheckoutRequest)6 Test (org.junit.Test)5 Operation (org.eclipse.che.api.promises.client.Operation)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)2 Project (org.eclipse.che.ide.api.resources.Project)2 CommitRequest (org.eclipse.che.plugin.svn.shared.CommitRequest)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Promise (org.eclipse.che.api.promises.client.Promise)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 Credentials (org.eclipse.che.ide.api.subversion.Credentials)1 CommandLineResult (org.eclipse.che.plugin.svn.server.upstream.CommandLineResult)1 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)1 PropertySetRequest (org.eclipse.che.plugin.svn.shared.PropertySetRequest)1 SwitchRequest (org.eclipse.che.plugin.svn.shared.SwitchRequest)1 UpdateRequest (org.eclipse.che.plugin.svn.shared.UpdateRequest)1