ZOO-Project
Macros | Functions | Variables
service_json.h File Reference
#include "response_print.h"
#include <stdio.h>
#include <ctype.h>
#include <service.h>
#include <json_object.h>
#include "json_c_version.h"

Go to the source code of this file.

Macros

#define JSON_C_TO_STRING_NOSLASHESCAPE   (1<<4)
 

Functions

mapsjsonToMaps (json_object *)
 Convert a json object to maps. More...
 
mapjsonToMap (json_object *)
 Convert a json object to map. More...
 
json_object * mapToJson (map *)
 Convert a map to a json object. More...
 
json_object * mapsToJson (maps *)
 Convert a maps to a json object. More...
 
json_object * serviceToJson (service *)
 Convert an service to a json object. More...
 
void printLiteralValueJ (maps *, map *, map *, json_object *, const char *)
 Add literal property depending on the dataType. More...
 
void printGetCapabilitiesForProcessJ (registry *, maps *, void *, void *, service *)
 Add all the capabilities properties to a json_object. More...
 
void printExceptionReportResponseJ (maps **, map *)
 Print an OWS ExceptionReport Document and HTTP headers (when required) depending on the code. More...
 
void parseJRequest (maps *, service *, json_object *, map *, maps **, maps **)
 Parse Json Request. More...
 
json_object * printJResult (maps **, service *, maps *, int)
 Print the result of an execution. More...
 
json_object * printJobStatus (maps **, char *)
 Print the jobs status info cf. More...
 
json_object * printJobList (maps **)
 Print the jobs list. More...
 
json_object * printFilteredJobList (maps **, map *)
 Print the filtered jobs list. More...
 
int createNextLinks (maps *, json_object *)
 Create the next links. More...
 
int createStatusFile (maps *, int)
 Create the status file. More...
 
void json_getStatusAttributes (maps *, map *, json_object *, int)
 Fetch the statusFields attributes. More...
 
json_object * createStatus (maps *, int)
 Create the json object for job status. More...
 
char * json_getStatusFilePath (maps *)
 Get the status file path. More...
 
json_object * parseJson (maps *, char *)
 Parse a json string. More...
 
json_object * json_readFile (maps *, char *)
 Read a json file. More...
 
char * getResultPath (maps *, char *)
 Get the result path. More...
 
int json_getStatusFile (maps *)
 Create the status file. More...
 
void produceApi (maps *, json_object *)
 Produce the JSON object for /api. More...
 
void produceRoot (maps *, json_object *)
 Produce the JSON response for /. More...
 
void produceConformances (maps *, json_object *)
 Produce the JSON response for /conformance. More...
 
void outputSingleJsonComplexRes (maps *, maps *, json_object *, json_object *, char *, long)
 Append required field to Json objects for a complex output. More...
 
bool jsonIsFalse (json_bool)
 Trivial verification, check if a json_bool is equal to FALSE. More...
 
bool serviceIsFilter (maps *, char *)
 Verify that a service name correspond to the Deploy or Undeploy service name. More...
 

Variables

static const char * statusFields [6]
 Names of field to output in the status object. More...
 
static const char * statusFieldsC [6]
 Coreresponding names of field from the data table to fetch informations. More...
 
static const char * statusSearchFields [2]
 Coreresponding names of field from the data table to fetch informations. More...
 
static const char * statusSearchFieldsReal [2]
 Coreresponding names of field from the data table to fetch informations. More...
 
static char oapipStatus [5][11]
 Definitions of acceptable final status. More...
 
static const char * jcapabilities []
 Name and corresponding attributes depending on the WPS version. More...
 
static const char * pccFields [9]
 Possible field names corresponding to pccRFields. More...
 
static const char * pccRFields [3]
 Corresponding fields available in WPS for pccFields. More...
 
static const char * rangeCorrespondances [4][2]
 Equivalent range keywords for WPS version 1 and 2. More...
 

Macro Definition Documentation

◆ JSON_C_TO_STRING_NOSLASHESCAPE

#define JSON_C_TO_STRING_NOSLASHESCAPE   (1<<4)

Function Documentation

◆ createNextLinks()

int createNextLinks ( maps pmsConf,
json_object *  obj 
)

Create the next links.

Parameters
pmsConfthe 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

◆ createStatus()

json_object* createStatus ( maps pmsConf,
int  status 
)

