Skip to content

Commit

Permalink
Merge branch 'private-release/v1.2.1-221' into zowe-release/v1.2.1-221
Browse files Browse the repository at this point in the history
Signed-off-by: Uladzislau <[email protected]>
  • Loading branch information
KUGDev committed May 7, 2024
2 parents 81c022b + 3d8d27c commit a014713
Show file tree
Hide file tree
Showing 38 changed files with 396 additions and 175 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ org.gradle.jvmargs=-Xss1M
platformVersion = 2022.1

# SemVer format -> https://semver.org
pluginVersion = 1.2.0-221
pluginVersion = 1.2.1-221
pluginGroup = org.zowe
pluginRepositoryUrl = https://github.com/zowe/zowe-explorer-intellij

Expand All @@ -23,4 +23,4 @@ pluginSinceBuild = 221.5080
pluginUntilBuild = 222.*

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.7.0
gradleVersion = 8.7
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
25 changes: 24 additions & 1 deletion src/main/kotlin/org/zowe/explorer/config/connect/connectUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.zowe.explorer.dataops.operations.TsoOperationMode
import org.zowe.explorer.ui.build.tso.TSOWindowFactory
import org.zowe.explorer.ui.build.tso.config.TSOConfigWrapper
import org.zowe.explorer.ui.build.tso.ui.TSOSessionParams
import org.zowe.kotlinsdk.TsoData


/**
Expand Down Expand Up @@ -50,10 +51,16 @@ fun whoAmI(connectionConfig: ConnectionConfig): String? {
)
}.onSuccess {
var response = it
response.tsoData.last().tsoMessage?.data?.let { data -> owner = data.trim() }
val queuedMessages: MutableList<TsoData> = mutableListOf()
queuedMessages.addAll(response.tsoData)

// consume all the TSO messages while tsoPrompt become not null
while (response.tsoData.last().tsoPrompt == null) {
response = TSOWindowFactory.getTsoMessageQueue(tsoSession)
queuedMessages.addAll(response.tsoData)
}

owner = tryToExtractRealOwner(queuedMessages)
}
service<DataOpsManager>().performOperation(
TsoOperation(
Expand All @@ -66,6 +73,22 @@ fun whoAmI(connectionConfig: ConnectionConfig): String? {
return owner
}

/**
* Utility function extracts the owner from the messages returned from the TSO request
* @param tsoData
* @return USS Owner string value if tsoData contains the userID or an empty string otherwise
*/
fun tryToExtractRealOwner(tsoData: List<TsoData>) : String {
val emptyOwner = ""
val filteredData = tsoData.filter {
val tsoMessage = it.tsoMessage ?: return@filter false
val messageData = tsoMessage.data?.trim() ?: return@filter false
messageData.isNotEmpty() && !messageData.contains("READY") && messageData.chars().count() < 9
}.mapNotNull { it.tsoMessage?.data?.trim() }

return if (filteredData.isNotEmpty()) filteredData[0] else emptyOwner
}

