Skip to content

Commit a80497e

Browse files
committed
Clean WMS service
- Remove "transitional" code - Remove duplicated code (or functionaly equivalent code) - Remove dead code - Sanitize error checking - Ensure correct build with HAVE_SERVER_PYTHON_PLUGINS not defined
1 parent d0a4697 commit a80497e

41 files changed

Lines changed: 1118 additions & 1199 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/server/CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ SET ( qgis_mapserv_SRCS
5252
qgsfcgiserverresponse.cpp
5353
qgsbufferserverresponse.cpp
5454
qgsfilterresponsedecorator.cpp
55+
qgsserverinterface.cpp
56+
qgsserverinterfaceimpl.cpp
5557
qgsfilterrestorer.cpp
5658
#----------------------------
5759
)
@@ -98,11 +100,9 @@ SET(qgis_mapserv_MOC_HDRS ${qgis_mapserv_MOC_HDRS})
98100
IF (WITH_SERVER_PLUGINS)
99101
SET(qgis_mapserv_SRCS ${qgis_mapserv_SRCS}
100102
qgsserverplugins.cpp
101-
qgsserverinterface.cpp
102103
qgsserverfilter.cpp
103104
qgsaccesscontrolfilter.cpp
104105
qgsaccesscontrol.cpp
105-
qgsserverinterfaceimpl.cpp
106106
)
107107
ENDIF (WITH_SERVER_PLUGINS)
108108

