ZOO-Project
Functions | Variables
service_json.c File Reference
#include "service_json.h"
#include "json.h"
#include <errno.h>
#include "json_tokener.h"
#include "stdlib.h"
#include "mimetypes.h"
#include "server_internal.h"
#include "service_internal.h"
#include <dirent.h>

Functions

json_object * mapToJson (map *myMap)
 Convert a map to a json object. More...
 
json_object * mapsToJson (maps *myMap)
 Convert a maps to a json object. More...
 
json_object * elementsToJson (elements *myElements)
 Convert an elements to a json object. More...
 
json_object * serviceToJson (service *myService)
 Convert an service to a json object. More...
 
void printAllowedRangesJ (maps *m, iotype *iot, json_object *prop)
 Add Allowed Range properties to a json_object. More...
 
void printLiteralDataJ (maps *m, elements *in, json_object *input)
 Add literalDataDomains property to a json_object. More...
 
void printFormatJ (maps *m, iotype *iot, json_object *res, bool isDefault, map *maxSize)
 Add Format properties to a json_object. More...
 
void printJAdditionalParameters (maps *conf, map *meta, json_object *doc)
 Add additionalParameters property to a json_object. More...
 
void printJMetadata (maps *conf, map *meta, json_object *doc)
 Add metadata property to a json_object. More...
 
void printIOTypeJ (maps *m, const char *io, elements *in, json_object *inputs, service *serv)
 Add metadata properties to a json_object. More...
 
void printGetCapabilitiesForProcessJ (registry *reg, maps *m, void *doc0, void *nc0, service *serv)
 Add all the capabilities properties to a json_object. More...
 
void printExceptionReportResponseJ (maps *m, map *s)
 Print an OWS ExceptionReport Document and HTTP headers (when required) depending on the code. More...
 
void parseJLiteral (maps *conf, json_object *req, elements *element, maps *output)
 Parse LiteralData value. More...
 
void parseJComplex (maps *conf, json_object *req, elements *element, maps *output, const char *name)
 Parse ComplexData value. More...
 
void parseJBoundingBox (maps *conf, json_object *req, elements *element, maps *output)
 Parse BoundingBox value. More...
 
void _parseJIOSingle (maps *conf, elements *cio, maps **ioMaps, const char *ioType, const char *key, json_object *val, maps *cMaps)
 Parse a single input / output entity. More...
 
void parseJIOSingle (maps *conf, elements *ioElements, maps **ioMaps, const char *ioType, const char *key, json_object *val)
 Parse a single input / output entity that can be an array. More...
 
void parseJIO (maps *conf, json_object *req, elements *ioElements, maps **ioMaps, const char *ioType)
 Parse all the inputs / outputs entities. More...
 
void parseJRequest (maps *conf, service *s, json_object *req, map *request_inputs, maps **inputs, maps **outputs)
 Parse Json Request. More...
 
json_object * printJobStatus (maps *pmsConf, char *pcJobId)
 Print the jobs status info cf. More...
 
json_object * printJobList (maps *conf)
 Print the jobs list. More...
 
json_object * printJResult (maps *conf, service *s, maps *result, int res)
 Print the result of an execution. More...
 
int createStatusLinks (maps *conf, int result, json_object *obj)
 Create the status links. More...
 
char * json_getStatusFilePath (maps *conf)
 Get the status file path. More...
 
char * getResultPath (maps *conf, char *jobId)
 
json_object * parseJson (maps *conf, char *myString)
 
json_object * json_readFile (maps *conf, char *filePath)
 
json_object * createStatus (maps *conf, int status)
 
int createStatusFile (maps *conf, int status)
 Create the status file. More...
 
int json_getStatusFile (maps *conf)
 Create the status file. More...
 
void produceApiInfo (maps *conf, json_object *res, json_object *res5)
 Produce the JSON object for api info object. More...
 
void addResponse (const map *useContent, json_object *res, const map *pmSchema, const map *pmType, const char *code, const char *msg)
 
void addParameter (maps *conf, const char *oName, const char *fName, const char *in, json_object *res)
 
void produceApiParameters (maps *conf, json_object *res)
 Produce the JSON object for api parameter. More...
 
void produceApiComponents (maps *conf, json_object *res)
 
void produceApi (maps *conf, json_object *res)
 Produce the JSON object for /api. More...
 

Variables

const char * rangeCorrespondances [4][2]
 Equivalent range keywords for WPS version 1 and 2. More...
 

Function Documentation

