Skip to content

Commit

Permalink
IJMP-1320: fixed both IJMP-1318 and IJMP-1320.
Browse files Browse the repository at this point in the history
  • Loading branch information
VKrus committed Nov 7, 2023
1 parent 1afc8c0 commit 0712d79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
}
}

private val zoweConfigStates = mutableListOf<ConnectionDialogState>()
private val zoweConfigStates = hashMapOf<String, ConnectionDialogState>()

/** Dialog to edit existing connection. Triggers the dialog and, after the changes, tests the connection and adds the changes */
private fun editConnection() {
Expand All @@ -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)
Expand Down Expand Up @@ -275,7 +275,7 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
val wasModified = isModified
applySandbox<Credentials>()
applySandbox<ConnectionConfig>()
zoweConfigStates.distinct().forEach { updateZoweConfigIfNeeded(it) }
zoweConfigStates.values.forEach { updateZoweConfigIfNeeded(it) }
if (wasModified) {
panel?.updateUI()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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-"

Expand Down Expand Up @@ -82,7 +82,7 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
private fun findExistingConnection(): ConnectionConfig? {
val zoweConnectionList = configCrudable.find<ConnectionConfig> {
it.name == zoweConnectionName
}.toList()
}.collect(Collectors.toList())
return if (zoweConnectionList.isEmpty()) null else zoweConnectionList[0]
}

Expand Down Expand Up @@ -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
*/
Expand All @@ -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
) {
Expand All @@ -202,3 +212,4 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
}

}

0 comments on commit 0712d79

Please sign in to comment.