‎src/server/qgsconfigcache.cpp‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ QgsServerProjectParser* QgsConfigCache::serverConfiguration( const QString& file
7979

8080
QgsWCSProjectParser *QgsConfigCache::wcsConfiguration(
8181
const QString& filePath
82-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
8382
, const QgsAccessControl* accessControl
84-
#endif
8583
)
8684
{
8785
QgsWCSProjectParser *p = mWCSConfigCache.object( filePath );
@@ -94,9 +92,7 @@ QgsWCSProjectParser *QgsConfigCache::wcsConfiguration(
9492
}
9593
p = new QgsWCSProjectParser(
9694
filePath
97-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
9895
, accessControl
99-
#endif
10096
);
10197
mWCSConfigCache.insert( filePath, p );
10298
p = mWCSConfigCache.object( filePath );
@@ -109,9 +105,7 @@ QgsWCSProjectParser *QgsConfigCache::wcsConfiguration(
109105

110106
QgsWfsProjectParser *QgsConfigCache::wfsConfiguration(
111107
const QString& filePath
112-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
113108
, const QgsAccessControl* accessControl
114-
#endif
115109
)
116110
{
117111
QgsWfsProjectParser *p = mWFSConfigCache.object( filePath );
@@ -124,9 +118,7 @@ QgsWfsProjectParser *QgsConfigCache::wfsConfiguration(
124118
}
125119
p = new QgsWfsProjectParser(
126120
filePath
127-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
128121
, accessControl
129-
#endif
130122
);
131123
mWFSConfigCache.insert( filePath, p );
132124
p = mWFSConfigCache.object( filePath );
@@ -139,9 +131,7 @@ QgsWfsProjectParser *QgsConfigCache::wfsConfiguration(
139131

140132
QgsWmsConfigParser *QgsConfigCache::wmsConfiguration(
141133
const QString& filePath
142-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
143134
, const QgsAccessControl* accessControl
144-
#endif
145135
, const QMap<QString, QString>& parameterMap
146136
)
147137
{
@@ -165,9 +155,7 @@ QgsWmsConfigParser *QgsConfigCache::wmsConfiguration(
165155
{
166156
p = new QgsWmsProjectParser(
167157
filePath
168-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
169158
, accessControl
170-
#endif
171159
);
172160
}
173161
mWMSConfigCache.insert( filePath, p );

‎src/server/qgsconfigcache.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,15 @@ class SERVER_EXPORT QgsConfigCache : public QObject
4343
QgsServerProjectParser* serverConfiguration( const QString& filePath );
4444
QgsWCSProjectParser* wcsConfiguration(
4545
const QString& filePath
46-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
4746
, const QgsAccessControl* accessControl
48-
#endif
4947
);
5048
QgsWfsProjectParser* wfsConfiguration(
5149
const QString& filePath
52-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
5350
, const QgsAccessControl* accessControl
54-
#endif
5551
);
5652
QgsWmsConfigParser* wmsConfiguration(
5753
const QString& filePath
58-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
5954
, const QgsAccessControl* accessControl
60-
#endif
6155
, const QMap<QString, QString>& parameterMap = ( QMap< QString, QString >() )
6256
);
6357

‎src/server/qgsfilterrestorer.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
#include "qgsvectorlayer.h"
2121
#include "qgsvectordataprovider.h"
2222

23-
//! Apply filter from AccessControl
23+
#ifdef HAVE_SERVER_PYTHON_PLUGINS
24+
#include "qgsaccesscontrol.h"
25+
#endif
26+
27+
//! Apply filter from AccessControal
28+
#ifdef HAVE_SERVER_PYTHON_PLUGINS
2429
void QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( const QgsAccessControl* accessControl, QgsMapLayer* mapLayer,
2530
QHash<QgsMapLayer*, QString>& originalLayerFilters )
2631
{
@@ -45,6 +50,7 @@ void QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( const QgsAccess
4550
}
4651
}
4752
}
53+
#endif
4854

4955
//! Restore layer filter as original
5056
void QgsOWSServerFilterRestorer::restoreLayerFilters( const QHash<QgsMapLayer*, QString>& filterMap )

‎src/server/qgsfilterrestorer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#ifndef QGSFILTERRESTORER_H
1919
#define QGSFILTERRESTORER_H
2020

21-
#include "qgsaccesscontrol.h"
2221
#include "qgis_server.h"
2322

2423
#include <QHash>
2524

2625
class QgsMapLayer;
26+
class QgsAccessControl;
2727

2828
/** RAII class to restore layer filters on destruction
2929
*/

‎src/server/qgsserverinterfaceimpl.cpp‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache* capCache,
3131
#ifdef HAVE_SERVER_PYTHON_PLUGINS
3232
mAccessControls = new QgsAccessControl();
3333
#else
34-
mAccessControls = nullptr
34+
mAccessControls = nullptr;
3535
#endif
3636
}
3737

@@ -43,7 +43,9 @@ QString QgsServerInterfaceImpl::getEnv( const QString& name ) const
4343

4444
QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
4545
{
46+
#ifdef HAVE_SERVER_PYTHON_PLUGINS
4647
delete mAccessControls;
48+
#endif
4749
}
4850

4951

@@ -75,10 +77,12 @@ void QgsServerInterfaceImpl::setFilters( QgsServerFiltersMap* filters )
7577
//! Register a new access control filter
7678
void QgsServerInterfaceImpl::registerAccessControl( QgsAccessControlFilter* accessControl, int priority )
7779
{
78-
if ( mAccessControls )
79-
{
80-
mAccessControls->registerAccessControl( accessControl, priority );
81-
}
80+
#ifdef HAVE_SERVER_PYTHON_PLUGINS
81+
mAccessControls->registerAccessControl( accessControl, priority );
82+
#else
83+
Q_UNUSED( accessControl );
84+
Q_UNUSED( priority );
85+
#endif
8286
}
8387

8488

‎src/server/qgswcsprojectparser.cpp‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@
3131

3232
QgsWCSProjectParser::QgsWCSProjectParser(
3333
const QString& filePath
34-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
3534
, const QgsAccessControl* as
36-
#endif
3735
)
38-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
39-
:
40-
mAccessControl( as )
41-
#endif
36+
: mAccessControl( as )
4237
{
38+
#ifndef HAVE_SERVER_PYTHON_PLUGINS
39+
Q_UNUSED( mAccessControl );
40+
#endif
4341
mProjectParser = QgsConfigCache::instance()->serverConfiguration( filePath );
4442
}
4543

‎src/server/qgswcsprojectparser.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@
2121
#include "qgsserverprojectparser.h"
2222
#include "qgis_server.h"
2323

24-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
2524
class QgsAccessControl;
26-
#endif
2725

2826
class SERVER_EXPORT QgsWCSProjectParser
2927
{
3028
public:
3129
QgsWCSProjectParser(
3230
const QString& filePath
33-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
3431
, const QgsAccessControl* ac
35-
#endif
3632
);
3733
~QgsWCSProjectParser();
3834

@@ -49,9 +45,7 @@ class SERVER_EXPORT QgsWCSProjectParser
4945

5046
private:
5147
QgsServerProjectParser* mProjectParser;
52-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
5348
const QgsAccessControl* mAccessControl;
54-
#endif
5549

5650
};
5751

‎src/server/qgswfsprojectparser.cpp‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626

2727
QgsWfsProjectParser::QgsWfsProjectParser(
2828
const QString& filePath
29-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
3029
, const QgsAccessControl* ac
31-
#endif
3230
)
33-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
34-
:
35-
mAccessControl( ac )
36-
#endif
31+
: mAccessControl( ac )
3732
{
33+
#ifndef HAVE_SERVER_PYTHON_PLUGINS
34+
Q_UNUSED( mAccessControl );
35+
#endif
3836
mProjectParser = QgsConfigCache::instance()->serverConfiguration( filePath );
3937
}
4038

‎src/server/qgswfsprojectparser.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,15 @@
2222
#include "qgis_server.h"
2323

2424

25-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
2625
class QgsAccessControl;
27-
#endif
2826

2927

3028
class SERVER_EXPORT QgsWfsProjectParser
3129
{
3230
public:
3331
QgsWfsProjectParser(
3432
const QString& filePath
35-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
3633
, const QgsAccessControl* ac
37-
#endif
3834
);
3935
~QgsWfsProjectParser();
4036

@@ -60,9 +56,7 @@ class SERVER_EXPORT QgsWfsProjectParser
6056

6157
private:
6258
QgsServerProjectParser* mProjectParser;
63-
#ifdef HAVE_SERVER_PYTHON_PLUGINS
6459
const QgsAccessControl* mAccessControl;
65-
#endif
6660

6761
};
6862

0 commit comments

Comments
 (0)