Search in sources :

Example 1 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class UrlSerializationHelper method serializeUrl.

private static String serializeUrl(final String url, final Ref<Boolean> withUserInfo) {
    if (Boolean.FALSE.equals(withUserInfo.get())) {
        return url;
    }
    try {
        final SVNURL svnurl = SVNURL.parseURIEncoded(url);
        if (withUserInfo.isNull()) {
            final String userInfo = svnurl.getUserInfo();
            withUserInfo.set((userInfo != null) && (userInfo.length() > 0));
        }
        if (withUserInfo.get()) {
            return SVNURL.create(svnurl.getProtocol(), null, svnurl.getHost(), SvnUtil.resolvePort(svnurl), svnurl.getURIEncodedPath(), true).toString();
        }
    } catch (SVNException e) {
    //
    }
    return url;
}
Also used : SVNURL(org.tmatesoft.svn.core.SVNURL) SVNException(org.tmatesoft.svn.core.SVNException)

Example 2 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class CmdBrowseClient method list.

@Override
public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException {
    assertUrl(target);
    List<String> parameters = new ArrayList<>();
    CommandUtil.put(parameters, target);
    CommandUtil.put(parameters, revision);
    CommandUtil.put(parameters, depth);
    parameters.add("--xml");
    CommandExecutor command = execute(myVcs, target, SvnCommandName.list, parameters, null);
    Info info = myFactory.createInfoClient().doInfo(target, revision);
    try {
        parseOutput(target.getURL(), command, handler, info != null ? info.getRepositoryRootURL() : null);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ArrayList(java.util.ArrayList) CommandExecutor(org.jetbrains.idea.svn.commandLine.CommandExecutor) SVNException(org.tmatesoft.svn.core.SVNException) Info(org.jetbrains.idea.svn.info.Info) CommitInfo(org.jetbrains.idea.svn.checkin.CommitInfo)

Example 3 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnAuthenticationNotifier method validationImpl.

private static boolean validationImpl(final Project project, final SVNURL url, final SvnConfiguration configuration, final SvnAuthenticationManager manager, final boolean checkWrite, final String realm, final String kind, boolean interactive) {
    // we should also NOT show proxy credentials dialog if at least fixed proxy was used, so
    Proxy proxyToRelease = null;
    if (!interactive && configuration.isIsUseDefaultProxy()) {
        final HttpConfigurable instance = HttpConfigurable.getInstance();
        if (instance.USE_HTTP_PROXY && instance.PROXY_AUTHENTICATION && (StringUtil.isEmptyOrSpaces(instance.getProxyLogin()) || StringUtil.isEmptyOrSpaces(instance.getPlainProxyPassword()))) {
            return false;
        }
        if (instance.USE_PROXY_PAC) {
            final List<Proxy> select;
            try {
                select = CommonProxy.getInstance().select(new URI(url.toString()));
            } catch (URISyntaxException e) {
                LOG.info("wrong URL: " + url.toString());
                return false;
            }
            if (select != null && !select.isEmpty()) {
                for (Proxy proxy : select) {
                    if (HttpConfigurable.isRealProxy(proxy) && Proxy.Type.HTTP.equals(proxy.type())) {
                        final InetSocketAddress address = (InetSocketAddress) proxy.address();
                        final PasswordAuthentication password = HttpConfigurable.getInstance().getGenericPassword(address.getHostName(), address.getPort());
                        if (password == null) {
                            CommonProxy.getInstance().noAuthentication("http", address.getHostName(), address.getPort());
                            proxyToRelease = proxy;
                        }
                    }
                }
            }
        }
    }
    SvnInteractiveAuthenticationProvider.clearCallState();
    try {
        // start svnkit authentication cycle
        SvnVcs.getInstance(project).getSvnKitManager().createWCClient(manager).doInfo(url, SVNRevision.UNDEFINED, SVNRevision.HEAD);
    //SvnVcs.getInstance(project).getInfo(url, SVNRevision.HEAD, manager);
    } catch (SVNAuthenticationException | SVNCancelException e) {
        log(e);
        return false;
    } catch (final SVNException e) {
        if (e.getErrorMessage().getErrorCode().isAuthentication()) {
            log(e);
            return false;
        }
        LOG.info("some other exc", e);
        if (interactive) {
            showAuthenticationFailedWithHotFixes(project, configuration, e);
        }
        /// !!!! any exception means user should be notified that authorization failed
        return false;
    } finally {
        if (!interactive && configuration.isIsUseDefaultProxy() && proxyToRelease != null) {
            final InetSocketAddress address = (InetSocketAddress) proxyToRelease.address();
            CommonProxy.getInstance().noAuthentication("http", address.getHostName(), address.getPort());
        }
    }
    if (!checkWrite) {
        return true;
    }
    if (SvnInteractiveAuthenticationProvider.wasCalled() && SvnInteractiveAuthenticationProvider.wasCancelled())
        return false;
    if (SvnInteractiveAuthenticationProvider.wasCalled())
        return true;
    final SvnVcs svnVcs = SvnVcs.getInstance(project);
    final SvnInteractiveAuthenticationProvider provider = new SvnInteractiveAuthenticationProvider(svnVcs, manager);
    final SVNAuthentication svnAuthentication = provider.requestClientAuthentication(kind, url, realm, null, null, true);
    if (svnAuthentication != null) {
        configuration.acknowledge(kind, realm, svnAuthentication);
        try {
            configuration.getAuthenticationManager(svnVcs).acknowledgeAuthentication(true, kind, realm, null, svnAuthentication);
        } catch (SVNException e) {
            LOG.info(e);
        }
        return true;
    }
    return false;
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) CommonProxy(com.intellij.util.proxy.CommonProxy) HttpConfigurable(com.intellij.util.net.HttpConfigurable) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) SVNAuthenticationException(org.tmatesoft.svn.core.SVNAuthenticationException) SVNAuthentication(org.tmatesoft.svn.core.auth.SVNAuthentication)

Example 4 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnKitImportClient method doImport.

@Override
public long doImport(@NotNull File path, @NotNull SVNURL url, @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, @Nullable ISVNCommitHandler commitHandler) throws VcsException {
    SVNCommitClient client = myVcs.getSvnKitManager().createCommitClient();
    client.setEventHandler(toEventHandler(handler));
    client.setCommitHandler(commitHandler);
    try {
        SVNCommitInfo info = client.doImport(path, url, message, null, !noIgnore, false, toDepth(depth));
        return info.getNewRevision();
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNCommitInfo(org.tmatesoft.svn.core.SVNCommitInfo) SVNCommitClient(org.tmatesoft.svn.core.wc.SVNCommitClient) SVNException(org.tmatesoft.svn.core.SVNException)

Example 5 with SVNException

use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.

the class SvnKitCheckoutClient method checkout.

@Override
public void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException {
    assertUrl(source);
    validateFormat(format, getSupportedFormats());
    SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient();
    client.setIgnoreExternals(ignoreExternals);
    client.setEventHandler(toEventHandler(handler));
    try {
        runCheckout(client, format, source, destination, revision, depth, force);
    } catch (SVNException e) {
        throw new SvnBindException(e);
    }
}
Also used : SVNUpdateClient(org.tmatesoft.svn.core.wc.SVNUpdateClient) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

SVNException (org.tmatesoft.svn.core.SVNException)95 File (java.io.File)37 SVNURL (org.tmatesoft.svn.core.SVNURL)37 VcsException (com.intellij.openapi.vcs.VcsException)18 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)14 SVNConfigFile (org.tmatesoft.svn.core.internal.wc.SVNConfigFile)14 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)8 List (java.util.List)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)7 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)7 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)7 Date (java.util.Date)6 NotNull (org.jetbrains.annotations.NotNull)6 SVNCancelException (org.tmatesoft.svn.core.SVNCancelException)6 SVNLogEntry (org.tmatesoft.svn.core.SVNLogEntry)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5