Search in sources :

Example 1 with ErrorProcessor

use of com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor 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 ErrorProcessor

use of com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor in project intellij-community by JetBrains.

the class StickyHeadGetter method getBranchHeadRevision.

@Nullable
protected String getBranchHeadRevision(final VirtualFile parent, final String name, final Convertor<CvsRevisionNumber, Boolean> chooser) {
    final LocalPathIndifferentLogOperation operation = new LocalPathIndifferentLogOperation(new File(parent.getPath(), name));
    final Ref<Boolean> logSuccess = new Ref<>(Boolean.TRUE);
    final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(new CvsMessagesAdapter(), CvsExecutionEnvironment.DUMMY_STOPPER, new ErrorProcessor() {

        public void addError(VcsException ex) {
            logSuccess.set(Boolean.FALSE);
        }

        public List<VcsException> getErrors() {
            return null;
        }
    }, PostCvsActivity.DEAF, myProject);
    try {
        // should already be logged in
        //operation.login(context);
        operation.execute(cvsExecutionEnvironment, false);
    } catch (VcsException | CommandAbortedException e) {
    //
    }
    if (Boolean.TRUE.equals(logSuccess.get())) {
        return extractRevision(operation, chooser);
    }
    return null;
}
Also used : ErrorProcessor(com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor) Ref(com.intellij.openapi.util.Ref) LocalPathIndifferentLogOperation(com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation) CvsExecutionEnvironment(com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment) CommandAbortedException(org.netbeans.lib.cvsclient.command.CommandAbortedException) VcsException(com.intellij.openapi.vcs.VcsException) CvsMessagesAdapter(com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter) List(java.util.List) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CvsExecutionEnvironment (com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment)2 VcsException (com.intellij.openapi.vcs.VcsException)2 CvsResultEx (com.intellij.cvsSupport2.CvsResultEx)1 GetModulesListOperation (com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation)1 ErrorMessagesProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor)1 ErrorProcessor (com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor)1 LocalPathIndifferentLogOperation (com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation)1 CvsMessagesAdapter (com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter)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 Ref (com.intellij.openapi.util.Ref)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 IOException (java.io.IOException)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1 ValidRequestsExpectedException (org.netbeans.lib.cvsclient.ValidRequestsExpectedException)1 CommandAbortedException (org.netbeans.lib.cvsclient.command.CommandAbortedException)1