ZOO-Project: response_print.h Source File
ZOO-Project
response_print.h
Go to the documentation of this file.
1 /*
2  * Author : Gérald FENOY
3  *
4  * Copyright (c) 2009-2013 GeoLabs SARL
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_RESPONSE_PRINT_H
26 #define ZOO_RESPONSE_PRINT_H 1
27 
28 #pragma once
29 
33 #define DEFAULT_SERVICE_URL "http://www.zoo-project.org/"
34 
37 #define TIME_SIZE 40
38 
39 #include <libintl.h>
40 #include <locale.h>
41 
45 #define _(String) dgettext ("zoo-kernel",String)
46 
49 #define _ss(String) dgettext ("zoo-services",String)
50 
54 #define ZOO_LOCK_CREATE_FAILED -4
55 
58 #define ZOO_LOCK_ACQUIRE_FAILED -5
59 
62 #define ZOO_LOCK_RELEASE_FAILED -6
63 
64 #include <sys/stat.h>
65 #include <sys/types.h>
66 #ifndef WIN32
67 #include <sys/ipc.h>
68 #include <sys/shm.h>
69 #include <sys/sem.h>
70 #else
71 #include <direct.h>
72 #endif
73 #include <stdio.h>
74 #include <time.h>
75 #include <ctype.h>
76 #ifdef WIN32
77 #ifndef USE_RUBY
78 #include <unistd.h>
79 #endif
80 #endif
81 #ifndef WIN32
82 //#include <locale.h>
83 #include <locale.h> // knut: this appears to be a non-standard header file that has been removed in newer versions of glibc; it may be sufficient to include <locale.h> (see above)
84 #endif
85 
86 #include "service.h"
87 #include <openssl/sha.h>
88 #include <openssl/md5.h>
89 #include <openssl/hmac.h>
90 #include <openssl/evp.h>
91 #include <openssl/bio.h>
92 #include <openssl/buffer.h>
93 
94 #include <libxml/parser.h>
95 #include <libxml/xpath.h>
96 #include "cgic.h"
97 
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101 
104 #define ZOO_NS_MAX 10
105 
108 #define ZOO_DOC_MAX 20
109 
113  static char* SERVICE_URL;
114 
118  static xmlNsPtr usedNs[ZOO_NS_MAX];
122  static char* nsName[ZOO_NS_MAX];
126  static int nbNs=0;
130  static xmlDocPtr iDocs[ZOO_DOC_MAX];
134  static int nbDocs=0;
135 
139  static char wpsStatus[3][11]={
140  "Succeeded",
141  "Failed",
142  "Running"
143  };
147  static const char* schemas[2][8]={
148  {"1.0.0","http://www.opengis.net/ows/1.1","http://www.opengis.net/wps/1.0.0","http://schemas.opengis.net/wps/1.0.0","%s %s/wps%s_response.xsd","http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd","1.1.0"},
149  {"2.0.0","http://www.opengis.net/ows/2.0","http://www.opengis.net/wps/2.0","http://schemas.opengis.net/wps/2.0","http://www.opengis.net/wps/2.0 http://schemas.opengis.net/wps/2.0/wps.xsd","http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd","2.0.2","http://www.opengis.net/spec/wps/2.0/def/process-profile/"},
150  };
154  static int nbSupportedRequests=7;
158  static const char* requests[2][7]={
159  {"GetCapabilities","DescribeProcess","Execute",NULL},
160  {"GetCapabilities","DescribeProcess","Execute","GetStatus","GetResult","Dismiss",NULL},
161  };
165  static int nbReqIdentifier=2;
169  static int nbReqJob=3;
173  static const char* root_nodes[2][4]={
174  {"ProcessOfferings","ProcessDescriptions","ExecuteResponse",NULL},
175  {"Contents","ProcessOfferings","Result",NULL}
176  };
177 
181  static const char* capabilities[2][7]={
182  {
183  "Process",
184  "processVersion","1",
185  "storeSupported","true",
186  "statusSupported","true"
187  },
188  {
189  "ProcessSummary",
190  "processVersion","1.0.0",
191  "jobControlOptions","sync-execute async-execute dismiss",
192  "outputTransmission","value reference"
193  }
194  };
195 
196 
197  static const char* const aapccStatusCodes[][8] = {
198  {
199  "500 Not Implemented",
200  "OperationNotSupported",
201  "NoApplicableCode",
202  NULL
203  },
204  {
205  "400 Bad request",
206  "MissingParameterValue"
207  "InvalidParameterValue",
208  "InvalidUpdateSequence",
209  "OptionNotSupported",
210  "VersionNegotiationFailed",
211  "NoSuchMode",
212  NULL
213  },
214  {
215  "404 Not Found",
216  "NotFound",
217  "NoSuchProcess",
218  "NoSuchJob",
219  "ResultNotReady",
220  NULL
221  },
222  {
223  "500 Not Implemented",
224  NULL
225  }
226  };
227 
228  void addLangAttr(xmlNodePtr,maps*);
229 
230  void printHeaders(maps*);
231  void printSessionHeaders(maps*);
232 
233  int zooXmlSearchForNs(const char*);
234  int zooXmlAddNs(xmlNodePtr,const char*,const char*);
235  void zooXmlCleanupNs();
236 
237  int zooXmlAddDoc(xmlNodePtr,const char*,const char*);
238  void zooXmlCleanupDocs();
239 
240  const char* produceStatusString(maps*,map*);
242  xmlNodePtr createExceptionReportNode(maps*,map*,int);
243  void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*);
244  xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*,const char*,int);
245  xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*,const char*);
248  void printFullDescription(xmlDocPtr,int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int,int,const map*);
249  void printDocument(maps*,xmlDocPtr,int);
250  void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int);
251  void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*,int);
252  void* printRawdataOutput(maps*,maps*);
253  map* parseBoundingBox(const char*);
254  void printBoundingBox(xmlNsPtr,xmlNodePtr,map*);
255  void printBoundingBoxDocument(maps*,maps*,FILE*);
256  void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*);
257  void printStatusInfo(maps*,map*,char*);
258  void addAdditionalParameters(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int);
259  void addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int);
260 
261  char* produceFileUrl(service*,maps*,maps*,const char*, int);
262  void outputResponse(service*,maps*,maps*,map*,int,maps*,int);
263 
264  int errorException(maps *, const char *, const char *, const char*);
265 
266  xmlNodePtr soapEnvelope(maps*,xmlNodePtr);
267  int checkForSoapEnvelope(xmlDocPtr);
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 
273 #endif
#define ZOO_NS_MAX
Maximum number of XML namespaces.
Definition: response_print.h:104
xmlNodePtr printWPSHeader(xmlDocPtr, maps *, const char *, const char *, const char *, int)
Generate a WPS header.
Definition: response_print.c:343
void zooXmlCleanupDocs()
Free allocated memort to store XML documents.
Definition: response_print.c:292
static const char * schemas[2][8]
Definitions of schemas depending on the WPS version.
Definition: response_print.h:147
int zooXmlSearchForNs(const char *)
Search for an existing XML namespace in usedNS.
Definition: response_print.c:214
static xmlDocPtr iDocs[ZOO_DOC_MAX]
Array of xmlDocPtr storing XML docs.
Definition: response_print.h:130
void printIOType(xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, xmlNsPtr, elements *, maps *, const char *, int)
Generate XML nodes describing inputs or outputs metadata.
Definition: response_print.c:2262
map * parseBoundingBox(const char *)
Parse a BoundingBox string.
Definition: response_print.c:3134
void outputResponse(service *, maps *, maps *, map *, int, maps *, int)
Generate the output response (RawDataOutput or ResponseDocument)
Definition: response_print.c:2850
int errorException(maps *, const char *, const char *, const char *)
Print an OWS ExceptionReport.
Definition: response_print.c:2720
void printDescribeProcessForProcess(registry *, maps *, void *, void *, service *)
Generate a ProcessDescription node for a servie and add it to a given node.
Definition: response_print.c:1069
static int nbNs
Number of XML namespaces.
Definition: response_print.h:126
const char * produceStatusString(maps *, map *)
Produce the status string used in HTTP headers.
Definition: response_print.c:2542
static xmlNsPtr usedNs[ZOO_NS_MAX]
Array of xmlNsPtr storing all used XML namespace.
Definition: response_print.h:118
void zooXmlCleanupNs()
Free allocated memory to store used XML namespace.
Definition: response_print.c:258
static int nbSupportedRequests
Definitions of support requests (depending on the WPS version)
Definition: response_print.h:154
void printGetCapabilitiesForProcess(registry *, maps *, void *, void *, service *)
Generate a wps:Process node for a servie and add it to a given node.
Definition: response_print.c:706
void addLangAttr(xmlNodePtr, maps *)
Add a land attribute to a XML node.
Definition: response_print.c:170
static int nbDocs
Number of XML docs.
Definition: response_print.h:134
void addAdditionalParameters(map *, xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, int)
Add AdditionalParameters nodes to any existing node.
Definition: response_print.c:911
void printFullDescription(xmlDocPtr, int, elements *, const char *, xmlNsPtr, xmlNsPtr, xmlNodePtr, int, int, const map *)
Generate the required XML tree for the detailled metadata information of inputs or outputs...
Definition: response_print.c:1188
int checkForSoapEnvelope(xmlDocPtr)
int zooXmlAddNs(xmlNodePtr, const char *, const char *)
Add an XML namespace to the usedNS if it was not already used.
Definition: response_print.c:233
static const char * requests[2][7]
Definitions of requests depending on the WPS version.
Definition: response_print.h:158
void printBoundingBoxDocument(maps *, maps *, FILE *)
Print an ows:BoundingBox XML document.
Definition: response_print.c:3187
linked list of map pointer
Definition: main_conf_read.y:292
static const char * capabilities[2][7]
Name and corresponding attributes depending on the WPS version.
Definition: response_print.h:181
void printOutputDefinitions(xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, elements *, maps *, const char *)
Print a XML document.
Definition: response_print.c:2218
void printHeaders(maps *)
Print the HTTP headers based on a map.
Definition: response_print.c:89
void addMetadata(map *, xmlDocPtr, xmlNodePtr, xmlNsPtr, xmlNsPtr, int)
Add a Metadata node to any existing node.
Definition: response_print.c:824
static int nbReqJob
Definitions requests requiring jobid (only for WPS version 2.0.0)
Definition: response_print.h:169
KVP linked list.
Definition: service.h:244
static char wpsStatus[3][11]
Definitions of acceptable final status.
Definition: response_print.h:139
void printBoundingBox(xmlNsPtr, xmlNodePtr, map *)
Create required XML nodes for boundingbox and update the current XML node.
Definition: response_print.c:3082
void printDescription(xmlNodePtr, xmlNsPtr, const char *, map *, int)
Create XML node with basic ows metadata information (Identifier,Title,Abstract)
Definition: response_print.c:2509
static char * SERVICE_URL
Global char* to store the serverAddress value of the [main] section.
Definition: response_print.h:113
char * produceFileUrl(service *, maps *, maps *, const char *, int)
Produce a copy file and the corresponding url in case it is required Please, free the returned ressou...
Definition: response_print.c:2746
Metadata information about a full Service.
Definition: main_conf_read.y:329
void printProcessResponse(maps *, map *, int, service *, const char *, int, maps *, maps *)
Generate a wps:Execute XML document.
Definition: response_print.c:1865
xmlNodePtr soapEnvelope(maps *, xmlNodePtr)
Generate a SOAP Envelope node when required (if the isSoap key of the [main] section is set to true)...
Definition: response_print.c:309
Profile registry.
Definition: main_conf_read.y:349
void printDocument(maps *, xmlDocPtr, int)
Print a XML document.
Definition: response_print.c:2183
#define ZOO_DOC_MAX
Maximum number of XML docs.
Definition: response_print.h:108
void printExceptionReportResponse(maps *, map *)
Print an OWS ExceptionReport or exception.yaml Document and HTTP headers (when required) depending on...
Definition: response_print.c:2622
void printSessionHeaders(maps *)
Print the Set-Cookie header if necessary (conf["lenv"]["cookie"]) and save the session file...
Definition: response_print.c:109
xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr, maps *, const char *)
Generate a Capabilities header.
Definition: response_print.c:441
Metadata information about input or output.
Definition: main_conf_read.y:314
static const char *const aapccStatusCodes[][8]
Definition: response_print.h:197
xmlNodePtr createExceptionReportNode(maps *, map *, int)
Create an OWS ExceptionReport Node.
Definition: response_print.c:2641
static int nbReqIdentifier
Definitions requests requiring identifier (depending on the WPS version)
Definition: response_print.h:165
static char * nsName[ZOO_NS_MAX]
Array storing names of the used XML namespace.
Definition: response_print.h:122
void printStatusInfo(maps *, map *, char *)
Print a StatusInfo XML document.
Definition: response_print.c:3251
int zooXmlAddDoc(xmlNodePtr, const char *, const char *)
static const char * root_nodes[2][4]
Definitions of root node for response depending on the request and the WPS version.
Definition: response_print.h:173
void * printRawdataOutput(maps *, maps *)
Print one outputs as raw.
Definition: response_print.c:3025

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png