ConnectionInfo(@NotNull ClientConfig clientConfig) { this.clientConfig = clientConfig; serverConfig = clientConfig.getServerConfig(); serverName = clientConfig.getServerConfig().getServerName(); }
private <R> QueryAnswer<R> onlineQuery(@NotNull ClientConfig clientConfig, Exec<QueryAnswer<R>> serverExec, Exec<QueryAnswer<R>> cacheExec) { return onlineQuery(clientConfig.getServerConfig(), serverExec, cacheExec); }
private <R> ActionAnswer<R> onlineExec(@NotNull ClientConfig clientConfig, Exec<ActionAnswer<R>> serverExec, Exec<ActionAnswer<R>> cacheExec) { return onlineExec(clientConfig.getServerConfig(), serverExec, cacheExec); }
public boolean isIn(@NotNull ServerConfig config) { return getServerConfig().getServerId().equals(config.getServerId()); }
private void deregisterServerForConfig(ClientConfig config) { synchronized (registeredServers) { ServerRef ref = registeredServers.get(config.getServerConfig().getServerId()); if (ref != null) { if (ref.removeClientConfig()) { registeredServers.remove(config.getServerConfig().getServerId()); ref.state.dispose(); } } } }
@NotNull @Override public ServerConfig getServerConfig() { return config.getServerConfig(); }
private ServerConfig getServerConfigForChangelistId(ProjectConfigRegistry registry, P4ChangelistId p4cl) { ClientConfig clientConfig = registry.getRegisteredClientConfigState(p4cl.getClientServerRef()); if (clientConfig != null) { return clientConfig.getServerConfig(); } return null; }
@Override public void projectOpened(Project project) { MessageBusClient.ProjectClient projectMbClient = MessageBusClient.forProject(project, InvalidPasswordMonitorComponent.this); ClientConfigAddedMessage.addListener(projectMbClient, this, e -> forgetLoginProblem(e.getClientConfig().getServerConfig())); ClientConfigRemovedMessage.addListener(projectMbClient, this, event -> forgetLoginProblem(event.getClientConfig().getServerConfig())); }
/** * Should only be called by {@link net.groboclown.p4.server.api.ProjectConfigRegistry}. Doesn't conform to * the "send(Project)" standard API, because it can trigger 2 events. * * @param project project to send the message on. */ public static void sendClientConfigurationAdded(@NotNull Project project, @Nullable VirtualFile root, @NotNull ClientConfig clientConfig) { ServerListener serverListener = ApplicationMessage.getListener(SERVER_TOPIC); if (serverListener != null) { serverListener.serverConfigAdded(new ServerConfigAddedEvent(clientConfig.getServerConfig())); } getListener(project, TOPIC, DEFAULT_LISTENER).clientConfigurationAdded(new ClientConfigAddedEvent( root, clientConfig)); }
@NotNull public static Map<String, String> toProperties(@NotNull ClientConfig config, @Nullable String valueIfUnset, @Nullable String valueIfPasswordStored, @Nullable String valueIfPasswordNotStored) { Map<String, String> props = toProperties(config.getServerConfig(), valueIfUnset, valueIfPasswordStored, valueIfPasswordNotStored); props.put(PerforceEnvironment.P4CHARSET, config.getDefaultCharSet() == null ? valueIfUnset : config.getDefaultCharSet()); props.put(PerforceEnvironment.P4IGNORE, config.getIgnoreFileName() == null ? valueIfUnset : config.getIgnoreFileName()); props.put(PerforceEnvironment.P4CLIENT, config.getClientname() == null ? valueIfUnset : config.getClientname()); props.put(PerforceEnvironment.P4HOST, config.getClientHostName() == null ? valueIfUnset : config.getClientHostName()); return props; }
private P4CommandRunner.QueryAnswer<ListFileHistoryResult> getHistory( @NotNull ClientConfigRoot root, FilePath file, int revisionCount) { return P4ServerComponent .query(project, root.getClientConfig().getServerConfig(), new ListFileHistoryQuery( root.getClientConfig().getClientServerRef(), file, revisionCount)); }
private ClientConfigRootImpl createClientConfigState(@NotNull ClientConfig inpConfig, @NotNull VirtualFile vcsRootDir) { ServerStatusImpl serverState; synchronized (registeredServers) { ServerRef ref = registeredServers.get(inpConfig.getServerConfig().getServerId()); if (ref == null || ref.state.isDisposed()) { ref = new ServerRef(createServerConfigState(inpConfig.getServerConfig())); registeredServers.put(inpConfig.getServerConfig().getServerId(), ref); } ref.addClientConfigRef(); serverState = ref.state; } ClientConfig config; synchronized (registeredClients) { ClientRef ref = registeredClients.get(inpConfig.getClientServerRef()); if (ref == null || ref.isDisposed()) { ref = new ClientRef(inpConfig); registeredClients.put(inpConfig.getClientServerRef(), ref); } ref.addClientConfigRootRef(); config = ref.state; } return new ClientConfigRootImpl(config, serverState, vcsRootDir); }
@NotNull @Override public Collection<P4LocalChangelist> getCachedOpenedChangelists(@NotNull ClientConfig config) { return openChangelists.computeIfAbsent( new ClientServerRef(config.getServerConfig().getServerName(), config.getClientname()), k -> new ArrayList<>() ); }
@Nullable @Override public String getContent() throws VcsException { ClientConfig config = clientConfigFactory.get(); if (getLoader() == null || config == null || config.getClientname() == null) { return null; } return ContentRevisionUtil.getContent(config.getServerConfig(), config.getClientname(), getLoader(), getFile(), getIntRevisionNumber().getValue(), getCharset()); }
public MockP4RemoteChangelist withConfig(ClientConfig cc) { csRef = cc.getClientServerRef(); //clientname = cc.getClientname(); //serverName = csRef.getServerName(); username = cc.getServerConfig().getUsername(); summary = null; return this; }
private IClient setupClient(@NotNull ClientConfig config) throws P4JavaException { IOptionsServer s = setupServer(config.getServerConfig()); IClient c = client; if (clientConfig != null) { c = clientConfig.configure(config, c); } when(c.getServer()).thenReturn(s); when(c.getName()).thenReturn(config.getClientname()); return c; }
@Nullable @Override public String getContent() throws VcsException { if (getLoader() == null || clientConfig.getClientname() == null) { return null; } return ContentRevisionUtil.getContent(clientConfig.getServerConfig(), clientConfig.getClientname(), getLoader(), getFile(), getIntRevisionNumber().getValue(), getCharset()); } }
@Nullable @Override public String getContent() throws VcsException { try { if (LOG.isDebugEnabled()) { LOG.debug("Loading file content for " + local + " rev " + iRev); } return loader.loadStringContentForLocal( root.getClientConfig().getServerConfig(), clientName, local, iRev.getValue()); } catch (IOException e) { LOG.info("Problem loading file content for " + local + " rev " + iRev, e); throw new VcsException(e); } }
public static Answer<SimpleConnectionManager> setupClient(final ClientConfig config, final TemporaryFolder tmpDir, File clientRoot, P4RequestErrorHandler errorHandler) { if (!clientRoot.isDirectory()) { if (!clientRoot.mkdirs()) { fail("Could not create " + clientRoot); } } return withConnection(config.getServerConfig(), tmpDir, errorHandler) .mapAsync(mgr -> mgr.withConnection(config.getServerConfig(), server -> { CoreFactory.createClient(server, config.getClientname(), "new client from CoreFactory", clientRoot.getAbsolutePath(), new String[]{"//depot/... //" + config.getClientname() + "/..."}, true); return mgr; })); }
@Nullable @Override public VcsHistorySession createSessionFor(FilePath filePath) throws VcsException { ClientConfigRoot root = getRootFor(filePath); if (root == null) { LOG.info("Not in P4 project: " + filePath); return null; } try { List<VcsFileRevision> revisions = P4ServerComponent .query(project, root.getClientConfig().getServerConfig(), new ListFileHistoryQuery(root.getClientConfig().getClientServerRef(), filePath, -1)) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project), TimeUnit.MILLISECONDS) .getRevisions(formatter, loader); return createAppendableSession(filePath, revisions, null); } catch (InterruptedException e) { throw new VcsInterruptedException(e); } }