Skip to content

Commit

Permalink
Merge branch 'feature/staging-int' into create-datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Caron committed Aug 7, 2019
2 parents 93de7df + c5a9228 commit 96c26c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
32 changes: 21 additions & 11 deletions c/dataservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ static void *lookupDLLEntryPoint(char *libraryName, char *functionName){
return ep;
}

static DataService *makeDataService(WebPlugin *plugin, JsonObject *serviceJsonObject, char *subURI, InternalAPIMap *namedAPIMap) {
static DataService *makeDataService(WebPlugin *plugin, JsonObject *serviceJsonObject, char *subURI, InternalAPIMap *namedAPIMap,
unsigned int *idMultiplier, int pluginLogLevel) {
zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_INFO, "%s begin data service:\n", __FUNCTION__);
DataService *service = (DataService*) safeMalloc(sizeof (DataService), "DataService");
memset(service, 0, sizeof (DataService));
Expand All @@ -136,7 +137,7 @@ static DataService *makeDataService(WebPlugin *plugin, JsonObject *serviceJsonOb
service->name = jsonObjectGetString(serviceJsonObject, "subserviceName");
} else {
service->name = jsonObjectGetString(serviceJsonObject, "name");
}
}
service->identifier = safeMalloc(strlen(plugin->identifier) + 1
+ (service->subURI ? strlen(service->subURI) + 1 : 0)
+ (service->name ? strlen(service->name) : 0) + 1, "service identifier name");
Expand All @@ -149,7 +150,11 @@ static DataService *makeDataService(WebPlugin *plugin, JsonObject *serviceJsonOb
} else {
sprintf(service->identifier, "%s", plugin->identifier);
}

service->loggingIdentifier = LOG_PROD_PLUGINS + (0x10000 * (*idMultiplier)); // creates unique logging id
logConfigureComponent(NULL, service->loggingIdentifier, service->identifier,
LOG_DEST_PRINTF_STDOUT, pluginLogLevel);
zowelog(NULL,service->loggingIdentifier,ZOWE_LOG_INFO,"added identifier for %s\n", service->identifier);

char *initializerLookupMethod = jsonObjectGetString(serviceJsonObject, "initializerLookupMethod");
char *initializerName = jsonObjectGetString(serviceJsonObject, "initializerName");
if (!strcmp(initializerLookupMethod, "internal")) {
Expand Down Expand Up @@ -235,21 +240,22 @@ static bool isValidServiceDef(JsonObject *serviceDef) {
return true;
}

WebPlugin *makeWebPlugin(char *pluginLocation, JsonObject *pluginDefintion, InternalAPIMap *internalAPIMap) {
WebPlugin *makeWebPlugin(char *pluginLocation, JsonObject *pluginDefinition, InternalAPIMap *internalAPIMap,
unsigned int *idMultiplier, int pluginLogLevel) {
zowelog(NULL, LOG_COMP_DATASERVICE, ZOWE_LOG_INFO, "%s begin\n", __FUNCTION__);
WebPlugin *plugin = (WebPlugin*)safeMalloc(sizeof(WebPlugin),"WebPlugin");
memset(plugin, 0, sizeof (WebPlugin));
plugin->pluginLocation = pluginLocation;
plugin->identifier = jsonObjectGetString(pluginDefintion, "identifier");
plugin->baseURI = jsonObjectGetString(pluginDefintion, "baseURI");
char *pluginType = jsonObjectGetString(pluginDefintion, "pluginType");
plugin->identifier = jsonObjectGetString(pluginDefinition, "identifier");
plugin->baseURI = jsonObjectGetString(pluginDefinition, "baseURI");
char *pluginType = jsonObjectGetString(pluginDefinition, "pluginType");
if (pluginType) {
plugin->pluginType = pluginTypeFromString(pluginType);
} else {
plugin->pluginType = WEB_PLUGIN_TYPE_APPLICATION;
}
plugin->pluginDefinition = pluginDefintion;
JsonArray *dataServices = jsonObjectGetArray(pluginDefintion, "dataServices");
plugin->pluginDefinition = pluginDefinition;
JsonArray *dataServices = jsonObjectGetArray(pluginDefinition, "dataServices");

if (dataServices && jsonArrayGetCount(dataServices) > 0) {
/* count data services */
Expand Down Expand Up @@ -281,13 +287,17 @@ WebPlugin *makeWebPlugin(char *pluginLocation, JsonObject *pluginDefintion, Inte
char *type = jsonObjectGetString(serviceDef, "type");

if (!type || !strcmp(type, "service")) {
plugin->dataServices[k++] = makeDataService(plugin, jsonArrayGetObject(dataServices, i), NULL, internalAPIMap);
plugin->dataServices[k++] = makeDataService(plugin, jsonArrayGetObject(dataServices, i), NULL, internalAPIMap,
idMultiplier,pluginLogLevel);
(*idMultiplier++);
} else if (!strcmp(type, "group")) {
char *subURI = jsonObjectGetString(serviceDef, "name");
JsonArray* group = jsonObjectGetArray(serviceDef, "subservices");
if (group) {
for (int j = 0; j < jsonArrayGetCount(group); j++) {
plugin->dataServices[k++] = makeDataService(plugin, jsonArrayGetObject(group, j), subURI, internalAPIMap);
plugin->dataServices[k++] = makeDataService(plugin, jsonArrayGetObject(group, j), subURI, internalAPIMap,
idMultiplier,pluginLogLevel);
(*idMultiplier++);
}
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion h/dataservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ typedef struct DataService_tag {
ExternalAPI *externalAPI; /* a function call to some lower level module to get data */
void *extension; /* another slot to stash things */
JsonObject *serviceDefinition;
uint64 loggingIdentifier;
WebPlugin *plugin;
} DataService;

WebPlugin *makeWebPlugin(char *baseDir, struct JsonObject_tag *pluginDefintion, InternalAPIMap *internalAPIMap);
WebPlugin *makeWebPlugin(char *baseDir, struct JsonObject_tag *pluginDefinition, InternalAPIMap *internalAPIMap,
unsigned int *idMultiplier, int pluginLogLevel);
void initalizeWebPlugin(WebPlugin *plugin, HttpServer *server);

/**
Expand Down
1 change: 1 addition & 0 deletions h/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ZOWE_PRAGMA_PACK_RESET
#define LOG_PROD_COMMON 0x008F000100000000LLU
#define LOG_PROD_ZIS 0x008F000200000000LLU
#define LOG_PROD_ZSS 0x008F000300000000LLU
#define LOG_PROD_PLUGINS 0x008F000400000000LLU

#define LOG_COMP_ALLOC 0x008F000100010000LLU
#define LOG_COMP_UTILS 0x008F000100020000LLU
Expand Down

0 comments on commit 96c26c0

Please sign in to comment.