Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CICS connections breaking other ZE sessions #173

Merged
merged 12 commits into from
Jan 9, 2025
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
43 changes: 7 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/vsce/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente

- BugFix: Updated commands to use Utils.getResourceURI. [#178](https://github.com/zowe/cics-for-zowe-client/issues/178)
- BugFix: Regions icon updates when plex tree is expanded. [#194](https://github.com/zowe/cics-for-zowe-client/issues/194)
- BugFix: Opening CICS connections prevents other Zowe sessions connecting. [#159](https://github.com/zowe/cics-for-zowe-client/issues/159)

## `3.2.3`

Expand Down
1 change: 0 additions & 1 deletion packages/vsce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,6 @@
"@zowe/cics-for-zowe-sdk": "6.2.4",
"@zowe/core-for-zowe-sdk": "^8.0.0",
"@zowe/zowe-explorer-api": "^3.0.3",
"axios": "^1.6.7",
"xml-js": "~1.6.11"
}
}
28 changes: 28 additions & 0 deletions packages/vsce/src/commands/ICommandParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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 Contributors to the Zowe Project.
*
*/

/**
* Parameters passed to a command
*/
export interface ICommandParams {
/**
* Name of resource to find in filter
*/
name: string;
/**
* Region Applid to perform action
*/
regionName: string;
/**
* CICS Plex to perform action
*/
cicsPlex: string;
}
11 changes: 3 additions & 8 deletions packages/vsce/src/commands/closeLocalFileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { imperative } from "@zowe/zowe-explorer-api";
import { commands, ProgressLocation, TreeView, window } from "vscode";
import { CICSRegionTree } from "../trees/CICSRegionTree";
import { CICSTree } from "../trees/CICSTree";
import * as https from "https";
import { CICSRegionsContainer } from "../trees/CICSRegionsContainer";
import { CICSLocalFileTreeItem } from "../trees/treeItems/CICSLocalFileTreeItem";
import { findSelectedNodes, splitCmciErrorMessage } from "../utils/commandUtils";
import { CICSCombinedLocalFileTree } from "../trees/CICSCombinedTrees/CICSCombinedLocalFileTree";
import { ICommandParams } from "./ICommandParams";

export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
return commands.registerCommand("cics-extension-for-zowe.closeLocalFile", async (clickedNode) => {
Expand Down Expand Up @@ -52,8 +52,6 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>
});
const currentNode = allSelectedNodes[parseInt(index)];

https.globalAgent.options.rejectUnauthorized = currentNode.parentRegion.parentSession.session.ISession.rejectUnauthorized;

try {
await closeLocalFile(
currentNode.parentRegion.parentSession.session,
Expand All @@ -64,20 +62,17 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>
},
busyDecision
);
https.globalAgent.options.rejectUnauthorized = undefined;
if (!parentRegions.includes(currentNode.parentRegion)) {
parentRegions.push(currentNode.parentRegion);
}
} catch (error) {
https.globalAgent.options.rejectUnauthorized = undefined;
// @ts-ignore
if (error.mMessage) {
// @ts-ignore
const [_, resp2, respAlt, eibfnAlt] = splitCmciErrorMessage(error.mMessage);

window.showErrorMessage(
`Perform CLOSE on local file "${
allSelectedNodes[parseInt(index)].localFile.file
`Perform CLOSE on local file "${allSelectedNodes[parseInt(index)].localFile.file
}" failed: EXEC CICS command (${eibfnAlt}) RESP(${respAlt}) RESP2(${resp2})`
);
} else {
Expand Down Expand Up @@ -124,7 +119,7 @@ export function getCloseLocalFileCommand(tree: CICSTree, treeview: TreeView<any>

async function closeLocalFile(
session: imperative.AbstractSession,
parms: { name: string; regionName: string; cicsPlex: string },
parms: ICommandParams,
busyDecision: string
): Promise<ICMCIApiResponse> {
const requestBody: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { imperative } from "@zowe/zowe-explorer-api";
import { commands, ProgressLocation, TreeView, window } from "vscode";
import { CICSRegionTree } from "../../trees/CICSRegionTree";
import { CICSTree } from "../../trees/CICSTree";
import * as https from "https";
import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer";
import { findSelectedNodes } from "../../utils/commandUtils";
import { CICSLocalFileTreeItem } from "../../trees/treeItems/CICSLocalFileTreeItem";
import { CICSCombinedLocalFileTree } from "../../trees/CICSCombinedTrees/CICSCombinedLocalFileTree";
import { ICommandParams } from "../ICommandParams";

export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
return commands.registerCommand("cics-extension-for-zowe.disableLocalFile", async (clickedNode) => {
Expand Down Expand Up @@ -52,8 +52,6 @@ export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<an
});
const currentNode = allSelectedNodes[parseInt(index)];

https.globalAgent.options.rejectUnauthorized = currentNode.parentRegion.parentSession.session.ISession.rejectUnauthorized;

try {
await disableLocalFile(
currentNode.parentRegion.parentSession.session,
Expand All @@ -64,12 +62,10 @@ export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<an
},
busyDecision
);
https.globalAgent.options.rejectUnauthorized = undefined;
if (!parentRegions.includes(currentNode.parentRegion)) {
parentRegions.push(currentNode.parentRegion);
}
} catch (error) {
https.globalAgent.options.rejectUnauthorized = undefined;
window.showErrorMessage(
`Something went wrong when performing a DISABLE - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
/(\\n\t|\\n|\\t)/gm,
Expand Down Expand Up @@ -112,7 +108,7 @@ export function getDisableLocalFileCommand(tree: CICSTree, treeview: TreeView<an

async function disableLocalFile(
session: imperative.AbstractSession,
parms: { name: string; regionName: string; cicsPlex: string },
parms: ICommandParams,
busyDecision: string
): Promise<ICMCIApiResponse> {
const requestBody: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { imperative } from "@zowe/zowe-explorer-api";
import { commands, ProgressLocation, TreeView, window } from "vscode";
import { CICSRegionTree } from "../../trees/CICSRegionTree";
import { CICSTree } from "../../trees/CICSTree";
import * as https from "https";
import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer";
import { findSelectedNodes } from "../../utils/commandUtils";
import { CICSProgramTreeItem } from "../../trees/treeItems/CICSProgramTreeItem";
import { CICSCombinedProgramTree } from "../../trees/CICSCombinedTrees/CICSCombinedProgramTree";
import { ICommandParams } from "../ICommandParams";

/**
* Performs disable on selected CICSProgram nodes.
Expand Down Expand Up @@ -50,20 +50,17 @@ export function getDisableProgramCommand(tree: CICSTree, treeview: TreeView<any>
});
const currentNode = allSelectedNodes[parseInt(index)];

https.globalAgent.options.rejectUnauthorized = currentNode.parentRegion.parentSession.session.ISession.rejectUnauthorized;

try {
await disableProgram(currentNode.parentRegion.parentSession.session, {
name: currentNode.program.program,
regionName: currentNode.parentRegion.label,
cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined,
});
https.globalAgent.options.rejectUnauthorized = undefined;
if (!parentRegions.includes(currentNode.parentRegion)) {
parentRegions.push(currentNode.parentRegion);
}
} catch (error) {
https.globalAgent.options.rejectUnauthorized = undefined;
// @ts-ignore
window.showErrorMessage(
`Something went wrong when performing a disable - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
Expand Down Expand Up @@ -105,7 +102,7 @@ export function getDisableProgramCommand(tree: CICSTree, treeview: TreeView<any>
});
}

function disableProgram(session: imperative.AbstractSession, parms: { name: string; regionName: string; cicsPlex: string }): Promise<ICMCIApiResponse> {
function disableProgram(session: imperative.AbstractSession, parms: ICommandParams): Promise<ICMCIApiResponse> {
const requestBody: any = {
request: {
action: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { imperative } from "@zowe/zowe-explorer-api";
import { commands, ProgressLocation, TreeView, window } from "vscode";
import { CICSRegionTree } from "../../trees/CICSRegionTree";
import { CICSTree } from "../../trees/CICSTree";
import * as https from "https";
import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer";
import { findSelectedNodes, splitCmciErrorMessage } from "../../utils/commandUtils";
import { CICSTransactionTreeItem } from "../../trees/treeItems/CICSTransactionTreeItem";
import { CICSCombinedTransactionsTree } from "../../trees/CICSCombinedTrees/CICSCombinedTransactionTree";
import { ICommandParams } from "../ICommandParams";

export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView<any>) {
return commands.registerCommand("cics-extension-for-zowe.disableTransaction", async (clickedNode) => {
Expand All @@ -45,20 +45,17 @@ export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView<
});
const currentNode = allSelectedNodes[parseInt(index)];

https.globalAgent.options.rejectUnauthorized = currentNode.parentRegion.parentSession.session.ISession.rejectUnauthorized;

try {
await disableTransaction(currentNode.parentRegion.parentSession.session, {
name: currentNode.transaction.tranid,
regionName: currentNode.parentRegion.label,
cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined,
});
https.globalAgent.options.rejectUnauthorized = undefined;
if (!parentRegions.includes(currentNode.parentRegion)) {
parentRegions.push(currentNode.parentRegion);
}
} catch (error) {
https.globalAgent.options.rejectUnauthorized = undefined;
// @ts-ignore
if (error.mMessage) {
// @ts-ignore
Expand Down Expand Up @@ -112,7 +109,7 @@ export function getDisableTransactionCommand(tree: CICSTree, treeview: TreeView<

async function disableTransaction(
session: imperative.AbstractSession,
parms: { name: string; regionName: string; cicsPlex: string }
parms: ICommandParams
): Promise<ICMCIApiResponse> {
const requestBody: any = {
request: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { imperative } from "@zowe/zowe-explorer-api";
import { commands, ProgressLocation, TreeView, window } from "vscode";
import { CICSRegionTree } from "../../trees/CICSRegionTree";
import { CICSTree } from "../../trees/CICSTree";
import * as https from "https";
import { CICSRegionsContainer } from "../../trees/CICSRegionsContainer";
import { CICSLocalFileTreeItem } from "../../trees/treeItems/CICSLocalFileTreeItem";
import { findSelectedNodes } from "../../utils/commandUtils";
import { CICSCombinedLocalFileTree } from "../../trees/CICSCombinedTrees/CICSCombinedLocalFileTree";
import { ICommandParams } from "../ICommandParams";

export function getEnableLocalFileCommand(tree: CICSTree, treeview: TreeView<any>) {
return commands.registerCommand("cics-extension-for-zowe.enableLocalFile", async (clickedNode) => {
Expand All @@ -45,20 +45,17 @@ export function getEnableLocalFileCommand(tree: CICSTree, treeview: TreeView<any
});
const currentNode = allSelectedNodes[parseInt(index)];

https.globalAgent.options.rejectUnauthorized = currentNode.parentRegion.parentSession.session.ISession.rejectUnauthorized;

try {
await enableLocalFile(currentNode.parentRegion.parentSession.session, {
name: currentNode.localFile.file,
regionName: currentNode.parentRegion.label,
cicsPlex: currentNode.parentRegion.parentPlex ? currentNode.parentRegion.parentPlex.getPlexName() : undefined,
});
https.globalAgent.options.rejectUnauthorized = undefined;
if (!parentRegions.includes(currentNode.parentRegion)) {
parentRegions.push(currentNode.parentRegion);
}
} catch (error) {
https.globalAgent.options.rejectUnauthorized = undefined;
window.showErrorMessage(
`Something went wrong when performing an ENABLE - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace(
/(\\n\t|\\n|\\t)/gm,
Expand Down Expand Up @@ -99,7 +96,7 @@ export function getEnableLocalFileCommand(tree: CICSTree, treeview: TreeView<any
});
}

async function enableLocalFile(session: imperative.AbstractSession, parms: { name: string; regionName: string; cicsPlex: string }): Promise<ICMCIApiResponse> {
async function enableLocalFile(session: imperative.AbstractSession, parms: ICommandParams): Promise<ICMCIApiResponse> {
const requestBody: any = {
request: {
action: {
Expand Down
Loading
Loading