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

Add new zss /jes end point for submitting jcl to jes #402

Open
wants to merge 16 commits into
base: v2.x/staging
Choose a base branch
from

Conversation

joepun76
Copy link
Contributor

@joepun76 joepun76 commented Feb 1, 2022

Signed-off-by: joepun76 [email protected]

Proposed changes

This PR addresses Issue: [Link to Github issue within https://github.com/zowe/zlux/issues if any]

This PR depends upon the following PRs:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Change in a documentation
  • Refactor the code
  • Chore, repository cleanup, updates the dependencies.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

PR Checklist

Please delete options that are not relevant.

  • If the changes in this PR are meant for the next release / mainline, this PR targets the "staging" branch.
  • My code follows the style guidelines of this project (see: Contributing guideline)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • video or image is included if visual changes are made
  • Relevant update to CHANGELOG.md
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works, or describe a test method below

Testing

Further comments

Add new end point /jes to submit jcl to jes (both jes2 and jes3 are support) with JOBID returned.

Signed-off-by: joepun76 <[email protected]>
@joepun76 joepun76 changed the title initial Add new zss /jes end point for submitting jcl to jes Feb 1, 2022
Copy link
Contributor

@ifakhrutdinov ifakhrutdinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at my comments. FYI, I'm still reviewing jesService.c and jesrequestjson.c.

c/dsutils.c Outdated
@@ -0,0 +1,417 @@
#ifdef METTLE
/* HAS NOT BEEN COMPILED WITH METTLE BEFORE */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this comment? Perhaps #error Metal C is not supported or something similar would be better?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced comment with #error Metal C is not supported

#ifdef METTLE
/* HAS NOT BEEN COMPILED WITH METTLE BEFORE */
#else
#include <stdbool.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these includes? For example, stdarg.h and bpxnet.h aren't needed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary includes

@@ -0,0 +1,417 @@
#ifdef METTLE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file needs the copyright at the top and at the bottom (and any others without one).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included copyright at the top and at the bottom

h/dsutils.h Outdated
int getMaxRecordLength(char *dscb);

int obtainDSCB1(const char *dsname, unsigned int dsnameLength,
const char *volser, unsigned int volserLength,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad formatting.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected formatting

Comment on lines +19 to +26
#define INDEXED_DSCB 96

static char defaultDatasetTypesAllowed[3] = {'A','D','X'};
static char *defaultCSIFields[] ={ "NAME ", "TYPE ", "VOLSER "};
static int defaultCSIFieldCount = 3;

const int DSCB_TRACE = FALSE;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are only used in datasetjson.c, why do we need to expose them in a header?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are used in dsutils.c as well

typedef struct Volser_tag {
char value[6]; /* space-padded */
} Volser;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide doc for these new public functions? See examples in zowe-common-c/h/resmgr.h or other similar files.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included comments similar to zowe-common-c/h/resmgr.h

h/dsutils.h Outdated
char value[6]; /* space-padded */
} Volser;

int getVolserForDataset(const DatasetName *dataset, Volser *volser);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that these are public, should we use a prefix for function names?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used prefix "dsutils"

h/dsutils.h Outdated
} Volser;

int getVolserForDataset(const DatasetName *dataset, Volser *volser);
char getRecordLengthType(char *dscb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good practise to use const for arguments you're not mutating, the definitions will need those too.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used const

c/dsutils.c Outdated
/*
Dataset only, no wildcards or pds members accepted - beware that this should be wrapped with authentication
*/
int getVolserForDataset(const DatasetName *dataset, Volser *volser) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the content of this file the same as the one you removed from datasetjson.c?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the same except that I removed the 'static' in front of the functions.

#define __JESREQUESTSJSON__ 1


#include "stcbase.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need all these headers here? Also, you can always use forward declaration for things like HttpResponse and void including unnecessary headers.

For example,

void respondWithSubmitDataset(struct HttpResponse_tag* response, 
                              const char* absolutePath,
                              int jsonMode);

Copy link

@ojcelis ojcelis May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this .h file and merged the changes to jesService.h. Only needed declarations were included to get .c file clean compiled



void responseWithJobDetails(HttpResponse* response, char* jobID, int jsonMode) {
#ifdef __ZOWE_OS_ZOS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done once in the beginning of this source other than in every function?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this .c file and merged the changes to jesService.c. Updated the code based on this review point

#define NATIVE_CODEPAGE CCSID_EBCDIC_1047
#endif


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason of having a separate source for this functionality as opposed to putting it into jesService.c?

Copy link

@ojcelis ojcelis May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes that are in jesrequestsjson.c were merged into jesService.c. Please check jesService.c for succeeding review points on jesrequestsjson.c


jsonStart(jPrinter);

jsonAddUnterminatedString(jPrinter, "jobId", jobID, 8);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if jobID is smaller than 8 bytes?

Copy link

@ojcelis ojcelis May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code to pass what is the exact bytes of the jobID

#else /* not __ZOWE_OS_ZOS */

/* Currently nothing else has "datasets" */
/* TBD: Is it really necessary to provide this empty array?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What array?

Copy link

@ojcelis ojcelis May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the comment

}

int bufferSize = recordLength+1;
char buffer[bufferSize];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use DATA_STREAM_BUFFER_SIZE + 1, otherwise you may end up with VLAs.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code based on the comment

// empty record
/* jsonAddString(jPrinter, NULL, ""); */
} else if (ferror(in)) {
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "Error reading DSN=%s, rc=%d\n", filename, bytesRead);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you print the actual error code?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added error number in the log

}
}
else {
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "UPDATE DATASET: body was not JSON!\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use this component if it's not related to data sets?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the correct component


char *outACB = NULL;
RPLCommon *rpl = NULL;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issues as in responseWithSubmitJCLContents

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included checking of rc

c/jesService.c Outdated
setResponseStatus(response, 405, "Method Not Allowed");
addStringHeader(response, "Server", "jdmfws");
addStringHeader(response, "Transfer-Encoding", "chunked");
addStringHeader(response, "Allow", "GET, PUT, DELETE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we allow GET and PUT?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only PUT, updated the code

@joepun76 joepun76 assigned joepun76 and unassigned joepun76 Mar 30, 2022
@ojcelis ojcelis self-assigned this Apr 13, 2022
@JoeNemo JoeNemo changed the base branch from v1.x/staging to v2.x/staging May 25, 2022 15:08
h/dsutils.h Outdated
* @return lrecl return the length of a dataset
* 0 this function encountered error
*/
int dsutilsGetLreclOrRespondError(HttpResponse *response, const DatasetName *dsn, const char *ddPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "respond" functions and the functions with http related code don't seem to belong here.

The name dsutils implies some generic data set utils, but the source contains http service speicific code . Did you intend that?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated dsutils and jesService.

h/dsutils.h Outdated
* @return lrecl return the length of a dataset
* 0 this function encountered error
*/
int dsutilsGetLreclOrRespondError(HttpResponse *response, const DatasetName *dsn, const char *ddPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "respond" functions and the functions with http related code don't seem to belong here.

The name dsutils implies some generic data set utils, but the source contains http service speicific code . Did you intend that?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated dustils and jesService.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants