diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e89968c..3aa9ba27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to the z/OS FTP Plug-in for Zowe CLI will be documented in this file. +## Recent Changes + +- Fix issue #156 to return proper message for active job. ## `2.1.8` diff --git a/src/api/JobUtils.ts b/src/api/JobUtils.ts index ee0c5fd3..85395a68 100644 --- a/src/api/JobUtils.ts +++ b/src/api/JobUtils.ts @@ -75,17 +75,20 @@ export class JobUtils { public static async getSpoolFiles(connection: any, jobId: string): Promise { const jobDetails = (await JobUtils.findJobByID(connection, jobId)); const fullSpoolFiles: ISpoolFile[] = []; - for (const spoolFileToDownload of jobDetails.spoolFiles) { - this.log.debug("Requesting spool files for job %s(%s) spool file ID %d", jobDetails.jobname, jobDetails.jobid, spoolFileToDownload.id); - const option = { - jobName: jobDetails.jobname, - jobId: jobDetails.jobid, - owner: "*", - fileId: spoolFileToDownload.id - }; - const spoolFile = await JobUtils.getSpoolFileContent(connection, option); - spoolFileToDownload.contents = spoolFile; - fullSpoolFiles.push(spoolFileToDownload); + if (jobDetails.spoolFiles) { + for (const spoolFileToDownload of jobDetails.spoolFiles) { + this.log.debug("Requesting spool files for job %s(%s) spool file ID %d", + jobDetails.jobname, jobDetails.jobid, spoolFileToDownload.id); + const option = { + jobName: jobDetails.jobname, + jobId: jobDetails.jobid, + owner: "*", + fileId: spoolFileToDownload.id + }; + const spoolFile = await JobUtils.getSpoolFileContent(connection, option); + spoolFileToDownload.contents = spoolFile; + fullSpoolFiles.push(spoolFileToDownload); + } } return fullSpoolFiles; } diff --git a/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts b/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts index 37503df7..7da8bba5 100644 --- a/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts +++ b/src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts @@ -23,17 +23,22 @@ export default class ListSpoolFilesByJobidHandler extends FTPBaseHandler { this.log.debug("Listing spool files for job ID %s", params.arguments.jobid); const job = await JobUtils.findJobByID(params.connection, params.arguments.jobid); const files = job.spoolFiles; + if (files) { + const successMessage = this.log.info(`"${files.length}" spool files obtained for job "${job.jobname}(${job.jobid})"`); + // Set the object, message, and log the prettified object + params.response.data.setObj(files); + params.response.data.setMessage(successMessage); - const successMessage = this.log.info(`"${files.length}" spool files obtained for job "${job.jobname}(${job.jobid})"`); - // Set the object, message, and log the prettified object - params.response.data.setObj(files); - params.response.data.setMessage(successMessage); - - // Format & print the response - params.response.format.output({ - fields: ["id", "ddname", "procstep", "stepname"], - output: files, - format: "table" - }); + // Format & print the response + params.response.format.output({ + fields: ["id", "ddname", "procstep", "stepname"], + output: files, + format: "table" + }); + } else { + const errorMessage = this.log.info("No spool file available."); + params.response.data.setMessage(errorMessage); + params.response.console.error(errorMessage); + } } }