QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
server
services
wms
qgswmsserviceexception.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsserviceexception.h
3
------------------------
4
begin : June 13, 2006
5
copyright : (C) 2006 by Marco Hugentobler
6
email : marco dot hugentobler at karto dot baug dot ethz dot ch
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#ifndef QGSWMSSERVICEEXCEPTION_H
19
#define QGSWMSSERVICEEXCEPTION_H
20
21
#include "
qgsserverexception.h
"
22
#include "
qgswmsparameters.h
"
23
24
#include <QMetaEnum>
25
#include <QString>
26
27
using namespace
Qt::StringLiterals;
28
29
namespace
QgsWms
30
{
31
37
class
QgsServiceException
:
public
QgsOgcServiceException
38
{
39
Q_GADGET
40
41
public
:
47
enum
ExceptionCode
48
{
49
OGC_InvalidFormat
,
50
OGC_InvalidSRS
,
51
OGC_LayerNotDefined
,
52
OGC_StyleNotDefined
,
53
OGC_LayerNotQueryable
,
54
OGC_CurrentUpdateSequence
,
55
OGC_InvalidUpdateSequence
,
56
OGC_MissingDimensionValue
,
57
OGC_InvalidDimensionValue
,
58
OGC_InvalidPoint
,
// new in WMS 1.3.0
59
OGC_InvalidCRS
,
// new in WMS 1.3.0
60
OGC_OperationNotSupported
,
// new in WMS 1.3.0
61
QGIS_MissingParameterValue
,
62
QGIS_InvalidParameterValue
63
};
64
Q_ENUM(
ExceptionCode
)
65
66
73
QgsServiceException
( const QString &
code
, const QString &
message
, const QString &
locator
= QString(),
int
responseCode
= 200 )
74
:
QgsOgcServiceException
(
code
,
message
,
locator
,
responseCode
, u
"1.3.0"
_s )
75
{}
76
83
QgsServiceException
(
const
QString &
code
,
const
QString &
message
,
int
responseCode
)
84
:
QgsOgcServiceException
(
code
,
message
, QString(),
responseCode
, u
"1.3.0"
_s )
85
{}
86
94
QgsServiceException
(
ExceptionCode
code
,
const
QString &
message
,
int
responseCode
)
95
:
QgsServiceException
( formatCode(
code
),
message
, QString(),
responseCode
)
96
{}
97
105
QgsServiceException
(
ExceptionCode
code
,
const
QgsWmsParameter
¶meter,
int
responseCode
)
106
:
QgsServiceException
( formatCode(
code
), formatMessage(
code
, parameter ), QString(),
responseCode
)
107
{}
108
109
private
:
110
static
QString formatMessage(
ExceptionCode
code
,
const
QgsWmsParameter
¶meter )
111
{
112
const
QString name = parameter.
name
();
113
QString
message
;
114
115
switch
(
code
)
116
{
117
case
QgsServiceException::QGIS_MissingParameterValue
:
118
{
119
message
= u
"The %1 parameter is missing."
_s.arg( name );
120
break
;
121
}
122
case
QGIS_InvalidParameterValue
:
123
{
124
message
= u
"The %1 parameter is invalid."
_s.arg( name );
125
break
;
126
}
127
case
OGC_InvalidFormat
:
128
{
129
message
= u
"The format '%1' from %2 is not supported."
_s.arg( parameter.
toString
(), name );
130
break
;
131
}
132
case
OGC_InvalidSRS
:
133
{
134
message
= u
"The SRS is not valid."
_s;
135
break
;
136
}
137
case
OGC_InvalidCRS
:
138
{
139
message
= u
"The CRS is not valid."
_s;
140
break
;
141
}
142
case
OGC_LayerNotDefined
:
143
{
144
message
= u
"The layer '%1' does not exist."
_s.arg( parameter.
toString
() );
145
break
;
146
}
147
case
OGC_LayerNotQueryable
:
148
{
149
message
= u
"The layer '%1' is not queryable."
_s.arg( parameter.
toString
() );
150
break
;
151
}
152
case
OGC_InvalidPoint
:
153
{
154
message
= u
"The point '%1' from '%2' is invalid."
_s.arg( parameter.
toString
(), name );
155
break
;
156
}
157
case
OGC_StyleNotDefined
:
158
case
OGC_CurrentUpdateSequence
:
159
case
OGC_InvalidUpdateSequence
:
160
case
OGC_MissingDimensionValue
:
161
case
OGC_InvalidDimensionValue
:
162
case
OGC_OperationNotSupported
:
163
{
164
break
;
165
}
166
}
167
168
return
message
;
169
}
170
171
static
QString formatCode(
ExceptionCode
code
)
172
{
173
// get key as a string from enum
174
const
QMetaEnum metaEnum( QMetaEnum::fromType<QgsServiceException::ExceptionCode>() );
175
QString key = metaEnum.valueToKey(
code
);
176
177
// remove prefix
178
key.replace(
"OGC_"
_L1, QString() );
179
key.replace(
"QGIS_"
_L1, QString() );
180
181
return
key;
182
}
183
};
184
190
class
QgsSecurityException
:
public
QgsServiceException
191
{
192
public
:
199
QgsSecurityException
(
const
QString &
message
,
const
QString &
locator
= QString() )
200
:
QgsServiceException
( u
"Security"
_s,
message
,
locator
, 403 )
201
{}
202
};
203
209
class
QgsBadRequestException
:
public
QgsServiceException
210
{
211
public
:
218
QgsBadRequestException
(
ExceptionCode
code
,
const
QString &
message
)
219
:
QgsServiceException
(
code
,
message
, 400 )
220
{}
221
228
QgsBadRequestException
(
ExceptionCode
code
,
const
QgsWmsParameter
¶meter )
229
:
QgsServiceException
(
code
, parameter, 400 )
230
{}
231
};
232
}
// namespace QgsWms
233
234
#endif
QgsOgcServiceException::locator
QString locator() const
Returns the locator.
Definition
qgsserverexception.h:99
QgsOgcServiceException::message
QString message() const
Returns the exception message.
Definition
qgsserverexception.h:93
QgsOgcServiceException::code
QString code() const
Returns the exception code.
Definition
qgsserverexception.h:96
QgsOgcServiceException::QgsOgcServiceException
QgsOgcServiceException(const QString &code, const QString &message, const QString &locator=QString(), int responseCode=200, const QString &version=u"1.3.0"_s)
Construction.
Definition
qgsserverexception.cpp:47
QgsServerException::responseCode
int responseCode() const
Returns the return HTTP response code associated with this exception.
Definition
qgsserverexception.h:56
QgsServerParameterDefinition::toString
QString toString(bool defaultValue=false) const
Converts the parameter into a string.
Definition
qgsserverparameters.cpp:75
QgsWms::QgsBadRequestException::QgsBadRequestException
QgsBadRequestException(ExceptionCode code, const QgsWmsParameter ¶meter)
Constructor for QgsBadRequestException (HTTP error code 400).
Definition
qgswmsserviceexception.h:228
QgsWms::QgsBadRequestException::QgsBadRequestException
QgsBadRequestException(ExceptionCode code, const QString &message)
Constructor for QgsBadRequestException (HTTP error code 400).
Definition
qgswmsserviceexception.h:218
QgsWms::QgsSecurityException::QgsSecurityException
QgsSecurityException(const QString &message, const QString &locator=QString())
Constructor for QgsSecurityException (HTTP error code 403 with Security code name).
Definition
qgswmsserviceexception.h:199
QgsWms::QgsServiceException::QgsServiceException
QgsServiceException(ExceptionCode code, const QgsWmsParameter ¶meter, int responseCode)
Constructor for QgsServiceException (empty locator attribute).
Definition
qgswmsserviceexception.h:105
QgsWms::QgsServiceException::QgsServiceException
QgsServiceException(const QString &code, const QString &message, const QString &locator=QString(), int responseCode=200)
Constructor for QgsServiceException.
Definition
qgswmsserviceexception.h:73
QgsWms::QgsServiceException::QgsServiceException
QgsServiceException(const QString &code, const QString &message, int responseCode)
Constructor for QgsServiceException (empty locator attribute).
Definition
qgswmsserviceexception.h:83
QgsWms::QgsServiceException::ExceptionCode
ExceptionCode
Exception codes as defined in OGC scpecifications for WMS 1.1.1 and WMS 1.3.0.
Definition
qgswmsserviceexception.h:48
QgsWms::QgsServiceException::OGC_InvalidCRS
@ OGC_InvalidCRS
Definition
qgswmsserviceexception.h:59
QgsWms::QgsServiceException::OGC_CurrentUpdateSequence
@ OGC_CurrentUpdateSequence
Definition
qgswmsserviceexception.h:54
QgsWms::QgsServiceException::OGC_OperationNotSupported
@ OGC_OperationNotSupported
Definition
qgswmsserviceexception.h:60
QgsWms::QgsServiceException::OGC_InvalidUpdateSequence
@ OGC_InvalidUpdateSequence
Definition
qgswmsserviceexception.h:55
QgsWms::QgsServiceException::OGC_InvalidDimensionValue
@ OGC_InvalidDimensionValue
Definition
qgswmsserviceexception.h:57
QgsWms::QgsServiceException::OGC_MissingDimensionValue
@ OGC_MissingDimensionValue
Definition
qgswmsserviceexception.h:56
QgsWms::QgsServiceException::OGC_LayerNotDefined
@ OGC_LayerNotDefined
Definition
qgswmsserviceexception.h:51
QgsWms::QgsServiceException::QGIS_InvalidParameterValue
@ QGIS_InvalidParameterValue
Definition
qgswmsserviceexception.h:62
QgsWms::QgsServiceException::OGC_InvalidPoint
@ OGC_InvalidPoint
Definition
qgswmsserviceexception.h:58
QgsWms::QgsServiceException::OGC_StyleNotDefined
@ OGC_StyleNotDefined
Definition
qgswmsserviceexception.h:52
QgsWms::QgsServiceException::OGC_InvalidFormat
@ OGC_InvalidFormat
Definition
qgswmsserviceexception.h:49
QgsWms::QgsServiceException::OGC_LayerNotQueryable
@ OGC_LayerNotQueryable
Definition
qgswmsserviceexception.h:53
QgsWms::QgsServiceException::QGIS_MissingParameterValue
@ QGIS_MissingParameterValue
Definition
qgswmsserviceexception.h:61
QgsWms::QgsServiceException::OGC_InvalidSRS
@ OGC_InvalidSRS
Definition
qgswmsserviceexception.h:50
QgsWms::QgsServiceException::QgsServiceException
QgsServiceException(ExceptionCode code, const QString &message, int responseCode)
Constructor for QgsServiceException (empty locator attribute).
Definition
qgswmsserviceexception.h:94
QgsWms::QgsWmsParameter
WMS parameter received from the client.
Definition
qgswmsparameters.h:106
QgsWms::QgsWmsParameter::name
QString name() const
Returns the name of the parameter.
Definition
qgswmsparameters.cpp:200
QgsWms
Median cut implementation.
Definition
qgsdxfwriter.cpp:27
qgsserverexception.h
qgswmsparameters.h
Generated on
for QGIS API Documentation by
1.17.0