Skip to content

Commit

Permalink
IJMP-1923 Fixed IDE error in case of invalid zowe.config
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 Nov 5, 2024
1 parent d466545 commit 99e4878
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.zowe.explorer.config.connect.ui.zosmf

import com.google.gson.JsonSyntaxException
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.options.BoundSearchableConfigurable
Expand All @@ -34,6 +35,7 @@ import org.zowe.explorer.config.connect.Credentials
import org.zowe.explorer.config.ws.FilesWorkingSetConfig
import org.zowe.explorer.config.ws.JesWorkingSetConfig
import org.zowe.explorer.config.ws.WorkingSetConfig
import org.zowe.explorer.telemetry.NotificationsService
import org.zowe.explorer.utils.crudable.getAll
import org.zowe.explorer.utils.isThe
import org.zowe.explorer.utils.runWriteActionInEdtAndWait
Expand Down Expand Up @@ -109,7 +111,12 @@ class ZOSMFConnectionConfigurable : BoundSearchableConfigurable("z/OSMF Connecti
return
}

val zoweConfig = parseConfigJson(configFile.inputStream)
val zoweConfig = try {
parseConfigJson(configFile.inputStream)
} catch (e: JsonSyntaxException) {
NotificationsService.getService().notifyError(Exception("Cannot parse Zowe config file"))
return
}
zoweConfig.extractSecureProperties(configFile.path.split("/").toTypedArray())
kotlin.runCatching {
zoweConfig.updateFromState(state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.zowe.explorer.zowe.actions

import com.google.gson.JsonSyntaxException
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
Expand Down Expand Up @@ -84,12 +85,17 @@ class UpdateZoweConfigAction : DumbAwareAction() {
zoweConfigService.localZoweConfig
else
zoweConfigService.globalZoweConfig
if (type == ZoweConfigType.LOCAL) {
zoweConfigService.localZoweConfig = parseConfigJson(editor.document.text)
zoweConfigService.localZoweConfig?.extractSecureProperties(vFile.path.split("/").toTypedArray())
} else {
zoweConfigService.globalZoweConfig = parseConfigJson(editor.document.text)
zoweConfigService.globalZoweConfig?.extractSecureProperties(vFile.path.split("/").toTypedArray())
try {
if (type == ZoweConfigType.LOCAL) {
zoweConfigService.localZoweConfig = parseConfigJson(editor.document.text)
zoweConfigService.localZoweConfig?.extractSecureProperties(vFile.path.split("/").toTypedArray())
} else {
zoweConfigService.globalZoweConfig = parseConfigJson(editor.document.text)
zoweConfigService.globalZoweConfig?.extractSecureProperties(vFile.path.split("/").toTypedArray())
}
} catch (ex: JsonSyntaxException) {
e.presentation.isEnabledAndVisible = false
return
}
val zoweState = zoweConfigService.getZoweConfigState(false, type = type)
e.presentation.isEnabledAndVisible =
Expand Down

0 comments on commit 99e4878

Please sign in to comment.