ZOO-Project
service_json.h
Go to the documentation of this file.
1 /*
2  * Author : GĂ©rald FENOY
3  *
4  * Copyright 2014-2021 GeoLabs SARL. All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef ZOO_JSON_H
26 #define ZOO_JSON_H 1
27 
28 #pragma once
29 
30 #include "response_print.h"
31 #include <stdio.h>
32 #include <ctype.h>
33 #include <service.h>
34 #include <json_object.h>
35 #include "json_c_version.h"
36 
37 #if (JSON_C_MINOR_VERSION<=12)
38 #define JSON_C_TO_STRING_NOSLASHESCAPE (1<<4)
39 #endif
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
48  static const char* statusFields[6]={
49  "type", "processID","created","started","finished","updated"
50  };
51 
55  static const char* statusFieldsC[6]={
56  "itype", "processid","creation_time","start_time","end_time","updated_time"
57  };
58 
62  static const char* statusSearchFields[2]={
63  "processid","status"
64  };
65 
69  static const char* statusSearchFieldsReal[2]={
70  "processid","fstate"
71  };
72 
76  static char oapipStatus[5][11]={
77  "successful",
78  "failed",
79  "running",
80  "dismissed",
81  "accepted"
82  };
83 
87  static const char* jcapabilities[]={
88  "jobControlOptions","sync-execute async-execute dismiss",
89  "outputTransmission","value reference",
90  "jobControlOptions","async-execute dismiss"
91  };
92 
97  static const char* pccFields[9]={
98  "type",
99  "encoding",
100  "schema",
101  "mediaType",
102  "mediaEncoding",
103  "mediaSchema",
104  "contentMediaType",
105  "contentEncoding",
106  "contentSchema"
107  };
108 
113  static const char* pccRFields[3]={
114  "mimeType",
115  "encoding",
116  "schema"
117  };
118 
122  static const char* rangeCorrespondances[4][2]={
123  { "rangeClosure", "rangeClosure" },
124  { "rangeMin", "minimum" },
125  { "rangeMax", "maximum"},
126  { "rangeSpacing", "spacing" }
127  };
128 
129  maps* jsonToMaps(json_object*);
130  map* jsonToMap(json_object*);
131  json_object* mapToJson(map*);
132  json_object* mapsToJson(maps*);
133  json_object* serviceToJson(service*);
134  void printLiteralValueJ(maps*,map*,map*,json_object*,const char*);
137  void parseJRequest(maps*,service*,json_object*,map*,maps**,maps**);
138  json_object* printJResult(maps**,service*,maps*,int);
139  json_object* printJobStatus(maps**,char*);
140  json_object* printJobList(maps**);
141  json_object* printFilteredJobList(maps**,map*);
142  int createNextLinks(maps*,json_object*);
143  int createStatusFile(maps*,int);
144  void json_getStatusAttributes(maps*,map*,json_object*,int);
145  json_object* createStatus(maps*,int);
147  json_object* parseJson(maps*,char*);
148  json_object* json_readFile(maps*,char*);
149  char* getResultPath(maps*,char*);
150  int json_getStatusFile(maps*);
151  void produceApi(maps*,json_object*);
152  void produceRoot(maps*,json_object*);
153  void produceConformances(maps*,json_object*);
154  void outputSingleJsonComplexRes(maps*,maps*,json_object*,json_object*,char*,long);
155  bool jsonIsFalse(json_bool);
156 #ifdef DRU_ENABLED
157  void handleDRUError(maps**);
158  int convertOGCAppPkgToExecute(maps*,map*,json_object**);
159  json_object* convertCwlToOGCAppPkg(maps*,map*);
160  bool serviceIsDRU(maps*,char*);
161  int handlePackage(maps**,char*,char*,char*);
162 #endif
163  bool serviceIsFilter(maps*,char*);
164  //void printIOTypeJ(maps*, const char*, elements*,json_object*,service*);
165 #ifdef __cplusplus
166 }
167 #endif
168 #endif
statusSearchFields
static const char * statusSearchFields[2]
Coreresponding names of field from the data table to fetch informations.
Definition: service_json.h:62
produceRoot
void produceRoot(maps *, json_object *)
Produce the JSON response for /.
Definition: service_json.c:4180
pccFields
static const char * pccFields[9]
Possible field names corresponding to pccRFields.
Definition: service_json.h:97
printExceptionReportResponseJ
void printExceptionReportResponseJ(maps **, map *)
Print an OWS ExceptionReport Document and HTTP headers (when required) depending on the code.
Definition: service_json.c:1274
service.h
mapToJson
json_object * mapToJson(map *)
Convert a map to a json object.
Definition: service_json.c:113
json_getStatusFilePath
char * json_getStatusFilePath(maps *)
Get the status file path.
Definition: service_json.c:3078
mapsToJson
json_object * mapsToJson(maps *)
Convert a maps to a json object.
Definition: service_json.c:156
printJResult
json_object * printJResult(maps **, service *, maps *, int)
Print the result of an execution.
Definition: service_json.c:2527
getResultPath
char * getResultPath(maps *, char *)
Get the result path.
Definition: service_json.c:3096
service
Metadata information about a full Service.
Definition: service.h:715
statusFields
static const char * statusFields[6]
Names of field to output in the status object.
Definition: service_json.h:48
jsonToMaps
maps * jsonToMaps(json_object *)
Convert a json object to maps.
Definition: service_json.c:54
json_readFile
json_object * json_readFile(maps *, char *)
Read a json file.
Definition: service_json.c:3144
produceApi
void produceApi(maps *, json_object *)
Produce the JSON object for /api.
Definition: service_json.c:3779
response_print.h
createStatusFile
int createStatusFile(maps *, int)
Create the status file.
Definition: service_json.c:3367
printJobStatus
json_object * printJobStatus(maps **, char *)
Print the jobs status info cf.
Definition: service_json.c:1974
jcapabilities
static const char * jcapabilities[]
Name and corresponding attributes depending on the WPS version.
Definition: service_json.h:87
serviceToJson
json_object * serviceToJson(service *)
Convert an service to a json object.
Definition: service_json.c:220
produceConformances
void produceConformances(maps *, json_object *)
Produce the JSON response for /conformance.
Definition: service_json.c:4246
printFilteredJobList
json_object * printFilteredJobList(maps **, map *)
Print the filtered jobs list.
Definition: service_json.c:2257
statusSearchFieldsReal
static const char * statusSearchFieldsReal[2]
Coreresponding names of field from the data table to fetch informations.
Definition: service_json.h:69
parseJRequest
void parseJRequest(maps *, service *, json_object *, map *, maps **, maps **)
Parse Json Request.
Definition: service_json.c:1892
createNextLinks
int createNextLinks(maps *, json_object *)
Create the next links.
Definition: service_json.c:2891
maps
linked list of map pointer
Definition: service.h:678
rangeCorrespondances
static const char * rangeCorrespondances[4][2]
Equivalent range keywords for WPS version 1 and 2.
Definition: service_json.h:122
jsonIsFalse
bool jsonIsFalse(json_bool)
Trivial verification, check if a json_bool is equal to FALSE.
Definition: service_json.c:104
parseJson
json_object * parseJson(maps *, char *)
Parse a json string.
Definition: service_json.c:3111
map
KVP linked list.
Definition: service.h:657
printJobList
json_object * printJobList(maps **)
Print the jobs list.
Definition: service_json.c:2128
json_getStatusAttributes
void json_getStatusAttributes(maps *, map *, json_object *, int)
Fetch the statusFields attributes.
Definition: service_json.c:3174
pccRFields
static const char * pccRFields[3]
Corresponding fields available in WPS for pccFields.
Definition: service_json.h:113
json_getStatusFile
int json_getStatusFile(maps *)
Create the status file.
Definition: service_json.c:3391
createStatus
json_object * createStatus(maps *, int)
Create the json object for job status.
Definition: service_json.c:3232
serviceIsFilter
bool serviceIsFilter(maps *, char *)
Verify that a service name correspond to the Deploy or Undeploy service name.
Definition: service_json.c:4694
statusFieldsC
static const char * statusFieldsC[6]
Coreresponding names of field from the data table to fetch informations.
Definition: service_json.h:55
registry
Profile registry.
Definition: service.h:735
printGetCapabilitiesForProcessJ
void printGetCapabilitiesForProcessJ(registry *, maps *, void *, void *, service *)
Add all the capabilities properties to a json_object.
Definition: service_json.c:1016
printLiteralValueJ
void printLiteralValueJ(maps *, map *, map *, json_object *, const char *)
Add literal property depending on the dataType.
Definition: service_json.c:342
outputSingleJsonComplexRes
void outputSingleJsonComplexRes(maps *, maps *, json_object *, json_object *, char *, long)
Append required field to Json objects for a complex output.
Definition: service_json.c:2840
jsonToMap
map * jsonToMap(json_object *)
Convert a json object to map.
Definition: service_json.c:82
oapipStatus
static char oapipStatus[5][11]
Definitions of acceptable final status.
Definition: service_json.h:76