ConnectionInfo(@NotNull ServerConfig config) { this.clientConfig = null; this.serverConfig = config; this.serverName = config.getServerName(); }
@NotNull public P4ServerName getName() { return config.getServerName(); }
private boolean shouldHandleProblem(ServerConfig config, FailureType type) { // The idea here is to prevent the user from being bombarded with duplicate requests. FailureType previous; synchronized (lastFailureType) { previous = lastFailureType.get(config.getServerName()); lastFailureType.put(config.getServerName(), type); } return (previous != type); }
private void forgetLoginProblem(ServerConfig config) { synchronized (lastFailureType) { lastFailureType.remove(config.getServerName()); } }
private Collection<ServerConnectionState> getStatesFor(P4ServerName name) { List<ServerConnectionState> ret = new ArrayList<>(); synchronized (stateCache) { for (ServerConnectionState state : stateCache.values()) { if (state.config.getServerName().equals(name)) { ret.add(state); } } } return ret; }
@Override public String toString() { if (clientName != null) { return serverConfig.getServerName().getDisplayName() + "@" + clientName; } return serverConfig.getServerName().getDisplayName(); }
public static String getSourceId(ServerConfig config) { return getSourceId(config.getServerName()); }
ConnectionInfo(@NotNull ClientConfig clientConfig) { this.clientConfig = clientConfig; serverConfig = clientConfig.getServerConfig(); serverName = clientConfig.getServerConfig().getServerName(); }
@NotNull protected CredentialAttributes getCredentialAttributes(@NotNull ServerConfig config, boolean inMemory) { return new CredentialAttributes( "p4ic4idea:" + config.getServerName().getFullPort(), config.getUsername(), null, inMemory); } }
private Stream<ServerStatusImpl> getServersFor(@NotNull P4ServerName name) { return getAllServers() .filter((sc) -> name.equals(sc.getServerConfig().getServerName())); }
@Override public void serverConnected(@NotNull ServerConnectedMessage.ServerConnectedEvent e) { // This can be spammy. //simpleInfo("Connected to " + serverConfig.getServerName() + // (loggedIn ? " and logged in." : ", but not logged in."), // "Perforce Server Connected"); if (LOG.isDebugEnabled()) { LOG.debug("Connected to " + e.getServerConfig().getServerName() + ". Logged in? " + e.isLoggedIn()); } } });
/** * * @return a changelist ID with a client name used to submit the changelist. */ public P4ChangelistId getChangelistId() { ClientServerRef ref = new ClientServerRef(config.getServerName(), data.getClientName()); return new P4ChangelistIdImpl(data.getChangelistId(), ref); }
@Override protected void onServerConnected(@NotNull ServerConnectedMessage.ServerConnectedEvent e) { // Note: does not check disposed state. getServersFor(e.getServerConfig().getServerName()).forEach((state) -> { state.setServerHostProblem(false); // If the connectivity and login all lines up, then the login works. if (e.isLoggedIn() && e.getServerConfig().getServerId().equals(state.getServerConfig().getServerId())) { state.setServerLoginProblem(false); } }); }
@NotNull @Override public Collection<P4LocalChangelist> getCachedOpenedChangelists(@NotNull ClientConfig config) { return openChangelists.computeIfAbsent( new ClientServerRef(config.getServerConfig().getServerName(), config.getClientname()), k -> new ArrayList<>() ); }
@NotNull @Override protected QueryAnswer<GetJobSpecResult> getJobSpec(ServerConfig config, GetJobSpecQuery query) { return onlineQuery(config, () -> server.getJobSpec(config) .whenCompleted((result) -> JobSpecCacheMessage.sendEvent(new JobSpecCacheMessage.Event( config.getServerName(), result.getJobSpec())) ), () -> new DoneQueryAnswer<>(new GetJobSpecResult(config, queryCache.getCachedJobSpec(config.getServerName()))) ); }
@Override public boolean isIn(@NotNull ServerConfig serverConfig) { return serverConfig.getServerName().equals(csRef.getServerName()); }
/** * Remove the password associated with the configuration. * * @param config server configuration for the password. */ public final void remove(@NotNull ServerConfig config) { if (LOG.isDebugEnabled()) { LOG.debug("Removing password for config " + config.getServerName()); } CredentialAttributes attr = getCredentialAttributes(config, false); PasswordSafe.getInstance().set(attr, new Credentials(config.getUsername(), (String) null)); }
@Override public void couldNotWrite(@NotNull ServerErrorEvent.ServerConfigErrorEvent<FileSaveException> event) { simpleError( P4Bundle.message("user-error.could-not-write.message", event.getConfig().getServerName(), event.getError().getLocalizedMessage()), P4Bundle.message("user-error.could-not-write.title")); LOG.warn(event.getError()); }
private IOptionsServer setupServer(@NotNull ServerConfig config) throws P4JavaException { Server s = setupServer(config.getServerName()); if (serverConfig != null) { s = serverConfig.configure(config, s); } when(s.getUserName()).thenReturn(config.getUsername()); return s; }
private CreateJobResult createJob(IOptionsServer server, ServerConfig cfg, CreateJobAction action) throws ConnectionException, AccessException, RequestException { P4JobImpl job = new P4JobImpl(cmd.createJob(server, action.getFields())); JobCacheMessage.sendEvent(new JobCacheMessage.Event(cfg.getServerName(), job, JobCacheMessage.JobUpdateAction.JOB_CREATED)); return new CreateJobResult(cfg, job); }