use of org.netbeans.lib.cvsclient.connection.IConnection 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.connection.IConnection in project intellij-community by JetBrains.
the class CvsCommandOperation method execute.
protected void execute(CvsRootProvider root, final CvsExecutionEnvironment executionEnvironment, ReadWriteStatistics statistics, IProgressViewer progressViewer) throws CommandException, VcsException {
final IConnection connection = root.createConnection(statistics);
execute(root, executionEnvironment, connection, progressViewer);
}
use of org.netbeans.lib.cvsclient.connection.IConnection in project intellij-community by JetBrains.
the class ClientEnvironment method createEnvironmentForDirectory.
public IClientEnvironment createEnvironmentForDirectory(DirectoryObject directory) {
IConnection connection = cvsRootProvider.getConnection(directory, cvsFileSystem);
if (connection == null)
return null;
CvsRoot cvsRoot = cvsRootProvider.getCvsRoot(directory, cvsFileSystem);
if (cvsRoot == null)
return null;
return new ClientEnvironment(connection, cvsFileSystem.getLocalFileSystem().getFile(directory), cvsFileSystem.getAdminFileSystem().getFile(directory), cvsRoot, getLocalFileReader(), getLocalFileWriter(), getAdminReader(), getAdminWriter(), getIgnoreFileFilter(), getFileReadOnlyHandler(), getCharset(), cvsRootProvider);
}
use of org.netbeans.lib.cvsclient.connection.IConnection in project intellij-community by JetBrains.
the class SshSharedConnection method getTicket.
@Nullable
public IConnection getTicket() {
final long oldMoment = System.currentTimeMillis() - EMPTY_CONNECTION_ALLOWED_FOR;
IConnection result = null;
synchronized (myLock) {
SshLogger.debug("shared connection: queue size " + myQueue.size());
for (Iterator<Cell> iterator = myQueue.iterator(); iterator.hasNext(); ) {
final Cell cell = iterator.next();
if (result == null) {
result = cell.allocate();
} else {
// check whether to remove
if (cell.isEmptyAndOlderThen(oldMoment)) {
SshLogger.debug("empty and older");
cell.closeSelf();
iterator.remove();
}
}
}
if (result != null)
return result;
SshLogger.debug("new cell");
final Cell newCell = new Cell(myConnectionFactory, myRepository);
myQueue.add(newCell);
return newCell.allocate();
}
}
use of org.netbeans.lib.cvsclient.connection.IConnection in project intellij-community by JetBrains.
the class CvsConnectionSettings method createConnection.
public IConnection createConnection(ReadWriteStatistics statistics) {
CvsListenerWithProgress cvsCommandStopper = CvsListenerWithProgress.createOnProgress();
IConnection originalConnection = createOriginalConnection(cvsCommandStopper, myCvsRootConfiguration);
if (originalConnection instanceof SelfTestingConnection) {
return new SelfTestingConnectionWrapper(originalConnection, statistics, cvsCommandStopper);
} else {
return new ConnectionWrapper(originalConnection, statistics, cvsCommandStopper);
}
}
Aggregations