/
qgsserverinterfaceimpl.cpp
120 lines (101 loc) · 3.46 KB
/
qgsserverinterfaceimpl.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/***************************************************************************
qgsseerversinterface.h
Interface class for exposing functions in QGIS Server for use by plugins
-------------------
begin : 2014-09-10
copyright : (C) 2014 by Alessandro Pasotti
email : a dot pasotti at itopen dot it
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsserverinterfaceimpl.h"
#include "qgsconfigcache.h"
//! Constructor
QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache *capCache, QgsServiceRegistry *srvRegistry, QgsServerSettings *settings )
: mCapabilitiesCache( capCache )
, mServiceRegistry( srvRegistry )
, mServerSettings( settings )
{
mRequestHandler = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
mAccessControls = new QgsAccessControl();
mCacheManager = new QgsServerCacheManager();
#endif
}
QString QgsServerInterfaceImpl::getEnv( const QString &name ) const
{
return getenv( name.toLocal8Bit() );
}
QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
delete mAccessControls;
delete mCacheManager;
#endif
}
void QgsServerInterfaceImpl::clearRequestHandler()
{
mRequestHandler = nullptr;
}
void QgsServerInterfaceImpl::setRequestHandler( QgsRequestHandler *requestHandler )
{
mRequestHandler = requestHandler;
}
void QgsServerInterfaceImpl::setConfigFilePath( const QString &configFilePath )
{
mConfigFilePath = configFilePath;
}
void QgsServerInterfaceImpl::registerFilter( QgsServerFilter *filter, int priority )
{
mFilters.insert( priority, filter );
}
void QgsServerInterfaceImpl::setFilters( QgsServerFiltersMap *filters )
{
mFilters = *filters;
}
//! Register a new access control filter
void QgsServerInterfaceImpl::registerAccessControl( QgsAccessControlFilter *accessControl, int priority )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
mAccessControls->registerAccessControl( accessControl, priority );
#else
Q_UNUSED( accessControl );
Q_UNUSED( priority );
#endif
}
//! Register a new access control filter
void QgsServerInterfaceImpl::registerServerCache( QgsServerCacheFilter *serverCache, int priority )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
mCacheManager->registerServerCache( serverCache, priority );
#else
Q_UNUSED( serverCache );
Q_UNUSED( priority );
#endif
}
QgsServerCacheManager *QgsServerInterfaceImpl::cacheManager() const
{
return mCacheManager;
}
void QgsServerInterfaceImpl::removeConfigCacheEntry( const QString &path )
{
if ( mCapabilitiesCache )
{
mCapabilitiesCache->removeCapabilitiesDocument( path );
}
QgsConfigCache::instance()->removeEntry( path );
}
QgsServiceRegistry *QgsServerInterfaceImpl::serviceRegistry()
{
return mServiceRegistry;
}
QgsServerSettings *QgsServerInterfaceImpl::serverSettings()
{
return mServerSettings;
}