void _parseJIOSingle ( maps conf,
elements cio,
maps **  ioMaps,
const char *  ioType,
const char *  key,
json_object *  val,
maps cMaps 
)

Parse a single input / output entity.

Parameters
confthe maps containing the settings of the main.cfg file
ioElementsthe elements extracted from the zcfg
ioMapsthe produced maps containing inputs (or outputs)
ioTypethe char* set to inputs or outputs
keychar* the input/output name
valjson_object pointing to the input/output
cMapsthe outputed maps containing input (or output) metedata
void addParameter ( maps conf,
const char *  oName,
const char *  fName,
const char *  in,
json_object *  res 
)
void addResponse ( const map useContent,
json_object *  res,
const map pmSchema,
const map pmType,
const char *  code,
const char *  msg 
)
json_object* createStatus ( maps conf,
int  status 
)
int createStatusFile ( maps conf,
int  status 
)

Create the status file.

Parameters
confthe maps containing the settings of the main.cfg file
statusan integer (SERVICE_ACCEPTED,SERVICE_STARTED...)
Returns
an integer (0 in case of success, 1 in case of failure)
int createStatusLinks ( maps conf,
int  result,
json_object *  obj 
)

Create the status links.

Parameters
confthe maps containing the settings of the main.cfg file
resultan integer (>0 for adding the /result link)
objthe JSON object pointer to add the links to
Returns
0
json_object* elementsToJson ( elements myElements)

Convert an elements to a json object.

Parameters
myElementsthe elements pointer to be converted into a json object
Returns
a json_object pointer to the created json_object
char* getResultPath ( maps conf,
char *  jobId 
)
int json_getStatusFile ( maps conf)

Create the status file.

Parameters
confthe maps containing the settings of the main.cfg file
Returns
an integer (0 in case of success, 1 in case of failure)
char* json_getStatusFilePath ( maps conf)

Get the status file path.

Parameters
confthe maps containing the settings of the main.cfg file
Returns
a char* containing the full status file path
json_object* json_readFile ( maps conf,
char *  filePath 
)
json_object* mapsToJson ( maps myMap)

Convert a maps to a json object.

Parameters
myMapthe maps to be converted into json object
Returns
a json_object pointer to the created json_object
json_object* mapToJson ( map myMap)

Convert a map to a json object.

Parameters
myMapthe map to be converted into json object
Returns
a json_object pointer to the created json_object
void parseJBoundingBox ( maps conf,
json_object *  req,
elements element,
maps output 
)

Parse BoundingBox value.

Parameters
confthe maps containing the settings of the main.cfg file
reqjson_object pointing to the input/output
element
outputthe maps to set current json structure
void parseJComplex ( maps conf,
json_object *  req,
elements element,
maps output,
const char *  name 
)

Parse ComplexData value.

Parameters
confthe maps containing the settings of the main.cfg file
reqjson_object pointing to the input/output
element
outputthe maps to set current json structure
namethe name of the request from http_requests
void parseJIO ( maps conf,
json_object *  req,
elements ioElements,
maps **  ioMaps,
const char *  ioType 
)

Parse all the inputs / outputs entities.

Parameters
confthe maps containing the settings of the main.cfg file
reqjson_object pointing to the input/output
ioElementsthe elements extracted from the zcfg
ioMapsthe produced maps containing inputs (or outputs)
ioTypethe char* set to inputs or outputs
void parseJIOSingle ( maps conf,
elements ioElements,
maps **  ioMaps,
const char *  ioType,
const char *  key,
json_object *  val 
)

Parse a single input / output entity that can be an array.

Parameters
confthe maps containing the settings of the main.cfg file
ioElementsthe elements extracted from the zcfg
ioMapsthe produced maps containing inputs (or outputs)
ioTypethe char* set to inputs or outputs
keychar* the input/output name
valjson_object pointing to the input/output
void parseJLiteral ( maps conf,
json_object *  req,
elements element,
maps output 
)

Parse LiteralData value.

Parameters
confthe maps containing the settings of the main.cfg file
reqjson_object pointing to the input/output
element
outputthe maps to set current json structure
void parseJRequest ( maps conf,
service s,
json_object *  req,
map request_inputs,
maps **  inputs,
maps **  outputs 
)

Parse Json Request.

Parameters
confthe maps containing the settings of the main.cfg file
sthe current service metadata
reqthe JSON object of the request body
inputsthe produced maps
outputsthe produced maps
json_object* parseJson ( maps conf,
char *  myString 
)
void printAllowedRangesJ ( maps m,
iotype iot,
json_object *  prop 
)

