source: branches/prototype-v0/zoo-project/zoo-kernel/response_print.h @ 896

Last change on this file since 896 was 896, checked in by knut, 5 years ago

Added some recent changes from trunk (r889), including some new utility functions and exception handling and new (conditional) definition of type bool. Added some new logic concerning Python and Mono environment and search paths. Fixed problem with Mono updateStatus function. Changed response_print.h to #include locale.h unconditionally and xlocale.h conditionally; xlocale.h is non-standard and can probably be dropped.

  • Property svn:keywords set to Id
File size: 7.2 KB
Line 
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
30/**
31 * The default service url (overriden by serverAddress)
32 */
33#define DEFAULT_SERVICE_URL "http://www.zoo-project.org/"
34/**
35 * The time size
36 */
37#define TIME_SIZE 40
38
39#include <libintl.h>
40//#include <xlocale.h> //#include <xlocale>
41#include <locale.h>
42
43/**
44 * ZOO-Kernel internal messages translation function
45 */
46#define _(String) dgettext ("zoo-kernel",String)
47/**
48 * ZOO-Services messages translation function
49 */
50#define _ss(String) dgettext ("zoo-services",String)
51
52/**
53 * ZOO-Kernel was unable to create a lock
54 */
55#define ZOO_LOCK_CREATE_FAILED -4
56/**
57 * ZOO-Kernel was unable to acquire a lock
58 */
59#define ZOO_LOCK_ACQUIRE_FAILED -5
60/**
61 * ZOO-Kernel was unable to release a lock
62 */
63#define ZOO_LOCK_RELEASE_FAILED -6
64
65#include <sys/stat.h>
66#include <sys/types.h>
67#include "cgic.h"
68#ifndef WIN32
69#include <sys/ipc.h>
70#include <sys/shm.h>
71#include <sys/sem.h>
72#else
73#include <direct.h>
74#endif
75#include <stdio.h>
76#include <time.h>
77#include <ctype.h>
78#ifdef WIN32
79#ifndef USE_RUBY
80#include <unistd.h>
81#endif
82#endif
83#ifndef WIN32
84//#include <locale.h>
85#include <xlocale.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)
86#endif
87#include "ulinet.h"
88
89#include "service.h"
90#include <openssl/sha.h>
91#include <openssl/md5.h>
92#include <openssl/hmac.h>
93#include <openssl/evp.h>
94#include <openssl/bio.h>
95#include <openssl/buffer.h>
96
97#include <libxml/parser.h>
98#include <libxml/xpath.h>
99
100#ifdef __cplusplus
101extern "C" {
102#endif
103  /**
104   * Maximum number of XML namespaces
105   */
106#define ZOO_NS_MAX 10
107  /**
108   * Maximum number of XML docs
109   */
110#define ZOO_DOC_MAX 20
111
112  /**
113   * Global char* to store the serverAddress value of the [main] section
114   */
115  static char* SERVICE_URL;
116
117  /**
118   * Array of xmlNsPtr storing all used XML namespace
119   */
120  static xmlNsPtr usedNs[ZOO_NS_MAX];
121  /**
122   * Array storing names of the used XML namespace
123   */
124  static char* nsName[ZOO_NS_MAX];
125  /**
126   * Number of XML namespaces
127   */
128  static int nbNs=0;
129  /**
130   * Array of xmlDocPtr storing XML docs
131   */
132  static xmlDocPtr iDocs[ZOO_DOC_MAX];
133  /**
134   * Number of XML docs
135   */
136  static int nbDocs=0;
137
138  /**
139   * Definitions of acceptable final status
140   */
141  static char wpsStatus[3][11]={
142    "Succeeded",
143    "Failed",
144    "Running"
145  };
146  /**
147   * Definitions of schemas depending on the WPS version
148   */
149  static const char* schemas[2][8]={
150    {"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"},
151    {"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/"},
152  };
153  /**
154   * Definitions of support requests (depending on the WPS version)
155   */
156  static int nbSupportedRequests=7;
157  /**
158   * Definitions of requests depending on the WPS version
159   */
160  static const char* requests[2][7]={
161    {"GetCapabilities","DescribeProcess","Execute",NULL},
162    {"GetCapabilities","DescribeProcess","Execute","GetStatus","GetResult","Dismiss",NULL},
163  };
164  /**
165   * Definitions requests requiring identifier (depending on the WPS version)
166   */
167  static int nbReqIdentifier=2;
168  /**
169   * Definitions requests requiring jobid (only for WPS version 2.0.0)
170   */
171  static int nbReqJob=3;
172  /**
173   * Definitions of root node for response depending on the request and the WPS version
174   */
175  static const char root_nodes[2][4][20]={
176    {"ProcessOfferings","ProcessDescriptions","ExecuteResponse",NULL},
177    {"Contents","ProcessOfferings","Result",NULL}
178  };
179
180  /**
181   * Name and corresponding attributes depending on the WPS version
182   */
183  static const char* capabilities[2][7]={
184    {
185      "Process",
186      "processVersion","1",
187      "storeSupported","true",
188      "statusSupported","true"
189    },
190    {
191      "ProcessSummary",
192      "processVersion","1.0.0",
193      "jobControlOptions","sync-execute async-execute dismiss",
194      "outputTransmission","value reference"
195    }
196  };
197
198  void addLangAttr(xmlNodePtr,maps*);
199
200  void printHeaders(maps*);
201
202  int zooXmlSearchForNs(const char*);
203  int zooXmlAddNs(xmlNodePtr,const char*,const char*);
204  void zooXmlCleanupNs();
205
206  int zooXmlAddDoc(xmlNodePtr,const char*,const char*);
207  void zooXmlCleanupDocs();
208 
209  void printExceptionReportResponse(maps*,map*);
210  xmlNodePtr createExceptionReportNode(maps*,map*,int);
211  void printProcessResponse(maps*,map*,int,service*,const char*,int,maps*,maps*);
212  xmlNodePtr printWPSHeader(xmlDocPtr,maps*,const char*,const char*,const char*,int);
213  xmlNodePtr printGetCapabilitiesHeader(xmlDocPtr,maps*,const char*);
214  void printGetCapabilitiesForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*);
215  void printDescribeProcessForProcess(registry*,maps*,xmlDocPtr,xmlNodePtr,service*);
216  void printFullDescription(xmlDocPtr,int,elements*,const char*,xmlNsPtr,xmlNsPtr,xmlNodePtr,int,int,const map*);
217  void printDocument(maps*,xmlDocPtr,int);
218  void printDescription(xmlNodePtr,xmlNsPtr,const char*,map*,int);
219  void printIOType(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*,int);
220  map* parseBoundingBox(const char*);
221  void printBoundingBox(xmlNsPtr,xmlNodePtr,map*);
222  void printBoundingBoxDocument(maps*,maps*,FILE*);
223  void printOutputDefinitions(xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,elements*,maps*,const char*);
224  void printStatusInfo(maps*,map*,char*);
225  void addAdditionalParameters(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int);
226  void addMetadata(map*,xmlDocPtr,xmlNodePtr,xmlNsPtr,xmlNsPtr,int);
227
228  void outputResponse(service*,maps*,maps*,map*,int,maps*,int);
229
230  int errorException(maps *, const char *, const char *, const char*);
231
232  xmlNodePtr soapEnvelope(maps*,xmlNodePtr);
233  int checkForSoapEnvelope(xmlDocPtr);
234 
235#ifdef __cplusplus
236}
237#endif
238
239#endif
Note: See TracBrowser for help on using the repository browser.

Search

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