Skip to content

Commit

Permalink
IJMP-1867 Fixed Owner field for zowe connection
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 Aug 28, 2024
1 parent 7ee72fc commit c3d794f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ConnectionUssOwnerColumn<ConnectionState : ConnectionDialogStateBase<*>>
* Specifies a renderer for this cell
*/
override fun getRenderer(o: ConnectionState): TableCellRenderer {
return UssOwnerColumnRenderer()
return UssOwnerColumnRenderer(o)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package org.zowe.explorer.config.connect.ui.renderer

import com.intellij.icons.AllIcons
import com.intellij.util.ui.table.IconTableCellRenderer
import org.zowe.explorer.config.connect.ui.ConnectionDialogStateBase
import javax.swing.Icon
import javax.swing.JTable
import java.awt.Component
Expand All @@ -21,7 +22,7 @@ const val WARNING_TOOLTIP_TEXT = "The last TSO request failed. Unable to get the
/**
* Renderer class for USS Owner column in the connections table view
*/
class UssOwnerColumnRenderer : IconTableCellRenderer<String>() {
class UssOwnerColumnRenderer(private val connState: ConnectionDialogStateBase<*>) : IconTableCellRenderer<String>() {

/**
* Function returns a warning icon or null if the value is not present
Expand All @@ -41,7 +42,7 @@ class UssOwnerColumnRenderer : IconTableCellRenderer<String>() {
row: Int,
column: Int
): Component {
super.getTableCellRendererComponent(table, value, selected, focus, row, column)
super.getTableCellRendererComponent(table, if (connState.connectionConfig.zoweConfigPath == null) value else "*".repeat(8), selected, focus, row, column)
if (icon != null) {
toolTipText = WARNING_TOOLTIP_TEXT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
this.globalZoweConfig
zoweConfig ?: throw Exception("Cannot get $type Zowe config")

var allPreparedConn = mutableListOf<ConnectionConfig>()
if (checkConnection) {
val failedURLs = testAndPrepareAllZosmfConnections(zoweConfig, type)
val failedURLs = mutableListOf<String>()
allPreparedConn = testAndPrepareAllZosmfConnections(zoweConfig, type, failedURLs)
if (failedURLs.isNotEmpty()) {
val andMore = if (failedURLs.size > 3)
"..."
Expand All @@ -286,15 +288,14 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
return
}
}
for (zosmfConnection in zoweConfig.getListOfZosmfConections()) {
val zoweConnection = prepareConnection(zosmfConnection, type)
val connectionOpt = configCrudable.addOrUpdate(zoweConnection)
for (zosmfConnection in allPreparedConn) {
val connectionOpt = configCrudable.addOrUpdate(zosmfConnection)
if (!connectionOpt.isEmpty) {
var topic = if (type == ZoweConfigType.LOCAL)
LOCAL_ZOWE_CONFIG_CHANGED
else
GLOBAL_ZOWE_CONFIG_CHANGED
sendTopic(topic).onConfigSaved(zoweConfig, zoweConnection)
sendTopic(topic).onConfigSaved(zoweConfig, zosmfConnection)
}
}

Expand Down Expand Up @@ -325,17 +326,18 @@ class ZoweConfigServiceImpl(override val myProject: Project) : ZoweConfigService
* @param type of zowe config
* @return list of URLs which did not pass the test
*/
private fun testAndPrepareAllZosmfConnections(zoweConfig: ZoweConfig, type: ZoweConfigType): List<String> {
var failedURLs = mutableListOf<String>()
private fun testAndPrepareAllZosmfConnections(zoweConfig: ZoweConfig, type: ZoweConfigType, failedURLs: MutableList<String>): MutableList<ConnectionConfig> {
var allPreparedConn = mutableListOf<ConnectionConfig>()
for (zosmfConnection in zoweConfig.getListOfZosmfConections()) {
val zoweConnection = prepareConnection(zosmfConnection, type)
try {
testAndPrepareConnection(zoweConnection)
} catch (t: Throwable) {
failedURLs.add(zoweConnection.url)
}
allPreparedConn.add(zoweConnection)
}
return failedURLs
return allPreparedConn
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ class ZoweConfigTestSpec : WithApplicationShouldSpec({
isInputStreamCalled shouldBe true
isReturnedZoweConfig shouldBe true
isScanForZoweConfigCalled shouldBe true
isAddOrUpdateConnectionCalled shouldBe true
isZOSInfoCalled shouldBe false
}

Expand Down

0 comments on commit c3d794f

Please sign in to comment.