Search in sources :

Example 21 with CLIOutputResponse

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

the class SubversionApi method add.

/**
     * Perform an "svn add" 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 add(final AddRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> args = defaultArgs();
    // Flags
    addFlag(args, "--no-ignore", request.isAddIgnored());
    addFlag(args, "--parents", request.isAddParents());
    if (request.isAutoProps()) {
        args.add("--auto-props");
    }
    if (request.isNotAutoProps()) {
        args.add("--no-auto-props");
    }
    // Options
    addOption(args, "--depth", request.getDepth());
    // Command Name
    args.add("add");
    // Command Arguments
    final CommandLineResult result = runCommand(null, args, projectPath, request.getPaths());
    return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) File(java.io.File)

Example 22 with CLIOutputResponse

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

the class CopyPresenter method onCopyClicked.

/** {@inheritDoc} */
@Override
public void onCopyClicked() {
    final Project project = appContext.getRootProject();
    Preconditions.checkState(project != null);
    final Path src = view.isSourceCheckBoxSelected() ? Path.valueOf(view.getSourcePath()) : toRelative(project, sourceNode);
    final Path target = view.isTargetCheckBoxSelected() ? Path.valueOf(view.getTargetUrl()) : toRelative(project, this.target);
    final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null;
    final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    view.hide();
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            notification.setStatus(PROGRESS);
            notification.setTitle(constants.copyNotificationStarted(src.toString()));
            return service.copy(project.getLocation(), src, target, comment, credentials);
        }
    }, notification).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy());
            notification.setTitle(constants.copyNotificationSuccessful());
            notification.setStatus(SUCCESS);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setTitle(constants.copyNotificationFailed());
            notification.setStatus(FAIL);
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) 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) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 23 with CLIOutputResponse

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

the class LockUnlockPresenter method doLockAction.

private void doLockAction(final boolean force, final Path[] paths) {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation<CLIOutputResponse>() {

        @Override
        public Promise<CLIOutputResponse> perform(Credentials credentials) {
            return service.lock(project.getLocation(), paths, force, credentials);
        }
    }, null).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandLock());
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) Promise(org.eclipse.che.api.promises.client.Promise) PromiseError(org.eclipse.che.api.promises.client.PromiseError) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Operation(org.eclipse.che.api.promises.client.Operation) Credentials(org.eclipse.che.ide.api.subversion.Credentials) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 24 with CLIOutputResponse

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

the class SubversionClientServiceImpl method listTags.

@Override
public Promise<CLIOutputResponse> listTags(Path project, @Nullable Credentials credentials) {
    ListRequest request = dtoFactory.createDto(ListRequest.class).withProjectPath(project.toString());
    if (credentials != null) {
        request.setUsername(credentials.getUsername());
        request.setPassword(credentials.getPassword());
    }
    return asyncRequestFactory.createPostRequest(getBaseUrl() + "/tags", request).loader(loader).send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class));
}
Also used : ListRequest(org.eclipse.che.plugin.svn.shared.ListRequest) PropertyListRequest(org.eclipse.che.plugin.svn.shared.PropertyListRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse)

Example 25 with CLIOutputResponse

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

the class AddPresenter method showAdd.

public void showAdd() {
    final Project project = appContext.getRootProject();
    checkState(project != null);
    final Resource[] resources = appContext.getResources();
    checkState(!Arrays.isNullOrEmpty(resources));
    final StatusNotification notification = new StatusNotification(constants.addStarted(resources.length), PROGRESS, FLOAT_MODE);
    notificationManager.notify(notification);
    service.add(project.getLocation(), toRelative(project, resources), null, false, true, false, false).then(new Operation<CLIOutputResponse>() {

        @Override
        public void apply(CLIOutputResponse response) throws OperationException {
            printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandAdd());
            if (response.getErrOutput() == null || response.getErrOutput().size() == 0) {
                notification.setTitle(constants.addSuccessful());
                notification.setStatus(SUCCESS);
            } else {
                notification.setTitle(constants.addWarning());
                notification.setStatus(FAIL);
            }
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError error) throws OperationException {
            notification.setTitle(constants.addFailed() + ": " + error.getMessage());
            notification.setStatus(FAIL);
        }
    });
}
Also used : Project(org.eclipse.che.ide.api.resources.Project) PromiseError(org.eclipse.che.api.promises.client.PromiseError) Resource(org.eclipse.che.ide.api.resources.Resource) StatusNotification(org.eclipse.che.ide.api.notification.StatusNotification) Operation(org.eclipse.che.api.promises.client.Operation) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)49 Operation (org.eclipse.che.api.promises.client.Operation)21 OperationException (org.eclipse.che.api.promises.client.OperationException)21 PromiseError (org.eclipse.che.api.promises.client.PromiseError)21 Project (org.eclipse.che.ide.api.resources.Project)18 File (java.io.File)14 Resource (org.eclipse.che.ide.api.resources.Resource)14 CommandLineResult (org.eclipse.che.plugin.svn.server.upstream.CommandLineResult)14 StatusNotification (org.eclipse.che.ide.api.notification.StatusNotification)7 Promise (org.eclipse.che.api.promises.client.Promise)6 Credentials (org.eclipse.che.ide.api.subversion.Credentials)6 ArrayList (java.util.ArrayList)5 CheckoutRequest (org.eclipse.che.plugin.svn.shared.CheckoutRequest)5 Test (org.junit.Test)4 Path (org.eclipse.che.ide.resource.Path)3 ListRequest (org.eclipse.che.plugin.svn.shared.ListRequest)3 PropertyListRequest (org.eclipse.che.plugin.svn.shared.PropertyListRequest)3 CLIOutputResponseList (org.eclipse.che.plugin.svn.shared.CLIOutputResponseList)2 Depth (org.eclipse.che.plugin.svn.shared.Depth)2 LockRequest (org.eclipse.che.plugin.svn.shared.LockRequest)2