Search in sources :

Example 1 with CommandException

use of org.netbeans.lib.cvsclient.command.CommandException in project intellij-community by JetBrains.

the class CvsRootConfiguration method testConnection.

public void testConnection(Project project) throws AuthenticationException, IOException {
    final IConnection connection = createSettings().createConnection(new ReadWriteStatistics());
    final ErrorMessagesProcessor errorProcessor = new ErrorMessagesProcessor();
    final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(errorProcessor, CvsExecutionEnvironment.DUMMY_STOPPER, errorProcessor, PostCvsActivity.DEAF, project);
    final CvsResult result = new CvsResultEx();
    try {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final GetModulesListOperation operation = new GetModulesListOperation(createSettings());
            final CvsRootProvider cvsRootProvider = operation.getCvsRootProvider();
            try {
                if (connection instanceof SelfTestingConnection) {
                    ((SelfTestingConnection) connection).test(CvsListenerWithProgress.createOnProgress());
                }
                operation.execute(cvsRootProvider, cvsExecutionEnvironment, connection, DummyProgressViewer.INSTANCE);
            } catch (ValidRequestsExpectedException ex) {
                result.addError(new CvsException(ex, cvsRootProvider.getCvsRootAsString()));
            } catch (CommandException ex) {
                result.addError(new CvsException(ex.getUnderlyingException(), cvsRootProvider.getCvsRootAsString()));
            } catch (ProcessCanceledException ex) {
                result.setIsCanceled();
            } catch (BugLog.BugException e) {
                LOG.error(e);
            } catch (Exception e) {
                result.addError(new CvsException(e, cvsRootProvider.getCvsRootAsString()));
            }
        }, CvsBundle.message("operation.name.test.connection"), true, null);
        if (result.isCanceled())
            throw new ProcessCanceledException();
        if (result.hasErrors()) {
            final VcsException vcsException = result.composeError();
            throw new AuthenticationException(vcsException.getLocalizedMessage(), vcsException.getCause());
        }
        final List<VcsException> errors = errorProcessor.getErrors();
        if (!errors.isEmpty()) {
            final VcsException firstError = errors.get(0);
            throw new AuthenticationException(firstError.getLocalizedMessage(), firstError);
        }
    } finally {
        connection.close();
    }
}
Also used : AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) IConnection(org.netbeans.lib.cvsclient.connection.IConnection) CommandException(org.netbeans.lib.cvsclient.command.CommandException) ValidRequestsExpectedException(org.netbeans.lib.cvsclient.ValidRequestsExpectedException) ErrorMessagesProcessor(com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor) CvsResult(com.intellij.openapi.cvsIntegration.CvsResult) ValidRequestsExpectedException(org.netbeans.lib.cvsclient.ValidRequestsExpectedException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) VcsException(com.intellij.openapi.vcs.VcsException) CommandException(org.netbeans.lib.cvsclient.command.CommandException) IOException(java.io.IOException) BugLog(org.netbeans.lib.cvsclient.util.BugLog) CvsExecutionEnvironment(com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment) GetModulesListOperation(com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation) VcsException(com.intellij.openapi.vcs.VcsException) CvsResultEx(com.intellij.cvsSupport2.CvsResultEx) ReadWriteStatistics(com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 2 with CommandException

use of org.netbeans.lib.cvsclient.command.CommandException in project intellij-community by JetBrains.

the class ExtConnectionCvsSettings method processException.

@Override
public CommandException processException(CommandException t) {
    Exception sourceException = t.getUnderlyingException();
    if (!(sourceException instanceof IOException))
        return t;
    String localizedMessage = t.getLocalizedMessage();
    if (localizedMessage == null || !localizedMessage.startsWith(UNHANDLED_RESPONSE_PREFIX))
        return t;
    String response = localizedMessage.substring(UNHANDLED_RESPONSE_PREFIX.length(), localizedMessage.length() - 1);
    if (StringUtil.startsWithConcatenation(response, USER, "@", HOST)) {
        return new IOCommandException(new IOException(CvsBundle.message("exception.text.ext.server.rejected.access")));
    } else {
        return new IOCommandException(new IOException(CvsBundle.message("exception.text.cannot.establish.external.connection", response)));
    }
}
Also used : IOException(java.io.IOException) CommandException(org.netbeans.lib.cvsclient.command.CommandException) IOException(java.io.IOException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) IOCommandException(org.netbeans.lib.cvsclient.command.IOCommandException) IOCommandException(org.netbeans.lib.cvsclient.command.IOCommandException)

Aggregations

IOException (java.io.IOException)2 CommandException (org.netbeans.lib.cvsclient.command.CommandException)2 AuthenticationException (org.netbeans.lib.cvsclient.connection.AuthenticationException)2 CvsResultEx (com.intellij.cvsSupport2.CvsResultEx)1 CvsExecutionEnvironment (com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment)1 GetModulesListOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation)1 ErrorMessagesProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor)1 CvsException (com.intellij.cvsSupport2.errorHandling.CvsException)1 ReadWriteStatistics (com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics)1 CvsResult (com.intellij.openapi.cvsIntegration.CvsResult)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 VcsException (com.intellij.openapi.vcs.VcsException)1 ValidRequestsExpectedException (org.netbeans.lib.cvsclient.ValidRequestsExpectedException)1 IOCommandException (org.netbeans.lib.cvsclient.command.IOCommandException)1 IConnection (org.netbeans.lib.cvsclient.connection.IConnection)1 BugLog (org.netbeans.lib.cvsclient.util.BugLog)1