@Override public String getRawPort() { return serverName.getFullPort(); }
private void setServerName(@Nullable P4ServerName port) { setTrimmed(PORT_KEY, port == null ? null : port.getFullPort()); }
public static void createActionState(@NotNull ClientServerRef ref, @NotNull Map<String, Object> data) { data.put("csr:port", ref.getServerName().getFullPort()); data.put("csr:clientname", ref.getClientName()); } }
@NotNull public State getState() { State ret = new State(); ret.serverName = serverName.getFullPort(); ret.jobSpec = P4JobSpecStore.getStateNullable(jobSpec); ret.userClients = new HashMap<>(); for (Map.Entry<String, List<P4WorkspaceSummary>> entry : userClients.entrySet()) { List<P4WorkspaceSummaryStore.State> states = new ArrayList<>(entry.getValue().size()); for (P4WorkspaceSummary summary : entry.getValue()) { states.add(P4WorkspaceSummaryStore.getState(summary)); } ret.userClients.put(entry.getKey(), states); } return ret; } }
@NotNull public static State getState(@NotNull ClientServerRef ref) { State ret = new State(); ret.serverPort = ref.getServerName().getFullPort(); ret.clientName = ref.getClientName(); return ret; }
@NotNull protected CredentialAttributes getCredentialAttributes(@NotNull ServerConfig config, boolean inMemory) { return new CredentialAttributes( "p4ic4idea:" + config.getServerName().getFullPort(), config.getUsername(), null, inMemory); } }
@NotNull PrimitiveMap putClientServerRef(@NotNull String key, @Nullable ClientServerRef ref) { if (ref == null) { return this; } return putString(key + "__serverPort", ref.getServerName().getFullPort()) .putString(key + "__clientName", ref.getClientName()); }
public static boolean isValidServerConfig(@Nullable ConfigPart part) { if (part == null || part.hasError()) { return false; } // This should be included with the above config problems. if (part.getServerName() == null || isBlank(part.getServerName().getFullPort())) { return false; } if (isBlank(part.getUsername())) { return false; } return true; }
@NotNull static String getServerIdForDataPart(@NotNull ConfigPart part) { StringBuilder sb = new StringBuilder(); if (part.hasServerNameSet() && part.getServerName() != null) { sb.append(part.getServerName().getFullPort()); } else { sb.append((String) null); } // Note: does not include password information. sb.append(SEP) .append(part.hasUsernameSet() ? part.getUsername() : null) .append(SEP) .append(part.hasAuthTicketFileSet() ? part.getAuthTicketFile() : null) .append(SEP) .append(part.hasTrustTicketFileSet() ? part.getTrustTicketFile() : null) .append(SEP) .append(part.hasServerFingerprintSet() ? part.getServerFingerprint() : null); // These may be common enough that we want to save memory by interning the strings. return sb.toString().intern(); }
dataOutput.writeUTF(ref.getServerName().getFullPort());
@Test void forPort_justPort() { P4ServerName name = P4ServerName.forPort("1667"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("localhost:1667")); assertThat("display", name.getDisplayName(), is("localhost:1667")); assertThat("url", name.getUrl(), is("p4jrpcnts://localhost:1667")); assertThat("full port", name.getFullPort(), is("localhost:1667")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_simpleProtocolPort() { P4ServerName name = P4ServerName.forPort("tcp:host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
@Test void forPort_ssl() { P4ServerName name = P4ServerName.forPort("ssl://host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(true)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTSSSL)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("ssl:host:1234")); assertThat("url", name.getUrl(), is("p4jrpcntsssl://host:1234")); assertThat("full port", name.getFullPort(), is("ssl://host:1234")); assertThat("protocol name", name.getProtocolName(), is("ssl")); }
@Test void forPort_hostPort() { P4ServerName name = P4ServerName.forPort("host:1234"); assertThat("null", name, notNullValue()); assertThat("secure", name.isSecure(), is(false)); assertThat("connection type", name.getServerProtocol(), is(IServerAddress.Protocol.P4JRPCNTS)); assertThat("port", name.getServerPort(), is("host:1234")); assertThat("display", name.getDisplayName(), is("host:1234")); assertThat("url", name.getUrl(), is("p4jrpcnts://host:1234")); assertThat("full port", name.getFullPort(), is("host:1234")); assertThat("protocol name", name.getProtocolName(), is("java")); }
changelist.changelistId.ref = new ClientServerRefStore.State(); changelist.changelistId.ref.clientName = root.getClientConfig().getClientname(); changelist.changelistId.ref.serverPort = root.getServerConfig().getServerName().getFullPort(); changelist.type = P4ChangelistType.PUBLIC; changelist.deleted = false;
public void linkP4ChangelistToIdeChangelist(ClientConfigRoot root, P4ChangelistId p4cl, LocalChangeList ide) { CacheComponent cc = CacheComponent.getInstance(idea.getMockProject()); // Use the state object to avoid all the work to populate the cache. ProjectCacheStore.State state = cc.getState(); assertNotNull(state); IdeChangelistCacheStore.LinkedChangelistState linkedState = new IdeChangelistCacheStore.LinkedChangelistState(); linkedState.changelistId = new P4ChangelistIdStore.State(); linkedState.changelistId.id = p4cl.getChangelistId(); linkedState.changelistId.ref = new ClientServerRefStore.State(); linkedState.changelistId.ref.clientName = root.getClientConfig().getClientname(); linkedState.changelistId.ref.serverPort = root.getServerConfig().getServerName().getFullPort(); linkedState.linkedLocalChangeId = ide.getId(); state.changelistState.linkedChangelistMap.add(linkedState); cc.loadState(state); }
@Test void isValid() { assertFalse(ServerConfig.isValidServerConfig(null)); MockConfigPart part = new MockConfigPart(); part.withConfigProblems(createError()); assertFalse(ServerConfig.isValidServerConfig(part)); part.withConfigProblems(); assertFalse(ServerConfig.isValidServerConfig(part)); P4ServerName mockName = mock(P4ServerName.class); when(mockName.getFullPort()).thenReturn(""); part.withP4ServerName(mockName); assertFalse(ServerConfig.isValidServerConfig(part)); part.withConfigProblems(createWarning()) .withServerName("my-server"); assertFalse(ServerConfig.isValidServerConfig(part)); part.withUsername(""); assertFalse(ServerConfig.isValidServerConfig(part)); part.withUsername("abc"); assertTrue(ServerConfig.isValidServerConfig(part)); }