26 std::vector<json_t *> content = loader->loadContent();
28 for (json_t *serviceManifest : content) {
29 parseServiceManifest(serviceManifest);
33 void BaseConfigStore::parseServiceManifest(json_t *serviceManifest)
37 std::string errorMessage;
39 json_t *capabilities = json_object_get(serviceManifest,
"capabilities");
40 if (
nullptr == capabilities) {
41 errorMessage =
"Could not parse the \"capability\" object";
42 log_error() << errorMessage;
45 if (!json_is_array(capabilities)) {
46 errorMessage =
"The \"capability\" key does not point to an array";
47 log_error() << errorMessage;
51 log_debug() <<
"Size of capabilities is " << std::to_string(json_array_size(capabilities));
53 json_array_foreach(capabilities, i, capability) {
54 if (!json_is_object(capability)) {
55 errorMessage =
"A \"capability\" in the Service Manifest is not a json object";
56 log_error() << errorMessage;
62 errorMessage =
"Could not read the name of the \"capability\" object";
63 log_error() << errorMessage;
67 json_t *gateways = json_object_get(capability,
"gateways");
68 if (
nullptr == gateways) {
69 errorMessage =
"Could not read the \"gateway\" objects in \"" + capName +
"\"";
70 log_error() << errorMessage;
73 if (!json_is_array(gateways)) {
74 errorMessage =
"The \"gateway\" object is not an array";
75 log_error() << errorMessage;
79 log_debug() <<
"Found capability \"" << capName <<
"\"";
81 parseGatewayConfigs(capName, gateways);
85 void BaseConfigStore::parseGatewayConfigs(std::string capName, json_t *gateways)
87 if (m_capMap.count(capName) > 0) {
88 log_debug() <<
"Capability " << capName <<
" already loaded.";
94 std::string errorMessage;
97 json_array_foreach(gateways, i, gateway) {
98 if (!json_is_object(gateway)) {
99 errorMessage =
"A \"gateway\" in the Service Manifest is not a json object";
100 log_error() << errorMessage;
106 errorMessage =
"Could not read the ID of the \"gateway\"" 107 " object in the Service Manifest";
108 log_error() << errorMessage;
112 json_t *confs = json_object_get(gateway,
"config");
113 if (
nullptr == confs) {
114 errorMessage =
"Could not read the \"gateway\" object's configuration element " 116 log_error() << errorMessage;
119 if (!json_is_array(confs)) {
120 errorMessage =
"The \"gateway\" object's configuration is not an array (" + gwID+
")";
121 log_error() << errorMessage;
124 gwConf.append(gwID, confs);
126 m_capMap[capName] = gwConf;
Contains the softwarecontainer::BaseConfigStore class.
An error occured in ConfigStore when parsing a Capability in a Service Manifest.
Developers guide to adding a config item:
static bool read(const json_t *element, const char *key, std::string &result)
Reads a string from a JSON Object.
BaseConfigStore(std::unique_ptr< ServiceManifestLoader > loader)
Creates a new BaseConfigStore object and searches for Service Manifests (of file type json) in the in...