From 0712d79e69a1e9990f869ddd018739eb1e586fff Mon Sep 17 00:00:00 2001 From: "vkrus@ibagroup.eu" Date: Tue, 7 Nov 2023 18:05:00 +0100 Subject: [PATCH 1/6] IJMP-1320: fixed both IJMP-1318 and IJMP-1320. Signed-off-by: vkrus@ibagroup.eu --- .../ui/zosmf/ZOSMFConnectionConfigurable.kt | 8 ++++---- .../zowe/service/ZoweConfigServiceImpl.kt | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt index 7306517d5..a99d2a04a 100644 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt @@ -105,7 +105,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti } } - private val zoweConfigStates = mutableListOf() + private val zoweConfigStates = hashMapOf() /** Dialog to edit existing connection. Triggers the dialog and, after the changes, tests the connection and adds the changes */ private fun editConnection() { @@ -114,8 +114,8 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val state = showAndTestConnection(connectionsTableModel!![idx].apply { mode = DialogMode.UPDATE }) - if (state?.zoweConfigPath != null) { - zoweConfigStates.add(state) + state?.zoweConfigPath?.let { + zoweConfigStates[it] = state } if (state != null) { connectionsTableModel?.set(idx, state) @@ -275,7 +275,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val wasModified = isModified applySandbox() applySandbox() - zoweConfigStates.distinct().forEach { updateZoweConfigIfNeeded(it) } + zoweConfigStates.values.forEach { updateZoweConfigIfNeeded(it) } if (wasModified) { panel?.updateUI() } diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 793fe0913..84d484ab3 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -35,7 +35,7 @@ import org.zowe.kotlinsdk.zowe.config.ZoweConfig import org.zowe.kotlinsdk.zowe.config.parseConfigJson import java.nio.file.Path import java.util.* -import kotlin.streams.toList +import java.util.stream.Collectors val ZOWE_PROJECT_PREFIX = "zowe-" @@ -82,7 +82,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService private fun findExistingConnection(): ConnectionConfig? { val zoweConnectionList = configCrudable.find { it.name == zoweConnectionName - }.toList() + }.collect(Collectors.toList()) return if (zoweConnectionList.isEmpty()) null else zoweConnectionList[0] } @@ -177,6 +177,16 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) + fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { + if (connectionA.name != connectionB.name) return false + if (connectionA.url != connectionB.url) return false + if (connectionA.isAllowSelfSigned != connectionB.isAllowSelfSigned) return false + if (connectionA.zVersion != connectionB.zVersion) return false + if (connectionA.zoweConfigPath != connectionB.zoweConfigPath) return false + + return true + } + /** * @see ZoweConfigService.getZoweConfigState */ @@ -191,7 +201,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService val zoweUsername = zoweConfig.user ?: return ZoweConfigState.ERROR val zowePassword = zoweConfig.password ?: return ZoweConfigState.ERROR - return if (existingConnection == newConnection && + return if (compareConnections(existingConnection, newConnection) && getUsername(newConnection) == zoweUsername && getPassword(newConnection) == zowePassword ) { @@ -202,3 +212,4 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService } } + From 06a7d6b611c1a41abd88634b71cb97f24e271471 Mon Sep 17 00:00:00 2001 From: "vkrus@ibagroup.eu" Date: Tue, 7 Nov 2023 18:33:34 +0100 Subject: [PATCH 2/6] IJMP-1320: documentation added. --- .../org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 84d484ab3..92d4b7e7c 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -177,6 +177,12 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) + /** + * Compares only significant for real connection fields between 2 connections. + * @param connectionA first connection instance to compare. + * @param connectionB second connection instance to compare. + * @return true if all significant fields fo connections are equal and false otherwise. + */ fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { if (connectionA.name != connectionB.name) return false if (connectionA.url != connectionB.url) return false From 907ed7e24bdd38101efcd1c01c7b0cad164f9692 Mon Sep 17 00:00:00 2001 From: Krus_V Date: Thu, 9 Nov 2023 23:53:32 +0100 Subject: [PATCH 3/6] IJMP-1318: comparison of zVersion and owner temporary removed from equals method. --- .../explorer/config/connect/ConnectionConfig.kt | 5 +++-- .../ui/zosmf/ZOSMFConnectionConfigurable.kt | 6 +++++- .../zowe/service/ZoweConfigServiceImpl.kt | 17 +---------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt index ded5e51f4..29df4dfcd 100755 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt @@ -65,9 +65,10 @@ class ConnectionConfig : ConnectionConfigBase { if (name != other.name) return false if (url != other.url) return false if (isAllowSelfSigned != other.isAllowSelfSigned) return false - if (zVersion != other.zVersion) return false if (zoweConfigPath != other.zoweConfigPath) return false - if (owner != other.owner) return false + // TODO: uncomment next 2 lines when the task https://jira.ibagroup.eu/browse/IJMP-1412 will be completed. + // if (zVersion != other.zVersion) return false + // if (owner != other.owner) return false return true } diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt index a99d2a04a..4252070fc 100644 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt @@ -275,7 +275,11 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val wasModified = isModified applySandbox() applySandbox() - zoweConfigStates.values.forEach { updateZoweConfigIfNeeded(it) } + zoweConfigStates.values.forEach { + if (isModified) { + updateZoweConfigIfNeeded(it) + } + } if (wasModified) { panel?.updateUI() } diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 92d4b7e7c..1cb938a03 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -177,21 +177,6 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) - /** - * Compares only significant for real connection fields between 2 connections. - * @param connectionA first connection instance to compare. - * @param connectionB second connection instance to compare. - * @return true if all significant fields fo connections are equal and false otherwise. - */ - fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { - if (connectionA.name != connectionB.name) return false - if (connectionA.url != connectionB.url) return false - if (connectionA.isAllowSelfSigned != connectionB.isAllowSelfSigned) return false - if (connectionA.zVersion != connectionB.zVersion) return false - if (connectionA.zoweConfigPath != connectionB.zoweConfigPath) return false - - return true - } /** * @see ZoweConfigService.getZoweConfigState @@ -207,7 +192,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService val zoweUsername = zoweConfig.user ?: return ZoweConfigState.ERROR val zowePassword = zoweConfig.password ?: return ZoweConfigState.ERROR - return if (compareConnections(existingConnection, newConnection) && + return if (existingConnection == newConnection && getUsername(newConnection) == zoweUsername && getPassword(newConnection) == zowePassword ) { From e28e086e13508107dbdb0ca7dd6c2c8ffe8f8a6c Mon Sep 17 00:00:00 2001 From: "vkrus@ibagroup.eu" Date: Tue, 7 Nov 2023 18:05:00 +0100 Subject: [PATCH 4/6] IJMP-1320: fixed both IJMP-1318 and IJMP-1320. Signed-off-by: vkrus@ibagroup.eu Signed-off-by: Krus_V --- .../ui/zosmf/ZOSMFConnectionConfigurable.kt | 8 ++++---- .../zowe/service/ZoweConfigServiceImpl.kt | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt index 7306517d5..a99d2a04a 100644 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt @@ -105,7 +105,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti } } - private val zoweConfigStates = mutableListOf() + private val zoweConfigStates = hashMapOf() /** Dialog to edit existing connection. Triggers the dialog and, after the changes, tests the connection and adds the changes */ private fun editConnection() { @@ -114,8 +114,8 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val state = showAndTestConnection(connectionsTableModel!![idx].apply { mode = DialogMode.UPDATE }) - if (state?.zoweConfigPath != null) { - zoweConfigStates.add(state) + state?.zoweConfigPath?.let { + zoweConfigStates[it] = state } if (state != null) { connectionsTableModel?.set(idx, state) @@ -275,7 +275,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val wasModified = isModified applySandbox() applySandbox() - zoweConfigStates.distinct().forEach { updateZoweConfigIfNeeded(it) } + zoweConfigStates.values.forEach { updateZoweConfigIfNeeded(it) } if (wasModified) { panel?.updateUI() } diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 793fe0913..84d484ab3 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -35,7 +35,7 @@ import org.zowe.kotlinsdk.zowe.config.ZoweConfig import org.zowe.kotlinsdk.zowe.config.parseConfigJson import java.nio.file.Path import java.util.* -import kotlin.streams.toList +import java.util.stream.Collectors val ZOWE_PROJECT_PREFIX = "zowe-" @@ -82,7 +82,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService private fun findExistingConnection(): ConnectionConfig? { val zoweConnectionList = configCrudable.find { it.name == zoweConnectionName - }.toList() + }.collect(Collectors.toList()) return if (zoweConnectionList.isEmpty()) null else zoweConnectionList[0] } @@ -177,6 +177,16 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) + fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { + if (connectionA.name != connectionB.name) return false + if (connectionA.url != connectionB.url) return false + if (connectionA.isAllowSelfSigned != connectionB.isAllowSelfSigned) return false + if (connectionA.zVersion != connectionB.zVersion) return false + if (connectionA.zoweConfigPath != connectionB.zoweConfigPath) return false + + return true + } + /** * @see ZoweConfigService.getZoweConfigState */ @@ -191,7 +201,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService val zoweUsername = zoweConfig.user ?: return ZoweConfigState.ERROR val zowePassword = zoweConfig.password ?: return ZoweConfigState.ERROR - return if (existingConnection == newConnection && + return if (compareConnections(existingConnection, newConnection) && getUsername(newConnection) == zoweUsername && getPassword(newConnection) == zowePassword ) { @@ -202,3 +212,4 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService } } + From 843d7f8bdba2d1b32e8c96d5d6af9c94cfb2047c Mon Sep 17 00:00:00 2001 From: "vkrus@ibagroup.eu" Date: Tue, 7 Nov 2023 18:33:34 +0100 Subject: [PATCH 5/6] IJMP-1320: documentation added. Signed-off-by: Krus_V --- .../org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 84d484ab3..92d4b7e7c 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -177,6 +177,12 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) + /** + * Compares only significant for real connection fields between 2 connections. + * @param connectionA first connection instance to compare. + * @param connectionB second connection instance to compare. + * @return true if all significant fields fo connections are equal and false otherwise. + */ fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { if (connectionA.name != connectionB.name) return false if (connectionA.url != connectionB.url) return false From 05a3cb481e07f3d5c6635b174b8aff3343840255 Mon Sep 17 00:00:00 2001 From: Krus_V Date: Thu, 9 Nov 2023 23:53:32 +0100 Subject: [PATCH 6/6] IJMP-1318: comparison of zVersion and owner temporary removed from equals method. Signed-off-by: Krus_V --- .../explorer/config/connect/ConnectionConfig.kt | 5 +++-- .../ui/zosmf/ZOSMFConnectionConfigurable.kt | 6 +++++- .../zowe/service/ZoweConfigServiceImpl.kt | 17 +---------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt index ded5e51f4..29df4dfcd 100755 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ConnectionConfig.kt @@ -65,9 +65,10 @@ class ConnectionConfig : ConnectionConfigBase { if (name != other.name) return false if (url != other.url) return false if (isAllowSelfSigned != other.isAllowSelfSigned) return false - if (zVersion != other.zVersion) return false if (zoweConfigPath != other.zoweConfigPath) return false - if (owner != other.owner) return false + // TODO: uncomment next 2 lines when the task https://jira.ibagroup.eu/browse/IJMP-1412 will be completed. + // if (zVersion != other.zVersion) return false + // if (owner != other.owner) return false return true } diff --git a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt index a99d2a04a..4252070fc 100644 --- a/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt +++ b/src/main/kotlin/org/zowe/explorer/config/connect/ui/zosmf/ZOSMFConnectionConfigurable.kt @@ -275,7 +275,11 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti val wasModified = isModified applySandbox() applySandbox() - zoweConfigStates.values.forEach { updateZoweConfigIfNeeded(it) } + zoweConfigStates.values.forEach { + if (isModified) { + updateZoweConfigIfNeeded(it) + } + } if (wasModified) { panel?.updateUI() } diff --git a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt index 92d4b7e7c..1cb938a03 100644 --- a/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt +++ b/src/main/kotlin/org/zowe/explorer/zowe/service/ZoweConfigServiceImpl.kt @@ -177,21 +177,6 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService fun ZoweConfig.toConnectionConfig(zVersion: ZVersion = ZVersion.ZOS_2_1): ConnectionConfig = toConnectionConfig(getOrCreateUuid(), zVersion) - /** - * Compares only significant for real connection fields between 2 connections. - * @param connectionA first connection instance to compare. - * @param connectionB second connection instance to compare. - * @return true if all significant fields fo connections are equal and false otherwise. - */ - fun compareConnections(connectionA: ConnectionConfig, connectionB: ConnectionConfig): Boolean { - if (connectionA.name != connectionB.name) return false - if (connectionA.url != connectionB.url) return false - if (connectionA.isAllowSelfSigned != connectionB.isAllowSelfSigned) return false - if (connectionA.zVersion != connectionB.zVersion) return false - if (connectionA.zoweConfigPath != connectionB.zoweConfigPath) return false - - return true - } /** * @see ZoweConfigService.getZoweConfigState @@ -207,7 +192,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService val zoweUsername = zoweConfig.user ?: return ZoweConfigState.ERROR val zowePassword = zoweConfig.password ?: return ZoweConfigState.ERROR - return if (compareConnections(existingConnection, newConnection) && + return if (existingConnection == newConnection && getUsername(newConnection) == zoweUsername && getPassword(newConnection) == zowePassword ) {