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
Open
Show file tree
Hide file tree
Changes from 8 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: 0 additions & 1 deletion build/build_zss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ if c89 \
${ZSS}/c/dsutils.c \
${ZSS}/c/envService.c \
${ZSS}/c/jesService.c \
${ZSS}/c/jesrequestsjson.c \
${ZSS}/c/zosDiscovery.c \
${ZSS}/c/securityService.c \
${ZSS}/c/registerProduct.c \
Expand Down
1 change: 0 additions & 1 deletion build/build_zss64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ if ! c89 \
${ZSS}/c/dsutils.c \
${ZSS}/c/envService.c \
${ZSS}/c/jesService.c \
${ZSS}/c/jesrequestsjson.c \
${ZSS}/c/zosDiscovery.c \
${ZSS}/c/securityService.c \
${ZSS}/c/registerProduct.c \
Expand Down
46 changes: 23 additions & 23 deletions c/datasetjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void addDetailedDatasetMetadata(char *datasetName, int nameLength,
int isPDS = FALSE;
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "Going to check dataset %s attributes\n",datasetName);
char dscb[INDEXED_DSCB] = {0};
int rc = obtainDSCB1(datasetName, nameLength,
int rc = dsutilsObtainDSCB1(datasetName, nameLength,
volser, volserLength,
dscb);
if (rc == 0){
Expand All @@ -497,7 +497,7 @@ void addMemberedDatasetMetadata(char *datasetName, int nameLength,

int isPDS = FALSE;
char dscb[INDEXED_DSCB] = {0};
int rc = obtainDSCB1(datasetName, nameLength,
int rc = dsutilsObtainDSCB1(datasetName, nameLength,
volser, volserLength,
dscb);

Expand Down Expand Up @@ -594,11 +594,11 @@ static void updateDatasetWithJSONInternal(HttpResponse* response,
Volser volser;
memset(&volser.value, ' ', sizeof(volser.value));

int volserSuccess = getVolserForDataset(dsn, &volser);
int volserSuccess = dsutilsGetVolserForDataset(dsn, &volser);
if (!volserSuccess){

char dscb[INDEXED_DSCB] = {0};
int rc = obtainDSCB1(dsn->value, sizeof(dsn->value),
int rc = dsutilsObtainDSCB1(dsn->value, sizeof(dsn->value),
volser.value, sizeof(volser.value),
dscb);
if (rc == 0){
Expand Down Expand Up @@ -626,8 +626,8 @@ static void updateDatasetWithJSONInternal(HttpResponse* response,
}
}

maxRecordLength = getMaxRecordLength(dscb);
char recordType = getRecordLengthType(dscb);
maxRecordLength = dsutilsGetMaxRecordLength(dscb);
char recordType = dsutilsGetRecordLengthType(dscb);
if (recordType == 'F'){
isFixed = TRUE;
} else if (recordType == 'U') {
Expand Down Expand Up @@ -803,7 +803,7 @@ static void updateDatasetWithJSON(HttpResponse *response, JsonObject *json, char

HttpRequest *request = response->request;

if (!isDatasetPathValid(datasetPath)) {
if (!dsutilsIsDatasetPathValid(datasetPath)) {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "Invalid dataset name");
return;
}
Expand All @@ -815,7 +815,7 @@ static void updateDatasetWithJSON(HttpResponse *response, JsonObject *json, char

DatasetName dsn;
DatasetMemberName memberName;
extractDatasetAndMemberName(datasetPath, &dsn, &memberName);
dsutilsExtractDatasetAndMemberName(datasetPath, &dsn, &memberName);

DynallocDatasetName daDsn;
DynallocMemberName daMember;
Expand All @@ -838,7 +838,7 @@ static void updateDatasetWithJSON(HttpResponse *response, JsonObject *json, char
"error: ds alloc dsn=\'%44.44s\', member=\'%8.8s\', dd=\'%8.8s\',"
" rc=%d sysRC=%d, sysRSN=0x%08X (update)\n",
daDsn.name, daMember.name, daDDname.name, daRC, daSysRC, daSysRSN, "update");
respondWithDYNALLOCError(response, daRC, daSysRC, daSysRSN,
dsutilsRespondWithDYNALLOCError(response, daRC, daSysRC, daSysRSN,
&daDsn, &daMember, "w");
return;
}
Expand All @@ -856,7 +856,7 @@ static void updateDatasetWithJSON(HttpResponse *response, JsonObject *json, char
int eTagRC = 0;
if (!force) { //do not write dataset if current contents do not match contents client expected, unless forced
int eTagReturnLength = 0;
int lrecl = getLreclOrRespondError(response, &dsn, ddPath);
int lrecl = dsutilsGetLreclOrRespondError(response, &dsn, ddPath);
if (lrecl) {
char *eTag = getDatasetETag(ddPath, lrecl, &eTagRC, &eTagReturnLength);
zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_INFO, "Given etag=%s, current etag=%s\n",lastEtag, eTag);
Expand Down Expand Up @@ -1062,14 +1062,14 @@ void updateDataset(HttpResponse* response, char* absolutePath, int jsonMode) {
void deleteDatasetOrMember(HttpResponse* response, char* absolutePath) {
#ifdef __ZOWE_OS_ZOS
HttpRequest *request = response->request;
if (!isDatasetPathValid(absolutePath)) {
if (!dsutilsIsDatasetPathValid(absolutePath)) {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "Invalid dataset name");
return;
}

DatasetName datasetName;
DatasetMemberName memberName;
extractDatasetAndMemberName(absolutePath, &datasetName, &memberName);
dsutilsExtractDatasetAndMemberName(absolutePath, &datasetName, &memberName);
DynallocDatasetName daDatasetName;
DynallocMemberName daMemberName;
memcpy(daDatasetName.name, datasetName.value, sizeof(daDatasetName.name));
Expand Down Expand Up @@ -1105,7 +1105,7 @@ void deleteDatasetOrMember(HttpResponse* response, char* absolutePath) {
" rc=%d sysRC=%d, sysRSN=0x%08X (read)\n",
daDatasetName.name, daMemberName.name, daDDName.name,
daReturnCode, daSysReturnCode, daSysReasonCode);
respondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
dsutilsRespondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
daSysReasonCode, &daDatasetName, &daMemberName,
"r");
return;
Expand All @@ -1124,7 +1124,7 @@ void deleteDatasetOrMember(HttpResponse* response, char* absolutePath) {
" rc=%d sysRC=%d, sysRSN=0x%08X (read)\n",
daDatasetName.name, daMemberName.name, daDDName.name,
daReturnCode, daSysReturnCode, daSysReasonCode);
respondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
dsutilsRespondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
daSysReasonCode, &daDatasetName, &daMemberName,
"r");
return;
Expand Down Expand Up @@ -1192,7 +1192,7 @@ void deleteDatasetOrMember(HttpResponse* response, char* absolutePath) {
" rc=%d sysRC=%d, sysRSN=0x%08X (read)\n",
daDatasetName.name, daMemberName.name, daDDName.name,
daReturnCode, daSysReturnCode, daSysReasonCode);
respondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
dsutilsRespondWithDYNALLOCError(response, daReturnCode, daSysReturnCode,
daSysReasonCode, &daDatasetName, &daMemberName,
"r");
return;
Expand Down Expand Up @@ -1266,7 +1266,7 @@ char getCSIType(char* absolutePath) {

DatasetName datasetName;
DatasetMemberName memberName;
extractDatasetAndMemberName(absolutePath, &datasetName, &memberName);
dsutilsExtractDatasetAndMemberName(absolutePath, &datasetName, &memberName);

char dsNameNullTerm[DATASET_NAME_LEN + 1] = {0};
memcpy(dsNameNullTerm, datasetName.value, sizeof(datasetName.value));
Expand Down Expand Up @@ -1294,7 +1294,7 @@ void deleteVSAMDataset(HttpResponse* response, char* absolutePath) {
#ifdef __ZOWE_OS_ZOS
HttpRequest *request = response->request;

if (!isDatasetPathValid(absolutePath)) {
if (!dsutilsIsDatasetPathValid(absolutePath)) {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "Invalid dataset name");
return;
}
Expand Down Expand Up @@ -1428,7 +1428,7 @@ static void respondWithDatasetInternal(HttpResponse* response,
char ddPath[16];
snprintf(ddPath, sizeof(ddPath), "DD:%8.8s", ddName->value);

int lrecl = getLreclOrRespondError(response, dsn, ddPath);
int lrecl = dsutilsGetLreclOrRespondError(response, dsn, ddPath);
if (!lrecl) {
return;
}
Expand All @@ -1454,14 +1454,14 @@ void respondWithDataset(HttpResponse* response, char* absolutePath, int jsonMode

HttpRequest *request = response->request;

if (!isDatasetPathValid(absolutePath)) {
if (!dsutilsIsDatasetPathValid(absolutePath)) {
respondWithError(response, HTTP_STATUS_BAD_REQUEST, "Invalid dataset name");
return;
}

DatasetName dsn;
DatasetMemberName memberName;
extractDatasetAndMemberName(absolutePath, &dsn, &memberName);
dsutilsExtractDatasetAndMemberName(absolutePath, &dsn, &memberName);

DynallocDatasetName daDsn;
DynallocMemberName daMember;
Expand All @@ -1484,7 +1484,7 @@ void respondWithDataset(HttpResponse* response, char* absolutePath, int jsonMode
"error: ds alloc dsn=\'%44.44s\', member=\'%8.8s\', dd=\'%8.8s\',"
" rc=%d sysRC=%d, sysRSN=0x%08X (read)\n",
daDsn.name, daMember.name, daDDname.name, daRC, daSysRC, daSysRSN);
respondWithDYNALLOCError(response, daRC, daSysRC, daSysRSN,
dsutilsRespondWithDYNALLOCError(response, daRC, daSysRC, daSysRSN,
&daDsn, &daMember, "r");
return;
}
Expand Down Expand Up @@ -1840,7 +1840,7 @@ void respondWithDatasetMetadata(HttpResponse *response) {
char *absDsPathTemp = stringConcatenate(response->slh, "//'", percentDecoded);
char *absDsPath = stringConcatenate(response->slh, absDsPathTemp, "'");

if(!isDatasetPathValid(absDsPath)){
if(!dsutilsIsDatasetPathValid(absDsPath)){
respondWithError(response,HTTP_STATUS_BAD_REQUEST,"Invalid dataset path");
return;
}
Expand All @@ -1852,7 +1852,7 @@ void respondWithDatasetMetadata(HttpResponse *response) {
DatasetMemberName memName;
int memberNameLength = 0;

extractDatasetAndMemberName(absDsPath, &dsnName, &memName);
dsutilsExtractDatasetAndMemberName(absDsPath, &dsnName, &memName);
memberNameLength = (unsigned int)rParenIndex - (unsigned int)lParenIndex -1;

HttpRequestParam *addQualifiersParam = getCheckedParam(request,"addQualifiers");
Expand Down
67 changes: 35 additions & 32 deletions c/dsutils.c
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@

/*
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.
*/

#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

/* HAS NOT BEEN COMPILED WITH METTLE BEFORE */
#error Metal C is not supported
#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

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/stat.h>
#include "zowetypes.h"
#include "alloc.h"
#include "utils.h"
#include "json.h"
#include "bpxnet.h"
#include "logging.h"
#include "unixfile.h"
#ifdef __ZOWE_OS_ZOS
#include "zos.h"
#endif

#include "charsets.h"

#include "socketmgmt.h"
#include "httpserver.h"
#include "datasetjson.h"
#include "pdsutil.h"
#include "jcsi.h"
#include "impersonation.h"
#include "dynalloc.h"
#include "utils.h"
#include "vsam.h"
#include "qsam.h"
#include "icsf.h"



#include "dsutils.h"


#ifdef __ZOWE_OS_ZOS
/*
Dataset only, no wildcards or pds members accepted - beware that this should be wrapped with authentication
*/
int getVolserForDataset(const DatasetName *dataset, Volser *volser) {
int dsutilsGetVolserForDataset(const DatasetName *dataset, Volser *volser) {
if (dataset == NULL){
return -1;
}
Expand Down Expand Up @@ -91,7 +84,7 @@ int getVolserForDataset(const DatasetName *dataset, Volser *volser) {
return rc;
}

char getRecordLengthType(char *dscb){
char dsutilsGetRecordLengthType(char *dscb){
int posOffset = 44;
int recfm = dscb[84 - posOffset];
if ((recfm & 0xc0) == 0xc0){
Expand All @@ -105,13 +98,13 @@ char getRecordLengthType(char *dscb){
}
}

int getMaxRecordLength(char *dscb){
int dsutilsGetMaxRecordLength(char *dscb){
int posOffset = 44;
int lrecl = (dscb[88-posOffset] << 8) | dscb[89-posOffset];
return lrecl;
}

int obtainDSCB1(const char *dsname, unsigned int dsnameLength,
int dsutilsObtainDSCB1(const char *dsname, unsigned int dsnameLength,
const char *volser, unsigned int volserLength,
char *dscb1) {

Expand Down Expand Up @@ -179,7 +172,7 @@ int obtainDSCB1(const char *dsname, unsigned int dsnameLength,
}


int getLreclOrRespondError(HttpResponse *response,
int dsutilsGetLreclOrRespondError(HttpResponse *response,
const DatasetName *dsn,
const char *ddPath){

Expand All @@ -190,20 +183,20 @@ int getLreclOrRespondError(HttpResponse *response,
int reasonCode;
FILE *in = fopen(ddPath, "r");
if (in == NULL) {
respondWithError(response,HTTP_STATUS_NOT_FOUND,"File could not be opened or does not exist");
respondWithError(response, HTTP_STATUS_NOT_FOUND, "File could not be opened or does not exist");
return 0;
}

Volser volser;
memset(&volser.value, ' ', sizeof(volser.value));

int volserSuccess = getVolserForDataset(dsn, &volser);
int volserSuccess = dsutilsGetVolserForDataset(dsn, &volser);
int handledThroughDSCB = FALSE;

if (!volserSuccess){

char dscb[INDEXED_DSCB] = {0};
int rc = obtainDSCB1(dsn->value, sizeof(dsn->value),
int rc = dsutilsObtainDSCB1(dsn->value, sizeof(dsn->value),
volser.value, sizeof(volser.value),
dscb);
if (rc == 0){
Expand All @@ -212,8 +205,8 @@ int getLreclOrRespondError(HttpResponse *response,
dumpbuffer(dscb,INDEXED_DSCB);
}

lrecl = getMaxRecordLength(dscb);
char recordType = getRecordLengthType(dscb);
lrecl = dsutilsGetMaxRecordLength(dscb);
char recordType = dsutilsGetRecordLengthType(dscb);
if (recordType == 'U'){
fclose(in);
respondWithError(response, HTTP_STATUS_BAD_REQUEST,"Undefined-length dataset");
Expand Down Expand Up @@ -251,7 +244,7 @@ int getLreclOrRespondError(HttpResponse *response,
#define DSPATH_PREFIX "//\'"
#define DSPATH_SUFFIX "\'"

bool isDatasetPathValid(const char *path) {
bool dsutilsIsDatasetPathValid(const char *path) {

/* Basic check. The fopen() dataset path format is //'dsn(member)' */

Expand Down Expand Up @@ -340,7 +333,7 @@ bool isDatasetPathValid(const char *path) {
#define DSPATH_PREFIX "//\'"
#define DSPATH_SUFFIX "\'"

void extractDatasetAndMemberName(const char *datasetPath,
void dsutilsExtractDatasetAndMemberName(const char *datasetPath,
DatasetName *dsn,
DatasetMemberName *memberName) {

Expand Down Expand Up @@ -374,7 +367,7 @@ void extractDatasetAndMemberName(const char *datasetPath,
#undef DSPATH_PREFIX
#undef DSPATH_SUFFIX

void respondWithDYNALLOCError(HttpResponse *response,
void dsutilsRespondWithDYNALLOCError(HttpResponse *response,
int rc, int sysRC, int sysRSN,
const DynallocDatasetName *dsn,
const DynallocMemberName *member,
Expand Down Expand Up @@ -415,3 +408,13 @@ void respondWithDYNALLOCError(HttpResponse *response,
#endif /* __ZOWE_OS_ZOS */

#endif /* not METTLE - the whole module */

/*
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.
*/
Loading