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();
}
}
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)));
}
}
Aggregations