/**
* Returns owner of particular connection config if it is not empty, or the username otherwise.
* @param connectionConfig connection config instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ abstract class ConnectionDialogStateBase<ConnectionConfig: ConnectionConfigBase>
abstract var connectionUuid: String
abstract var connectionName: String
abstract var username: String
abstract var owner: String
abstract var password: String
abstract var connectionUrl: String
abstract var credentials: Credentials
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/

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

import com.intellij.util.ui.ColumnInfo
import org.zowe.explorer.config.connect.ui.renderer.UssOwnerColumnRenderer
import javax.swing.table.TableCellRenderer

/**
* Class which represents column of USS Owner in connections GUI
*/
class ConnectionUssOwnerColumn<ConnectionState : ConnectionDialogStateBase<*>>
: ColumnInfo<ConnectionState, String>("Owner") {

/**
* Returns name of particular owner
* @param item all info about particular connection to mainframe
* @return name of particular owner
*/
override fun valueOf(item: ConnectionState): String {
return item.owner
}

/**
* Sets owner to particular user
* @param item all info about particular connection to mainframe
* @param value new owner of the user
*/
override fun setValue(item: ConnectionState, value: String) {
item.owner = value
}

/**
* Specifies a renderer for this cell
*/
override fun getRenderer(o: ConnectionState): TableCellRenderer {
return UssOwnerColumnRenderer()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ abstract class ConnectionsTableModelBase<ConnectionConfig : ConnectionConfigBase
crudable,
ConnectionNameColumn(),
ConnectionUrlColumn(connectionUrlColumnName),
ConnectionUsernameColumn()
ConnectionUsernameColumn(),
ConnectionUssOwnerColumn()
) {
abstract val connectionConfigClass: Class<out ConnectionConfig>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBA Group 2020
*/

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

import com.intellij.icons.AllIcons
import com.intellij.util.ui.table.IconTableCellRenderer
import javax.swing.Icon
import javax.swing.JTable
import java.awt.Component

const val WARNING_TOOLTIP_TEXT = "The last TSO request failed. Unable to get the real USS owner. The connection username will be used as USS owner"

/**
* Renderer class for USS Owner column in the connections table view
*/
class UssOwnerColumnRenderer : IconTableCellRenderer<String>() {

/**
* Function returns a warning icon or null if the value is not present
*/
override fun getIcon(value: String, table: JTable, row: Int): Icon? {
return if(value.isEmpty()) AllIcons.General.Warning else null
}

/**
* Function returns a component which renders a cell
*/
override fun getTableCellRendererComponent(
table: JTable?,
value: Any?,
selected: Boolean,
focus: Boolean,
row: Int,
column: Int
): Component {
super.getTableCellRendererComponent(table, value, selected, focus, row, column)
if (icon != null) {
toolTipText = WARNING_TOOLTIP_TEXT
}
return this
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
package org.zowe.explorer.config.connect.ui.zosmf

import com.intellij.icons.AllIcons
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.MessageDialogBuilder
Expand All @@ -29,6 +32,7 @@ import org.zowe.explorer.config.connect.ui.ChangePasswordDialog
import org.zowe.explorer.config.connect.ui.ChangePasswordDialogState
import org.zowe.explorer.dataops.DataOpsManager
import org.zowe.explorer.dataops.operations.*
import org.zowe.explorer.explorer.EXPLORER_NOTIFICATION_GROUP_ID
import org.zowe.explorer.utils.*
import org.zowe.explorer.utils.crudable.Crudable
import org.zowe.explorer.utils.crudable.find
Expand Down Expand Up @@ -147,13 +151,30 @@ class ConnectionDialog(
addAnyway
} else {
runTask(title = "Retrieving user information", project = project) {
// Could be empty if TSO request fails
state.owner = whoAmI(newTestedConnConfig) ?: ""
}
if (state.owner.isEmpty()) showWarningNotification(project)
true
}
}
)
}

/**
* Function shows a warning notification if USS owner cannot be retrieved
*/
private fun showWarningNotification(project: Project?) {
Notification(
EXPLORER_NOTIFICATION_GROUP_ID,
"Unable to retrieve USS username",
"Cannot retrieve USS username. An error happened while executing TSO request.\n" +
"When working with USS files the same username will be used that was specified by the user when connecting.",
NotificationType.WARNING
).let {
Notifications.Bus.notify(it, project)
}
}
}

private val initialState = state.clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ data class ConnectionDialogState(
/*var apiMeditationLayer: String = "",*/
override var username: String = "",
override var password: String = "",
override var owner: String = "",
var isAllowSsl: Boolean = false,
var zVersion: ZVersion = ZVersion.ZOS_2_1,
var zoweConfigPath: String? = null,
var owner: String = "",
override var mode: DialogMode = DialogMode.CREATE
) : ConnectionDialogStateBase<ConnectionConfig>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ConnectionsTableModel(
get(row).isAllowSsl = item.isAllowSsl
get(row).password = item.password
get(row).zVersion = item.zVersion
get(row).owner = item.owner
super.set(row, item)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ class RemoteDatasetAttributesService(
val volserDir = fsModel.findOrCreate(
this, subDirectory, newAttributes.volser ?: MIGRATED, createAttributes(directory = true)
)
fsModel.moveFile(this, file, volserDir)
file.move(this, volserDir)
}
if (oldAttributes.name != newAttributes.name) {
fsModel.renameFile(this, file, newAttributes.name)
file.rename(this, newAttributes.name)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RemoteJobAttributesService(
newAttributes: RemoteJobAttributes
) {
if (oldAttributes.name != newAttributes.name) {
fsModel.renameFile(this, file, newAttributes.name)
file.rename(this, newAttributes.name)
fsModel.setWritable(file, false)
}
}
Expand Down
Loading

0 comments on commit a014713

Please sign in to comment.