Add Allowed Range properties to a json_object.

Parameters
mthe main configuration maps pointer
iotthe iotype pointer
propthe json_object pointer to add the allowed range properties
Returns
a json_object pointer to the created json_object
void printExceptionReportResponseJ ( maps m,
map s 
)

Print an OWS ExceptionReport Document and HTTP headers (when required) depending on the code.

Set hasPrinted value to true in the [lenv] section.

Parameters
mthe maps containing the settings of the main.cfg file
sthe map containing the text,code,locator keys (or a map array of the same keys)
void printFormatJ ( maps m,
iotype iot,
json_object *  res,
bool  isDefault,
map maxSize 
)

Add Format properties to a json_object.

Parameters
mthe main configuration maps pointer
iotthe current iotype pointer
resthe json_object pointer to add the properties to
isDefaultboolean specifying if the currrent iotype is default
maxSizea map pointer to the maximumMegabytes param defined in the zcfg file for this input/output
void printGetCapabilitiesForProcessJ ( registry reg,
maps m,
void *  doc0,
void *  nc0,
service serv 
)

Add all the capabilities properties to a json_object.

Parameters
refthe registry pointer
mthe main configuration maps pointer
doc0the void (json_object) pointer to add the property to
nc0the void (json_object) pointer to add the property to
servthe service pointer to extract the metadata from
void printIOTypeJ ( maps m,
const char *  io,
elements in,
json_object *  inputs,
service serv 
)

Add metadata properties to a json_object.

Parameters
mthe main configuration maps pointer
ioa string
inan elements pointer to the current input/output
inputsthe json_object pointer to add the property to
servthe service pointer to extract the metadata from
void printJAdditionalParameters ( maps conf,
map meta,
json_object *  doc 
)

Add additionalParameters property to a json_object.

Parameters
confthe main configuration maps pointer
metaa map pointer to the current metadata informations
docthe json_object pointer to add the property to
void printJMetadata ( maps conf,
map meta,
json_object *  doc 
)

Add metadata property to a json_object.

Parameters
confthe main configuration maps pointer
metaa map pointer to the current metadata informations
docthe json_object pointer to add the property to
json_object* printJobList ( maps conf)

Print the jobs list.

Parameters
confthe maps containing the settings of the main.cfg file
Returns
the JSON object pointer to the jobs list
json_object* printJobStatus ( maps pmsConf,
char *  pcJobId 
)

Print the jobs status info cf.

Parameters
confthe maps containing the settings of the main.cfg file
Returns
the JSON object pointer to the jobs list
json_object* printJResult ( maps conf,
service s,
maps result,
int  res 
)

Print the result of an execution.

Parameters
confthe maps containing the settings of the main.cfg file
sservice pointer to metadata
resultoutputs of the service
resthe status of execution SERVICE_FAILED/SERVICE_SUCCEEDED
Returns
the JSON object pointer to the result
void printLiteralDataJ ( maps m,
elements in,
json_object *  input 
)

Add literalDataDomains property to a json_object.

Parameters
mthe main configuration maps pointer
inthe elements pointer
inputthe json_object pointer to add the literalDataDomains property
Returns
a json_object pointer to the created json_object
void produceApi ( maps conf,
json_object *  res 
)

Produce the JSON object for /api.

Parameters
confthe maps containing the settings of the main.cfg file
resthe JSON object to populate
void produceApiComponents ( maps conf,
json_object *  res 
)
void produceApiInfo ( maps conf,
json_object *  res,
json_object *  res5 
)

Produce the JSON object for api info object.

Parameters
confthe maps containing the settings of the main.cfg file
resthe JSON object for the api info
void produceApiParameters ( maps conf,
json_object *  res 
)

Produce the JSON object for api parameter.

Parameters
confthe maps containing the settings of the main.cfg file
resthe JSON object to populate with the parameters
json_object* serviceToJson ( service myService)

Convert an service to a json object.

Parameters
myServicethe service pointer to be converted into a json object
Returns
a json_object pointer to the created json_object

Variable Documentation

const char* rangeCorrespondances[4][2]
Initial value:
={
{ "rangeMin", "minimumValue" },
{ "rangeMax", "maximumValue"},
{ "rangeSpacing", "spacing" },
{ "rangeClosure", "rangeClosure" }
}

Equivalent range keywords for WPS version 1 and 2.