Create the json object for job status.

Parameters
pmsConfthe conf maps containing the main.cfg settings
statusinteger
Returns
the created json_object

◆ createStatusFile()

int createStatusFile ( maps pmsConf,
int  status 
)

Create the status file.

Parameters
pmsConfthe 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)

◆ getResultPath()

char* getResultPath ( maps pmsConf,
char *  jobId 
)

Get the result path.

Parameters
pmsConfthe conf maps containing the main.cfg settings
jobIdthe job identifier
Returns
the full path to the result file

◆ json_getStatusAttributes()

void json_getStatusAttributes ( maps pmsConf,
map pmSessId,
json_object *  pjoRes,
int  iStatus 
)

Fetch the statusFields attributes.

Parameters
pmsConfthe conf maps containing the main.cfg settings
pmSessIdthe map pointer to the session id
pjoResthe object to store metadata informations
iStatusinteger of the current execution status
See also
statusFields,

◆ json_getStatusFile()

int json_getStatusFile ( maps pmsConf)

Create the status file.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
Returns
an integer (0 in case of success, 1 in case of failure)

◆ json_getStatusFilePath()

char* json_getStatusFilePath ( maps pmsConf)

Get the status file path.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
Returns
a char* containing the full status file path

◆ json_readFile()

json_object* json_readFile ( maps pmsConf,
char *  filePath 
)

Read a json file.

Parameters
pmsConfthe conf maps containing the main.cfg settings @praam filePath the file path to read
Returns
a pointer to the created json_object

◆ jsonIsFalse()

bool jsonIsFalse ( json_bool  value)

Trivial verification, check if a json_bool is equal to FALSE.

Parameters
jbValuejson_bool value to verify if null
Returns
bool result of the test (jbValue==FALSE)

◆ jsonToMap()

map* jsonToMap ( json_object *  pjoObj)

Convert a json object to map.

Parameters
pjoObjthe json object to convert
Returns
the allocated map

◆ jsonToMaps()

maps* jsonToMaps ( json_object *  pjoObj)

Convert a json object to maps.

Parameters
pjoObjthe json object to convert
Returns
the allocated maps

◆ mapsToJson()

json_object* mapsToJson ( maps pmMap)

Convert a maps to a json object.

Parameters
pmMapthe maps to be converted into json object
Returns
a json_object pointer to the created json_object

◆ mapToJson()

json_object* mapToJson ( map pmMap)

Convert a map to a json object.

Parameters
pmMapthe map to be converted into json object
Returns
a json_object pointer to the created json_object

◆ outputSingleJsonComplexRes()

void outputSingleJsonComplexRes ( maps conf,
maps resu,
json_object *  pjoRes1,
json_object *  pjoRes3,
char *  pcValue,
long  lLen 
)

Append required field to Json objects for a complex output.

Parameters
confmaps pointer to the main configuration maps
resumaps pointer to the output
pjoRes1json_object pointer to which the value field should be added
pjoRes3json_object pointer to the format object associated with pjoRes1
pcValuechar pointer to the value to be allocated
lLenlength of pcValue

◆ parseJRequest()

void parseJRequest ( maps pmsConf,
service s,
json_object *  pjoRequestBody,
map pmRequestInputs,
maps **  inputs,
maps **  outputs 
)

Parse Json Request.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
sthe current service metadata
pjoRequestBodythe JSON object of the request body
pmRequestInputsthe produced maps
inputsthe produced maps
outputsthe produced maps

◆ parseJson()

json_object* parseJson ( maps pmsConf,
char *  myString 
)

Parse a json string.

Parameters
pmsConfthe conf maps containing the main.cfg settings
myStringthe string containing the json content
Returns
a pointer to the created json_object

◆ printExceptionReportResponseJ()

void printExceptionReportResponseJ ( maps **  pmsConf,
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.

See also
createExceptionJ
Parameters
pmsConfthe 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)

◆ printFilteredJobList()

json_object* printFilteredJobList ( maps **  ppmsConf,
map pmRequestInputs 
)

Print the filtered jobs list.

Parameters
ppmsConfthe maps containing the settings of the main.cfg file
Returns
the JSON object pointer to the jobs list
See also
printJobList

◆ printGetCapabilitiesForProcessJ()

