Search in sources :

Example 11 with CommandLineResult

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

the class SubversionApi method propget.

/**
     * Perform an "svn propget" based on the request.
     *
     * @param request
     *         the request
     * @return the response
     * @throws IOException
     *         if there is a problem executing the command
     * @throws ServerException
     *         if there is a Subversion issue
     */
public CLIOutputResponse propget(final PropertyGetRequest request) throws IOException, ServerException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> uArgs = defaultArgs();
    uArgs.add("propget");
    uArgs.add(request.getName());
    final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
    return DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout());
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) File(java.io.File)

Example 12 with CommandLineResult

use of org.eclipse.che.plugin.svn.server.upstream.CommandLineResult 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 13 with CommandLineResult

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

the class SubversionApi method propdel.

/**
     * Perform an "svn propdel" based on the request.
     *
     * @param request
     *         the request
     * @return the response
     * @throws IOException
     *         if there is a problem executing the command
     * @throws ServerException
     *         if there is a Subversion issue
     */
public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    final List<String> uArgs = defaultArgs();
    addDepth(uArgs, request.getDepth().getValue());
    uArgs.add("propdel");
    uArgs.add(request.getName());
    final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath()));
    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 14 with CommandLineResult

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

the class SubversionApi method move.

/**
     * Perform an "svn move" 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 move(final MoveRequest request) throws IOException, SubversionException, UnauthorizedException {
    Predicate<String> sourcePredicate = new Predicate<String>() {

        @Override
        public boolean apply(String input) {
            return input.startsWith("file://");
        }
    };
    //for security reason we should forbid file protocol
    if (Iterables.any(request.getSource(), sourcePredicate) || request.getDestination().startsWith("file://")) {
        throw new SubversionException("Url is not acceptable");
    }
    final File projectPath = new File(request.getProjectPath());
    final List<String> cliArgs = defaultArgs();
    if (!isNullOrEmpty(request.getComment())) {
        addOption(cliArgs, "--message", "\"" + request.getComment() + "\"");
    }
    // Command Name
    cliArgs.add("move");
    final List<String> paths = new ArrayList<>();
    paths.addAll(request.getSource());
    paths.add(request.getDestination());
    final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths, request.getUsername(), request.getPassword());
    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) ArrayList(java.util.ArrayList) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) File(java.io.File) Predicate(com.google.common.base.Predicate)

Example 15 with CommandLineResult

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

the class SubversionApi method resolve.

/**
     * Perform an "svn resolve" 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 CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException, UnauthorizedException {
    final File projectPath = new File(request.getProjectPath());
    Map<String, String> resolutions = request.getConflictResolutions();
    List<CLIOutputResponse> results = new ArrayList<>();
    for (String path : resolutions.keySet()) {
        final List<String> uArgs = defaultArgs();
        addDepth(uArgs, request.getDepth());
        addOption(uArgs, "--accept", resolutions.get(path));
        uArgs.add("resolve");
        final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(path));
        CLIOutputResponse outputResponse = DtoFactory.getInstance().createDto(CLIOutputResponse.class).withCommand(result.getCommandLine().toString()).withOutput(result.getStdout()).withErrOutput(result.getStderr());
        results.add(outputResponse);
    }
    return DtoFactory.getInstance().createDto(CLIOutputResponseList.class).withCLIOutputResponses(results);
}
Also used : CommandLineResult(org.eclipse.che.plugin.svn.server.upstream.CommandLineResult) CLIOutputResponseList(org.eclipse.che.plugin.svn.shared.CLIOutputResponseList) ArrayList(java.util.ArrayList) CLIOutputResponse(org.eclipse.che.plugin.svn.shared.CLIOutputResponse) 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