From ba2eaf71fe7a4958616ebe9b9c97542ded311463 Mon Sep 17 00:00:00 2001 From: EKhan Date: Fri, 3 Jan 2025 13:22:55 +0000 Subject: [PATCH] Updated commands to use Utils.getResourceURI Signed-off-by: EKhan --- .../sdk/src/constants/CicsCmci.constants.ts | 4 ++++ .../src/commands/closeLocalFileCommand.ts | 21 +++++++----------- .../disableLocalFileCommand.ts | 22 +++++++------------ .../disableCommands/disableProgramCommand.ts | 21 +++++++----------- .../disableTransactionCommand.ts | 22 ++++++++----------- .../enableCommands/enableLocalFileCommand.ts | 21 +++++++----------- .../enableCommands/enableProgramCommand.ts | 21 +++++++----------- .../enableTransactionCommand.ts | 21 +++++++----------- .../vsce/src/commands/openLocalFileCommand.ts | 21 +++++++----------- packages/vsce/src/commands/phaseInCommand.ts | 21 +++++++----------- .../vsce/src/commands/purgeTaskCommand.ts | 13 +++++++---- 11 files changed, 86 insertions(+), 122 deletions(-) diff --git a/packages/sdk/src/constants/CicsCmci.constants.ts b/packages/sdk/src/constants/CicsCmci.constants.ts index 791365ce..059dbc3e 100644 --- a/packages/sdk/src/constants/CicsCmci.constants.ts +++ b/packages/sdk/src/constants/CicsCmci.constants.ts @@ -104,4 +104,8 @@ export const CicsCmciConstants = { */ CICS_CMCI_EXTERNAL_RESOURCES: ["CICSLocalTransaction", "CICSRemoteTransaction", "CICSDefinitionTransaction", "CICSLocalFile"], + /** + * CICSTask parameter + */ + CICS_CMCI_TASK: "CICSTask" }; diff --git a/packages/vsce/src/commands/closeLocalFileCommand.ts b/packages/vsce/src/commands/closeLocalFileCommand.ts index 1e613013..08cfceb0 100644 --- a/packages/vsce/src/commands/closeLocalFileCommand.ts +++ b/packages/vsce/src/commands/closeLocalFileCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../trees/CICSRegionTree"; @@ -143,18 +143,13 @@ async function closeLocalFile( }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - "CICSLocalFile" + //CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3] - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(FILE=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `FILE='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts index 21ce7aa6..4815103c 100644 --- a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -131,19 +131,13 @@ async function disableLocalFile( }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - "CICSLocalFile" + //CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3] - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(FILE=" + - parms.name + - ")"; //+ - //"&PARAMETER=('BUSY(WAIT).')"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `FILE='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts b/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts index 2d606838..c5369349 100644 --- a/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableProgramCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -116,18 +116,13 @@ function disableProgram(session: imperative.AbstractSession, parms: { name: stri }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - CicsCmciConstants.CICS_PROGRAM_RESOURCE + - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(PROGRAM=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `PROGRAM='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_PROGRAM_RESOURCE, options); return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts b/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts index 3a1ffa1f..2ece866f 100644 --- a/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableTransactionCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -124,17 +124,13 @@ async function disableTransaction( }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - CicsCmciConstants.CICS_LOCAL_TRANSACTION + - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(TRANID=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `TRANID='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_LOCAL_TRANSACTION, options); + return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts index aa718227..5c60bbba 100644 --- a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -110,18 +110,13 @@ async function enableLocalFile(session: imperative.AbstractSession, parms: { nam }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - "CICSLocalFile" + //CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3] - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(FILE=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `FILE='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts b/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts index 9882bd86..56a1c5c3 100644 --- a/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableProgramCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -115,18 +115,13 @@ async function enableProgram(session: imperative.AbstractSession, parms: { name: }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - CicsCmciConstants.CICS_PROGRAM_RESOURCE + - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(PROGRAM=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `PROGRAM='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_PROGRAM_RESOURCE, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts b/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts index b1509c0f..40cdfe35 100644 --- a/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableTransactionCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../../trees/CICSRegionTree"; @@ -110,18 +110,13 @@ async function enableTransaction(session: imperative.AbstractSession, parms: { n }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - CicsCmciConstants.CICS_LOCAL_TRANSACTION + - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(TRANID=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `TRANID='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_LOCAL_TRANSACTION, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/openLocalFileCommand.ts b/packages/vsce/src/commands/openLocalFileCommand.ts index b59a06f9..e3c3712f 100644 --- a/packages/vsce/src/commands/openLocalFileCommand.ts +++ b/packages/vsce/src/commands/openLocalFileCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../trees/CICSRegionTree"; @@ -120,18 +120,13 @@ async function openLocalFile(session: imperative.AbstractSession, parms: { name: }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - "CICSLocalFile" + //CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3] - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(FILE=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `FILE='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/phaseInCommand.ts b/packages/vsce/src/commands/phaseInCommand.ts index b77d1073..fcb38f10 100644 --- a/packages/vsce/src/commands/phaseInCommand.ts +++ b/packages/vsce/src/commands/phaseInCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../trees/CICSRegionTree"; @@ -127,18 +127,13 @@ async function performPhaseIn(session: imperative.AbstractSession, parms: { cics }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + - CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + - "/" + - CicsCmciConstants.CICS_PROGRAM_RESOURCE + - "/" + - cicsPlex + - parms.regionName + - "?CRITERIA=(PROGRAM=" + - parms.name + - ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `PROGRAM='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_PROGRAM_RESOURCE, options); return (await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody)) as any; } diff --git a/packages/vsce/src/commands/purgeTaskCommand.ts b/packages/vsce/src/commands/purgeTaskCommand.ts index 128782c1..9ef8236d 100644 --- a/packages/vsce/src/commands/purgeTaskCommand.ts +++ b/packages/vsce/src/commands/purgeTaskCommand.ts @@ -9,7 +9,7 @@ * */ -import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse } from "@zowe/cics-for-zowe-sdk"; +import { CicsCmciConstants, CicsCmciRestClient, ICMCIApiResponse, Utils, IGetResourceUriOptions } from "@zowe/cics-for-zowe-sdk"; import { imperative } from "@zowe/zowe-explorer-api"; import { commands, ProgressLocation, TreeView, window } from "vscode"; import { CICSRegionTree } from "../trees/CICSRegionTree"; @@ -155,8 +155,13 @@ async function purgeTask( }, }; - const cicsPlex = parms.cicsPlex === undefined ? "" : parms.cicsPlex + "/"; - const cmciResource = - "/" + CicsCmciConstants.CICS_SYSTEM_MANAGEMENT + "/" + "CICSTask" + "/" + cicsPlex + parms.regionName + "?CRITERIA=(TASK=" + parms.name + ")"; + const options: IGetResourceUriOptions = { + "cicsPlex": parms.cicsPlex, + "regionName": parms.regionName, + "criteria": `TASK='${parms.name}'` + }; + + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_TASK, options); + return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); }