Skip to content

Commit

Permalink
IJMP-1814 Added parsing all zosmf profiles
Browse files Browse the repository at this point in the history
Signed-off-by: Katsiaryna Tsytsenia <[email protected]>
  • Loading branch information
Katsiaryna Tsytsenia authored and Katsiaryna Tsytsenia committed Jul 29, 2024
1 parent 467e004 commit 805e9b6
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 95 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ val junitVersion = "5.10.2"
val mockkVersion = "1.13.10"
val ibmMqVersion = "9.3.5.0"
val jGraphTVersion = "1.5.2"
val zoweKotlinSdkVersion = "0.5.0-rc.7"
val zoweKotlinSdkVersion = "0.5.0-rc.9"
val javaKeytarVersion = "1.0.0"

repositories {
Expand Down
1 change: 1 addition & 0 deletions gradle/sonar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ subprojects {
properties {
property "sonar.sources", "src/main/kotlin"
property "sonar.tests", "src/test/kotlin"
property 'sonar.exclusions', "src/IC-231/**, src/IC-223/**"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ class ConnectionDialog(
)
.bindText(state::username)
.validationOnApply {
it.text = it.text.trim()
if (it !is JPasswordField)
it.text = it.text.trim()
validateForBlank(it)
}.onApply {
state.username = state.username.uppercase()
Expand All @@ -299,7 +300,8 @@ class ConnectionDialog(
.widthGroup(sameWidthLabelsGroup)
passField = cell(JPasswordField())
.bindText(state::password)
.validationOnApply { validateForBlank(it) }
.validationOnApply {
validateForBlank(it) }
.align(AlignX.FILL)
}
indent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.zowe.explorer.utils.crudable.getAll
import org.zowe.explorer.utils.isThe
import org.zowe.explorer.utils.runWriteActionOnWriteThread
import org.zowe.explorer.utils.toMutableList
import org.zowe.explorer.zowe.service.ZoweConfigServiceImpl
import org.zowe.kotlinsdk.zowe.config.ZoweConfig
import org.zowe.kotlinsdk.zowe.config.parseConfigJson
import java.awt.event.MouseAdapter
Expand Down Expand Up @@ -64,13 +65,15 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
}

private fun ZoweConfig.updateFromState(state: ConnectionDialogState) {
setProfile(ZoweConfigServiceImpl.getProfileNameFromConnName(state.connectionName))
val uri = URI(state.connectionUrl)
host = uri.host
port = uri.port.toLong()
protocol = state.connectionUrl.split("://")[0]
user = state.username
password = state.password
rejectUnauthorized = !state.isAllowSsl
restoreProfile()
}

/**
Expand All @@ -81,7 +84,9 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
private fun updateZoweConfigIfNeeded(state: ConnectionDialogState?) {
val res = showOkCancelDialog(
title = "Zowe Config Update",
message = "Do you want to update zowe config file?\n${state?.zoweConfigPath}",
message = "Do you want to update zowe config file and credentials in secret store?"
+ "\n${state?.connectionName}"
+ "\n${state?.zoweConfigPath}",
okText = "Yes",
cancelText = "No"
)
Expand All @@ -97,7 +102,9 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
zoweConfig.extractSecureProperties(configFile.path.split("/").toTypedArray())
zoweConfig.updateFromState(state)
runWriteActionOnWriteThread {
zoweConfig.setProfile(ZoweConfigServiceImpl.getProfileNameFromConnName(state.connectionName))
zoweConfig.saveSecureProperties(configFile.path.split("/").toTypedArray())
zoweConfig.restoreProfile()
configFile.setBinaryContent(zoweConfig.toJson().toByteArray(configFile.charset))
}
}
Expand All @@ -112,8 +119,8 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
val state = showAndTestConnection(connectionsTableModel!![idx].apply {
mode = DialogMode.UPDATE
})
state?.zoweConfigPath?.let {
zoweConfigStates[it] = state
state?.let {
zoweConfigStates[it.connectionName] = state
}
if (state != null) {
connectionsTableModel?.set(idx, state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ fun validateForPassword(password: String, component: JPasswordField): Validation
* @param component the component to check the text in
*/
fun validateForBlank(component: JTextField): ValidationInfo? {
return validateForBlank(component.text, component)
return if(component is JPasswordField){
validateForBlank(String(component.password).trim(), component)
}
else validateForBlank(component.text, component)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun showDialogForDeleteZoweConfigIfNeeded(project: Project, type: ZoweConfigType
"If you decide to leave the connection, it will be converted to a regular connection (username will be visible).",
"Deleting Zowe Config connection",
arrayOf(
"Delete Connection", "Keep Connection"
"Delete Connection(s)", "Keep Connection(s)"
),
0,
AllIcons.General.QuestionDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface ZoweConfigService {
* @param checkConnection - Verify zowe connection by sending info request if true.
* @return - ConnectionConfig that was added or updated.
*/
fun addOrUpdateZoweConfig(scanProject: Boolean = true, checkConnection: Boolean = true, type: ZoweConfigType): ConnectionConfig?
fun addOrUpdateZoweConfig(scanProject: Boolean = true, checkConnection: Boolean = true, type: ZoweConfigType)

/**
* Deletes connection config related to zoweConnection
Expand Down
Loading

0 comments on commit 805e9b6

Please sign in to comment.