1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 """
31 This module contains old style exception handlers that use the OGC
32 namespace for exception reports (prior to OWS Common).
33 """
34
35 from eoxserver.core.util.xmltools import XMLEncoder
36 from eoxserver.services.exceptions import InvalidRequestException
37 from eoxserver.services.base import BaseExceptionHandler
38 from eoxserver.services.interfaces import (
39 ExceptionHandlerInterface, ExceptionEncoderInterface
40 )
41
43 """
44 Handler class for the OGC namespace.
45 """
46 REGISTRY_CONF = {
47 "name": "OGC Namespace Exception Handler",
48 "impl_id": "services.ogc.OGCExceptionHandler",
49 "registry_values": {
50 "services.interfaces.exception_scheme": "ogc"
51 }
52 }
53
57
60
61 - def _getContentType(self, exception):
62 return "application/vnd.ogc.se_xml"
63
64 OGCExceptionHandlerImplementation = ExceptionHandlerInterface.implement(OGCExceptionHandler)
65
67 """
68 Encoder class for OGC namespace exception reports.
69 """
70 REGISTRY_CONF = {
71 "name": "OGC Namespace Exception Report Encoder",
72 "impl_id": "services.ogc.OGCExceptionEncoder",
73 "registry_values": {
74 "services.interfaces.exception_scheme": "ogc"
75 }
76 }
77
79 return {
80 "ogc": "http://www.opengis.net/ogc",
81 "xsi": "http://www.w3.org/2001/XMLSchema-instance"
82 }
83
85 if locator is None:
86 element = self._makeElement("ogc", "ServiceExceptionReport", [
87 ("", "@version", "1.2.0"),
88 ("ogc", "ServiceException", [
89 ("", "@code", exception_code),
90 ("", "@@", exception_text)
91 ])
92 ])
93 else:
94 element = self._makeElement("ogc", "ServiceExceptionReport", [
95 ("", "@version", "1.2.0"),
96 ("ogc", "ServiceException", [
97 ("", "@code", exception_code),
98 ("", "@locator", locator),
99 ("", "@@", exception_text)
100 ])
101 ])
102
103 if self.schemas is not None:
104 schemas_location = " ".join(["%s %s"%(ns, location) for ns, location in self.schemas.iteritems()])
105 element.setAttributeNS(self.ns_dict["xsi"], "%s:%s" % ("xsi", "schemaLocation"), schemas_location)
106
107 return element
108
110 return self.encodeExceptionReport(
111 exception.msg,
112 exception.error_code,
113 exception.locator
114 )
115
118
121
122 OGCExceptionEncoderImplementation = ExceptionEncoderInterface.implement(OGCExceptionEncoder)
123