Skip to content

Commit

Permalink
Fix issue #156 to return proper message for active job
Browse files Browse the repository at this point in the history
Signed-off-by: Tian Na <[email protected]>
  • Loading branch information
tiantn committed Apr 23, 2024
1 parent 3bc2e29 commit 37404bb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
25 changes: 14 additions & 11 deletions src/api/JobUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,20 @@ export class JobUtils {
public static async getSpoolFiles(connection: any, jobId: string): Promise<ISpoolFile[]> {
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",

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (20.x, macos-14)

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (18.x, macos-14)

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (18.x, ubuntu-latest)

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (18.x, windows-latest)

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (20.x, ubuntu-latest)

Trailing spaces not allowed

Check warning on line 80 in src/api/JobUtils.ts

View workflow job for this annotation

GitHub Actions / test (20.x, windows-latest)

Trailing spaces not allowed
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;
}
Expand Down
27 changes: 16 additions & 11 deletions src/cli/list/spool-files-by-jobid/SpoolFilesByJobid.Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 37404bb

Please sign in to comment.