Search in sources :

Example 1 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.

the class SubversionApi method list.

/**
     * List remote subversion directory.
     *
     * @param request
     *         the request
     *
     * @return the response containing target children
     */
public ListResponse list(final ListRequest request) throws ApiException {
    final List<String> args = defaultArgs();
    args.add("list");
    final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), singletonList(request.getTargetPath()), request.getUsername(), request.getPassword());
    return newDto(ListResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrorOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) File(java.io.File)

Example 2 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.

the class SubversionApi method commit.

/**
     * Perform an "svn commit" 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 CLIOutputWithRevisionResponse commit(final CommitRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> cliArgs = defaultArgs();
    // Flags
    addFlag(cliArgs, "--keep-changelists", request.isKeepChangeLists());
    addFlag(cliArgs, "--no-unlock", request.isKeepLocks());
    // Command Name
    cliArgs.add("commit");
    // Command Arguments
    cliArgs.add("-m");
    cliArgs.add(request.getMessage());
    final CommandLineResult result = runCommand(null, cliArgs, projectPath, addWorkingCopyPathIfNecessary(request.getPaths()));
    return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class).withCommand(result.getCommandLine().toString()).withRevision(SubversionUtils.getCommitRevision(result.getStdout())).withOutput(result.getStdout()).withErrOutput(result.getStderr());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) File(java.io.File)

Example 3 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult in project che by eclipse.

the class SubversionApi method getRevisions.

public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> uArgs = defaultArgs();
    addOption(uArgs, "--revision", request.getRevisionRange());
    uArgs.add("log");
    final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
    final GetRevisionsResponse response = DtoFactory.getInstance().createDto(GetRevisionsResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
    if (result.getExitCode() == 0) {
        List<String> revisions = result.getStdout().parallelStream().filter(line -> line.split("\\|").length == 4).map(line -> line.split("\\|")[0].trim()).collect(Collectors.toList());
        response.withRevisions(revisions);
    }
    return response;
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) PropertySetRequest(org.eclipse.che.plugin.svn.shared.PropertySetRequest) UpdateRequest(org.eclipse.che.plugin.svn.shared.UpdateRequest) Arrays(java.util.Arrays) LineConsumerFactory(org.eclipse.che.api.core.util.LineConsumerFactory) InfoRequest(org.eclipse.che.plugin.svn.shared.InfoRequest) PropertyGetRequest(org.eclipse.che.plugin.svn.shared.PropertyGetRequest) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) Date(java.util.Date) CopyRequest(org.eclipse.che.plugin.svn.shared.CopyRequest) LoggerFactory(org.slf4j.LoggerFactory) RemoveRequest(org.eclipse.che.plugin.svn.shared.RemoveRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Collections.singletonList(java.util.Collections.singletonList) SubversionUtils(org.eclipse.che.plugin.svn.server.utils.SubversionUtils) ZipUtils(org.eclipse.che.commons.lang.ZipUtils) ListRequest(org.eclipse.che.plugin.svn.shared.ListRequest) CleanupRequest(org.eclipse.che.plugin.svn.shared.CleanupRequest) Map(java.util.Map) CommitRequest(org.eclipse.che.plugin.svn.shared.CommitRequest) UnauthorizedException(org.eclipse.che.api.core.UnauthorizedException) Path(java.nio.file.Path) PropertyDeleteRequest(org.eclipse.che.plugin.svn.shared.PropertyDeleteRequest) RepositoryUrlProvider(org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider) ResolveRequest(org.eclipse.che.plugin.svn.shared.ResolveRequest) SwitchRequest(org.eclipse.che.plugin.svn.shared.SwitchRequest) DtoFactory.newDto(org.eclipse.che.dto.server.DtoFactory.newDto) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Nullable(org.eclipse.che.commons.annotation.Nullable) IoUtil(org.eclipse.che.commons.lang.IoUtil) SshScriptProvider(org.eclipse.che.plugin.ssh.key.script.SshScriptProvider) List(java.util.List) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) Predicate(com.google.common.base.Predicate) MergeRequest(org.eclipse.che.plugin.svn.shared.MergeRequest) InfoUtils.getRelativeUrl(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRelativeUrl) ShowLogRequest(org.eclipse.che.plugin.svn.shared.ShowLogRequest) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) Singleton(com.google.inject.Singleton) SubversionUtils.recognizeProjectUri(org.eclipse.che.plugin.svn.server.utils.SubversionUtils.recognizeProjectUri) Iterables(com.google.common.collect.Iterables) LockRequest(org.eclipse.che.plugin.svn.shared.LockRequest) CLIOutputResponseList(org.eclipse.che.plugin.svn.shared.CLIOutputResponseList) GetRevisionsRequest(org.eclipse.che.plugin.svn.shared.GetRevisionsRequest) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) HashMap(java.util.HashMap) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ApiException(org.eclipse.che.api.core.ApiException) Files(com.google.common.io.Files) SshEnvironment(org.eclipse.che.plugin.svn.server.utils.SshEnvironment) InfoUtils.getRepositoryRoot(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRepositoryRoot) DtoFactory(org.eclipse.che.dto.server.DtoFactory) MediaType(com.google.common.net.MediaType) GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) Logger(org.slf4j.Logger) ErrorCodes(org.eclipse.che.api.core.ErrorCodes) Iterator(java.util.Iterator) IOException(java.io.IOException) StatusRequest(org.eclipse.che.plugin.svn.shared.StatusRequest) File(java.io.File) InfoUtils(org.eclipse.che.plugin.svn.server.utils.InfoUtils) PropertyListRequest(org.eclipse.che.plugin.svn.shared.PropertyListRequest) ShowDiffRequest(org.eclipse.che.plugin.svn.shared.ShowDiffRequest) ServerException(org.eclipse.che.api.core.ServerException) UpstreamUtils(org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils) AddRequest(org.eclipse.che.plugin.svn.shared.AddRequest) RevertRequest(org.eclipse.che.plugin.svn.shared.RevertRequest) DeleteOnCloseFileInputStream(org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream) MoveRequest(org.eclipse.che.plugin.svn.shared.MoveRequest) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) File(java.io.File)

Example 4 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult 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());
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) PropertySetRequest(org.eclipse.che.plugin.svn.shared.PropertySetRequest) UpdateRequest(org.eclipse.che.plugin.svn.shared.UpdateRequest) Arrays(java.util.Arrays) LineConsumerFactory(org.eclipse.che.api.core.util.LineConsumerFactory) InfoRequest(org.eclipse.che.plugin.svn.shared.InfoRequest) PropertyGetRequest(org.eclipse.che.plugin.svn.shared.PropertyGetRequest) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) Date(java.util.Date) CopyRequest(org.eclipse.che.plugin.svn.shared.CopyRequest) LoggerFactory(org.slf4j.LoggerFactory) RemoveRequest(org.eclipse.che.plugin.svn.shared.RemoveRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Collections.singletonList(java.util.Collections.singletonList) SubversionUtils(org.eclipse.che.plugin.svn.server.utils.SubversionUtils) ZipUtils(org.eclipse.che.commons.lang.ZipUtils) ListRequest(org.eclipse.che.plugin.svn.shared.ListRequest) CleanupRequest(org.eclipse.che.plugin.svn.shared.CleanupRequest) Map(java.util.Map) CommitRequest(org.eclipse.che.plugin.svn.shared.CommitRequest) UnauthorizedException(org.eclipse.che.api.core.UnauthorizedException) Path(java.nio.file.Path) PropertyDeleteRequest(org.eclipse.che.plugin.svn.shared.PropertyDeleteRequest) RepositoryUrlProvider(org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider) ResolveRequest(org.eclipse.che.plugin.svn.shared.ResolveRequest) SwitchRequest(org.eclipse.che.plugin.svn.shared.SwitchRequest) DtoFactory.newDto(org.eclipse.che.dto.server.DtoFactory.newDto) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Nullable(org.eclipse.che.commons.annotation.Nullable) IoUtil(org.eclipse.che.commons.lang.IoUtil) SshScriptProvider(org.eclipse.che.plugin.ssh.key.script.SshScriptProvider) List(java.util.List) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) Predicate(com.google.common.base.Predicate) MergeRequest(org.eclipse.che.plugin.svn.shared.MergeRequest) InfoUtils.getRelativeUrl(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRelativeUrl) ShowLogRequest(org.eclipse.che.plugin.svn.shared.ShowLogRequest) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) Singleton(com.google.inject.Singleton) SubversionUtils.recognizeProjectUri(org.eclipse.che.plugin.svn.server.utils.SubversionUtils.recognizeProjectUri) Iterables(com.google.common.collect.Iterables) LockRequest(org.eclipse.che.plugin.svn.shared.LockRequest) CLIOutputResponseList(org.eclipse.che.plugin.svn.shared.CLIOutputResponseList) GetRevisionsRequest(org.eclipse.che.plugin.svn.shared.GetRevisionsRequest) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) HashMap(java.util.HashMap) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ApiException(org.eclipse.che.api.core.ApiException) Files(com.google.common.io.Files) SshEnvironment(org.eclipse.che.plugin.svn.server.utils.SshEnvironment) InfoUtils.getRepositoryRoot(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRepositoryRoot) DtoFactory(org.eclipse.che.dto.server.DtoFactory) MediaType(com.google.common.net.MediaType) GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) Logger(org.slf4j.Logger) ErrorCodes(org.eclipse.che.api.core.ErrorCodes) Iterator(java.util.Iterator) IOException(java.io.IOException) StatusRequest(org.eclipse.che.plugin.svn.shared.StatusRequest) File(java.io.File) InfoUtils(org.eclipse.che.plugin.svn.server.utils.InfoUtils) PropertyListRequest(org.eclipse.che.plugin.svn.shared.PropertyListRequest) ShowDiffRequest(org.eclipse.che.plugin.svn.shared.ShowDiffRequest) ServerException(org.eclipse.che.api.core.ServerException) UpstreamUtils(org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils) AddRequest(org.eclipse.che.plugin.svn.shared.AddRequest) RevertRequest(org.eclipse.che.plugin.svn.shared.RevertRequest) DeleteOnCloseFileInputStream(org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream) MoveRequest(org.eclipse.che.plugin.svn.shared.MoveRequest) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) InfoRequest(org.eclipse.che.plugin.svn.shared.InfoRequest) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) File(java.io.File)

Example 5 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult 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());
}
Also used : CheckoutRequest(org.eclipse.che.plugin.svn.shared.CheckoutRequest) PropertySetRequest(org.eclipse.che.plugin.svn.shared.PropertySetRequest) UpdateRequest(org.eclipse.che.plugin.svn.shared.UpdateRequest) Arrays(java.util.Arrays) LineConsumerFactory(org.eclipse.che.api.core.util.LineConsumerFactory) InfoRequest(org.eclipse.che.plugin.svn.shared.InfoRequest) PropertyGetRequest(org.eclipse.che.plugin.svn.shared.PropertyGetRequest) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) Date(java.util.Date) CopyRequest(org.eclipse.che.plugin.svn.shared.CopyRequest) LoggerFactory(org.slf4j.LoggerFactory) RemoveRequest(org.eclipse.che.plugin.svn.shared.RemoveRequest) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) Collections.singletonList(java.util.Collections.singletonList) SubversionUtils(org.eclipse.che.plugin.svn.server.utils.SubversionUtils) ZipUtils(org.eclipse.che.commons.lang.ZipUtils) ListRequest(org.eclipse.che.plugin.svn.shared.ListRequest) CleanupRequest(org.eclipse.che.plugin.svn.shared.CleanupRequest) Map(java.util.Map) CommitRequest(org.eclipse.che.plugin.svn.shared.CommitRequest) UnauthorizedException(org.eclipse.che.api.core.UnauthorizedException) Path(java.nio.file.Path) PropertyDeleteRequest(org.eclipse.che.plugin.svn.shared.PropertyDeleteRequest) RepositoryUrlProvider(org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider) ResolveRequest(org.eclipse.che.plugin.svn.shared.ResolveRequest) SwitchRequest(org.eclipse.che.plugin.svn.shared.SwitchRequest) DtoFactory.newDto(org.eclipse.che.dto.server.DtoFactory.newDto) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Nullable(org.eclipse.che.commons.annotation.Nullable) IoUtil(org.eclipse.che.commons.lang.IoUtil) SshScriptProvider(org.eclipse.che.plugin.ssh.key.script.SshScriptProvider) List(java.util.List) HttpHeaders(javax.ws.rs.core.HttpHeaders) Response(javax.ws.rs.core.Response) Predicate(com.google.common.base.Predicate) MergeRequest(org.eclipse.che.plugin.svn.shared.MergeRequest) InfoUtils.getRelativeUrl(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRelativeUrl) ShowLogRequest(org.eclipse.che.plugin.svn.shared.ShowLogRequest) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) SubversionItem(org.eclipse.che.plugin.svn.shared.SubversionItem) Singleton(com.google.inject.Singleton) SubversionUtils.recognizeProjectUri(org.eclipse.che.plugin.svn.server.utils.SubversionUtils.recognizeProjectUri) Iterables(com.google.common.collect.Iterables) LockRequest(org.eclipse.che.plugin.svn.shared.LockRequest) CLIOutputResponseList(org.eclipse.che.plugin.svn.shared.CLIOutputResponseList) GetRevisionsRequest(org.eclipse.che.plugin.svn.shared.GetRevisionsRequest) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) HashMap(java.util.HashMap) CLIOutputWithRevisionResponse(org.eclipse.che.plugin.svn.shared.CLIOutputWithRevisionResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ApiException(org.eclipse.che.api.core.ApiException) Files(com.google.common.io.Files) SshEnvironment(org.eclipse.che.plugin.svn.server.utils.SshEnvironment) InfoUtils.getRepositoryRoot(org.eclipse.che.plugin.svn.server.utils.InfoUtils.getRepositoryRoot) DtoFactory(org.eclipse.che.dto.server.DtoFactory) MediaType(com.google.common.net.MediaType) GetRevisionsResponse(org.eclipse.che.plugin.svn.shared.GetRevisionsResponse) Logger(org.slf4j.Logger) ErrorCodes(org.eclipse.che.api.core.ErrorCodes) Iterator(java.util.Iterator) IOException(java.io.IOException) StatusRequest(org.eclipse.che.plugin.svn.shared.StatusRequest) File(java.io.File) InfoUtils(org.eclipse.che.plugin.svn.server.utils.InfoUtils) PropertyListRequest(org.eclipse.che.plugin.svn.shared.PropertyListRequest) ShowDiffRequest(org.eclipse.che.plugin.svn.shared.ShowDiffRequest) ServerException(org.eclipse.che.api.core.ServerException) UpstreamUtils(org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils) AddRequest(org.eclipse.che.plugin.svn.shared.AddRequest) RevertRequest(org.eclipse.che.plugin.svn.shared.RevertRequest) DeleteOnCloseFileInputStream(org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream) MoveRequest(org.eclipse.che.plugin.svn.shared.MoveRequest) InfoResponse(org.eclipse.che.plugin.svn.shared.InfoResponse) InfoRequest(org.eclipse.che.plugin.svn.shared.InfoRequest) CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) ListResponse(org.eclipse.che.plugin.svn.shared.ListResponse) File(java.io.File)

Aggregations

CommandLineResult (org.eclipse.che.plugin.svn.server.upstream.CommandLineResult)28 File (java.io.File)27 CLIOutputResponse (org.eclipse.che.plugin.svn.shared.CLIOutputResponse)18 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)5 InfoResponse (org.eclipse.che.plugin.svn.shared.InfoResponse)5 ListResponse (org.eclipse.che.plugin.svn.shared.ListResponse)5 Predicate (com.google.common.base.Predicate)4 Path (java.nio.file.Path)4 Date (java.util.Date)4 Response (javax.ws.rs.core.Response)4 ServerException (org.eclipse.che.api.core.ServerException)4 UnauthorizedException (org.eclipse.che.api.core.UnauthorizedException)4 DeleteOnCloseFileInputStream (org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream)4 SubversionItem (org.eclipse.che.plugin.svn.shared.SubversionItem)4 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)3 Iterables (com.google.common.collect.Iterables)3 Files (com.google.common.io.Files)3 MediaType (com.google.common.net.MediaType)3 Singleton (com.google.inject.Singleton)3