Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to the IBM® CICS® Plug-in for Zowe CLI will be documented
## `6.14.0`

- Changes to JVM Endpoint CICS CMCI constant. [#413](https://github.com/zowe/cics-for-zowe-client/issues/413)
- Enhancement: Added PUT API [#453](https://github.com/zowe/cics-for-zowe-client/issues/453)

## `6.13.0`

Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/src/constants/CicsCmci.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,8 @@ export const CicsCmciConstants = {
*/
INVALIDDATA: 1041,
},
/*
* Default Resp Code
*/
DEFAULT_RESP_CODE: "0000",
};
6 changes: 6 additions & 0 deletions packages/sdk/src/doc/ICMCIApiResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Interface representing API response from CMCI's web interface, parsed from XML to a javascript object
* using the xml2js package.
*/
import { ICMCIResponseErrors } from "./ICMCIResponseErrors";
import { ICMCIResponseResultSummary } from "./ICMCIResponseResultSummary";

export interface ICMCIApiResponse {
Expand All @@ -31,5 +32,10 @@ export interface ICMCIApiResponse {
* https://www.ibm.com/support/knowledgecenter/SSGMCP_5.2.0/com.ibm.cics.ts.clientapi.doc/topics/clientapi_records_element.html
*/
records: any;
/**
* See the following link for more information:
* https://www.ibm.com/support/knowledgecenter/SSGMCP_5.2.0/com.ibm.cics.ts.clientapi.doc/topics/clientapi_errors_element.html
*/
errors?: ICMCIResponseErrors;
};
}
27 changes: 27 additions & 0 deletions packages/sdk/src/doc/ICMCIResponseErrorFeedBack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.
*
*/

/**
* Represents the "feedback" field of the CMCI API response, parsed from XML
* to a javascript object with the xml2js package.
* See the following link for more information:
* https://www.ibm.com/support/knowledgecenter/SSGMCP_5.2.0/com.ibm.cics.ts.clientapi.doc/topics/clientapi_feedback_element.html
*
*/
export interface ICMCIResponseErrorFeedBack {
eyu_cicsname?: string
action?: string
eibfn?: string
eibfn_alt: string
resp: string
resp_alt: string
resp2: string
}
23 changes: 23 additions & 0 deletions packages/sdk/src/doc/ICMCIResponseErrors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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.
*
*/

import { ICMCIResponseErrorFeedBack } from "./ICMCIResponseErrorFeedBack";

/**
* Represents the "errors" field of the CMCI API response, parsed from XML
* to a javascript object with the xml2js package.
* See the following link for more information:
* https://www.ibm.com/support/knowledgecenter/SSGMCP_5.2.0/com.ibm.cics.ts.clientapi.doc/topics/clientapi_errors_element.html
*
*/
export interface ICMCIResponseErrors {
feedback: ICMCIResponseErrorFeedBack
}
3 changes: 3 additions & 0 deletions packages/sdk/src/doc/ICMCIResponseResultSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*
*/

import { ICMCIResponseErrors } from "./ICMCIResponseErrors";

/**
* Represents the "resultsummary" field of the CMCI API response, parsed from XML
* to a javascript object with the xml2js package.
Expand All @@ -26,4 +28,5 @@ export interface ICMCIResponseResultSummary {
displayed_recordcount: string;
successcount?: string;
cachetoken?: string;
errors?: ICMCIResponseErrors
}
1 change: 1 addition & 0 deletions packages/sdk/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from "./get";
export * from "./install";
export * from "./remove-from-list";
export * from "./set";
export * from "./put";
56 changes: 56 additions & 0 deletions packages/sdk/src/methods/put/Put.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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.
*
*/

import { AbstractSession, ImperativeExpect, Logger } from "@zowe/imperative";
import { ICMCIApiResponse, IGetResourceUriOptions, IResourceParms } from "../../doc";
import { ICMCIRequestOptions } from "../../doc/ICMCIRequestOptions";
import { CicsCmciRestClient } from "../../rest";
import { Utils } from "../../utils";

/**
* Put resources on in CICS through CMCI REST API
* @param {AbstractSession} session - the session to connect to CMCI with
* @param {IResourceParms} parms - parameters for getting resources
* @returns {Promise<ICMCIApiResponse>} promise that resolves to the response (XML parsed into a javascript object)
* when the request is complete
* @throws {ImperativeError} CICS resource name not defined or blank
* @throws {ImperativeError} CICS region name not defined or blank
* @throws {ImperativeError} CicsCmciRestClient request fails
*/
export async function putResource(
session: AbstractSession,
parms: IResourceParms,
headers: { [key: string]: string; }[] = [],
requestBody: any,
requestOptions?: ICMCIRequestOptions
): Promise<ICMCIApiResponse> {
ImperativeExpect.toBeDefinedAndNonBlank(parms.name, "CICS Resource name", "CICS resource name is required");

const options: IGetResourceUriOptions = {
cicsPlex: parms.cicsPlex,
regionName: parms.regionName,
criteria: parms.criteria,
parameter: parms.parameter,
queryParams: parms.queryParams,
};

const cmciResource = Utils.getResourceUri(parms.name, options);

Logger.getAppLogger().debug(
"PUT request - Resource [" + parms.name + "]" +
(parms.cicsPlex ? ", CICSplex [" + parms.cicsPlex + "]" : "") +
(parms.regionName ? ", Region [" + parms.regionName + "]" : "") +
(parms.criteria ? ", Criteria [" + parms.criteria + "]" : "") +
(parms.parameter ? ", Parameter [" + parms.parameter + "]" : "")
);

return CicsCmciRestClient.putExpectParsedXml(session, cmciResource, headers, requestBody, requestOptions);
}
12 changes: 12 additions & 0 deletions packages/sdk/src/methods/put/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* 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.
*
*/

export * from "./Put";
14 changes: 10 additions & 4 deletions packages/sdk/src/rest/CicsCmciRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,20 @@ export class CicsCmciRestClient extends AbstractRestClient {
session: AbstractSession,
resource: string,
reqHeaders: any[] = [],
payload: any
payload: any,
requestOptions?: ICMCIRequestOptions
): Promise<ICMCIApiResponse> {
if (payload != null) {
payload = CicsCmciRestClient.convertPayloadToXML(payload);
}
const data = await RestClient.putExpectString.call(AbstractRestClient, session, resource, reqHeaders, payload);
const apiResponse = CicsCmciRestClient.parseStringSync(data);
return CicsCmciRestClient.verifyResponseCodes(apiResponse);
const apiResponse: ICMCIApiResponse = CicsCmciRestClient.parseStringSync(data);
if (requestOptions?.failOnNoData === false && !apiResponse.response.records) {
const resourceName = resource.split(`${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/`)[1].split("/")[0].toLowerCase();
apiResponse.response.records = {};
apiResponse.response.records[resourceName] = [];
}
return CicsCmciRestClient.verifyResponseCodes(apiResponse, requestOptions);
}

/**
Expand Down Expand Up @@ -207,7 +213,7 @@ export class CicsCmciRestClient extends AbstractRestClient {
}

if (requestOptions?.useCICSCmciRestError) {
throw new CicsCmciRestError(CicsCmciMessages.cmciRequestFailed.message, apiResponse.response.resultsummary);
throw new CicsCmciRestError(CicsCmciMessages.cmciRequestFailed.message, apiResponse.response.resultsummary, apiResponse.response.errors);
}

throw new ImperativeError({
Expand Down
19 changes: 15 additions & 4 deletions packages/sdk/src/rest/CicsCmciRestError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import { ImperativeError } from "@zowe/imperative";
import { ICMCIResponseResultSummary } from "../doc";
import { ICMCIResponseErrors } from "../doc/ICMCIResponseErrors";
import { CicsCmciConstants } from "../constants";

export class CicsCmciRestError extends ImperativeError {
resultSummary: ICMCIResponseResultSummary;
Expand All @@ -19,12 +21,16 @@ export class CicsCmciRestError extends ImperativeError {
RESPONSE_2: number;
RESPONSE_1_ALT: string;
RESPONSE_2_ALT: string;
FEEDBACKRESP: number;
FEEDBACKRESP_2: number;
FEEDBACK_ACTION: string;
EIBFN_ALT: string;
FEEDBACKRESP_ALT: string;

constructor(msg: string, resultSummary: ICMCIResponseResultSummary) {
super({
msg,
});
constructor(msg: string , resultSummary: ICMCIResponseResultSummary, errorFeedback?: ICMCIResponseErrors) {
super({msg});
this.resultSummary = resultSummary;
this.resultSummary.errors = errorFeedback;
this.parseResultSummary();
}

Expand All @@ -33,5 +39,10 @@ export class CicsCmciRestError extends ImperativeError {
this.RESPONSE_2 = parseInt(this.resultSummary.api_response2);
this.RESPONSE_1_ALT = this.resultSummary.api_response1_alt;
this.RESPONSE_2_ALT = this.resultSummary.api_response2_alt;
this.FEEDBACKRESP = parseInt(this.resultSummary.errors?.feedback?.resp || CicsCmciConstants.DEFAULT_RESP_CODE);
this.FEEDBACKRESP_2 = parseInt(this.resultSummary.errors?.feedback?.resp2 || CicsCmciConstants.DEFAULT_RESP_CODE);
this.FEEDBACK_ACTION = this.resultSummary.errors?.feedback?.action;
this.FEEDBACKRESP_ALT = this.resultSummary.errors?.feedback?.resp_alt;
this.EIBFN_ALT = this.resultSummary.errors?.feedback?.eibfn_alt
}
}
1 change: 1 addition & 0 deletions packages/vsce/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the "cics-extension-for-zowe" extension will be documente
- Enhancement: Added Enable/Disable actions to JVM Endpoints. [#413](https://github.com/zowe/cics-for-zowe-client/issues/413)
- Bugfix: Refresh CICS Resource Inspector panel after performing action. [#433](https://github.com/zowe/cics-for-zowe-client/issues/433)
- Enhancement: Add Update Credentials option to the Manage Profile menu. [#451](https://github.com/zowe/cics-for-zowe-client/issues/451)
- Enhancement: Improved error message in notification [#453](https://github.com/zowe/cics-for-zowe-client/issues/453)
- Enhancement: Show CICS bundlepart enablestatus in label and icon. [#467](https://github.com/zowe/cics-for-zowe-client/issues/467)
- Bugfix: Enable MFA CMCI connections using LTPA tokens. [#381](https://github.com/zowe/cics-for-zowe-client/issues/381)

Expand Down
18 changes: 18 additions & 0 deletions packages/vsce/src/constants/CICS.errorMessages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 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.
*
*/


export default {
NO_CICS_RESOURCE_SELECTED: "No CICS resource was selected.",
INVALID_USER_OR_SESSION_EXPIRED: "Invalid credentials or your token has expired. Please login again for profile {0}."
};


57 changes: 57 additions & 0 deletions packages/vsce/src/errors/CICSErrorHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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.
*
*/

import { CICSExtensionError } from "./CICSExtensionError";
import { IError } from "./IError";
import errorConstants from "../constants/CICS.errorMessages";
import { ICICSErrorHandler } from "./ICICSErrorHandler";
import { MessageItem } from "vscode";
import { CICSLogger } from "../utils/CICSLogger";
import { Gui } from "@zowe/zowe-explorer-api";

export function resourceNotFoundError(error?: IError) {
if (!error) {
error.errorMessage = errorConstants.NO_CICS_RESOURCE_SELECTED;
}
}

export class CICSErrorHandler implements ICICSErrorHandler {
handleCMCIRestError(error: CICSExtensionError): Thenable<string | MessageItem> {
const msg = error.cicsExtensionError.errorMessage;
return this.notifyErrorMessage({ errorMessage: msg });
}

handleExtensionError() {}

notifyErrorMessage({
errorMessage,
additionalInfo,
action,
}: {
errorMessage: string;
additionalInfo?: string;
action?: MessageItem[];
}): Thenable<string | MessageItem> {
if (additionalInfo) {
CICSLogger.error(`${this.trimLineBreaks(errorMessage)} ${additionalInfo}`);
} else {
CICSLogger.error(`${this.trimLineBreaks(errorMessage)}`);
}
if (action) {
return Gui.errorMessage(errorMessage, { items: [...action] });
}
return Gui.errorMessage(errorMessage);
}

private trimLineBreaks(msg: string) {
return msg.replace(/\n/g, " ").replace(/\s+/g, " ").trim();
}
}
Loading
Loading