void printGetCapabilitiesForProcessJ ( registry reg,
maps pmsConf,
void *  doc0,
void *  nc0,
service serv 
)

Add all the capabilities properties to a json_object.

Parameters
regthe registry pointer
pmsConfthe 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

◆ printJobList()

json_object* printJobList ( maps **  ppmsConf)

Print the jobs list.

Parameters
ppmsConfthe maps containing the settings of the main.cfg file
Returns
the JSON object pointer to the jobs list

◆ printJobStatus()

json_object* printJobStatus ( maps **  ppmsConf,
char *  pcJobId 
)

Print the jobs status info cf.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
pcJobIdthe char pointer to the jobid
Returns
the JSON object pointer to the statusInfo

◆ printJResult()

json_object* printJResult ( maps **  ppmsConf,
service s,
maps result,
int  iRes 
)

Print the result of an execution.

Parameters
ppmsConfthe maps containing the settings of the main.cfg file
sservice pointer to metadata
resultoutputs of the service
iResthe status of execution SERVICE_FAILED/SERVICE_SUCCEEDED
Returns
the JSON object pointer to the result

◆ printLiteralValueJ()

void printLiteralValueJ ( maps pmConf,
map pmType,
map pmContent,
json_object *  pjoSchema,
const char *  pccFieldName 
)

Add literal property depending on the dataType.

Parameters
pmConfthe main configuration maps pointer
pmTypethe dataType map pointer
pmContentthe iotype content map pointer
pjoSchemathe json_object pointer to add the value
pccFieldNamethe field name string

◆ produceApi()

void produceApi ( maps pmsConf,
json_object *  pjoRes 
)

Produce the JSON object for /api.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
pjoResthe JSON object to populate

◆ produceConformances()

void produceConformances ( maps pmsConf,
json_object *  pjoRes 
)

Produce the JSON response for /conformance.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
pjoResthe JSON object to populate

◆ produceRoot()

void produceRoot ( maps pmsConf,
json_object *  pjoRes 
)

Produce the JSON response for /.

Parameters
pmsConfthe maps containing the settings of the main.cfg file
pjoResthe JSON object to populate

◆ serviceIsFilter()

bool serviceIsFilter ( maps pmsConf,
char *  pcService 
)

Verify that a service name correspond to the Deploy or Undeploy service name.

Parameters
pmsConfthe main configuration maps pointer
pcServicethe service name
Returns
true if the process name corresponds to a filter_in or filter_out; false otherwise

◆ serviceToJson()

json_object* serviceToJson ( service psService)

Convert an service to a json object.

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

Variable Documentation

◆ jcapabilities

const char* jcapabilities[]
static
Initial value:
={
"jobControlOptions","sync-execute async-execute dismiss",
"outputTransmission","value reference",
"jobControlOptions","async-execute dismiss"
}

Name and corresponding attributes depending on the WPS version.

◆ oapipStatus

char oapipStatus[5][11]
static
Initial value:
={
"successful",
"failed",
"running",
"dismissed",
"accepted"
}

Definitions of acceptable final status.

◆ pccFields

const char* pccFields[9]
static
Initial value:
={
"type",
"encoding",
"schema",
"mediaType",
"mediaEncoding",
"mediaSchema",
"contentMediaType",
"contentEncoding",
"contentSchema"
}

Possible field names corresponding to pccRFields.

See also
pccRFields

◆ pccRFields

const char* pccRFields[3]
static
Initial value:
={
"mimeType",
"encoding",
"schema"
}

Corresponding fields available in WPS for pccFields.

See also
pccFields

◆ rangeCorrespondances

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

Equivalent range keywords for WPS version 1 and 2.

◆ statusFields

const char* statusFields[6]
static
Initial value:
={
"type", "processID","created","started","finished","updated"
}

Names of field to output in the status object.

◆ statusFieldsC

const char* statusFieldsC[6]
static
Initial value:
={
"itype", "processid","creation_time","start_time","end_time","updated_time"
}

Coreresponding names of field from the data table to fetch informations.

◆ statusSearchFields

const char* statusSearchFields[2]
static
Initial value:
={
"processid","status"
}

Coreresponding names of field from the data table to fetch informations.

◆ statusSearchFieldsReal

const char* statusSearchFieldsReal[2]
static
Initial value:
={
"processid","fstate"
}

Coreresponding names of field from the data table to fetch informations.