QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsserverinterfaceimpl.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsseerversinterface.h
3  Interface class for exposing functions in QGIS Server for use by plugins
4  -------------------
5  begin : 2014-09-10
6  copyright : (C) 2014 by Alessandro Pasotti
7  email : a dot pasotti at itopen dot it
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 
20 #include "qgsserverinterfaceimpl.h"
21 #include "qgsconfigcache.h"
22 
25  : mCapabilitiesCache( capCache )
26  , mServiceRegistry( srvRegistry )
27  , mServerSettings( settings )
28 {
29  mRequestHandler = nullptr;
30 #ifdef HAVE_SERVER_PYTHON_PLUGINS
31  mAccessControls = new QgsAccessControl();
32  mCacheManager = new QgsServerCacheManager();
33 #endif
34 }
35 
36 QString QgsServerInterfaceImpl::getEnv( const QString &name ) const
37 {
38  return getenv( name.toLocal8Bit() );
39 }
40 
41 
43 {
44 #ifdef HAVE_SERVER_PYTHON_PLUGINS
45  delete mAccessControls;
46  delete mCacheManager;
47 #endif
48 }
49 
50 
52 {
53  mRequestHandler = nullptr;
54 }
55 
57 {
58  mRequestHandler = requestHandler;
59 }
60 
61 void QgsServerInterfaceImpl::setConfigFilePath( const QString &configFilePath )
62 {
63  mConfigFilePath = configFilePath;
64 }
65 
67 {
68  mFilters.insert( priority, filter );
69 }
70 
72 {
73  mFilters = *filters;
74 }
75 
78 {
79 #ifdef HAVE_SERVER_PYTHON_PLUGINS
80  mAccessControls->registerAccessControl( accessControl, priority );
81 #else
82  Q_UNUSED( accessControl )
83  Q_UNUSED( priority )
84 #endif
85 }
86 
89 {
90 #ifdef HAVE_SERVER_PYTHON_PLUGINS
91  mCacheManager->registerServerCache( serverCache, priority );
92 #else
93  Q_UNUSED( serverCache )
94  Q_UNUSED( priority )
95 #endif
96 }
97 
99 {
100  return mCacheManager;
101 }
102 
104 {
105  if ( mCapabilitiesCache )
106  {
107  mCapabilitiesCache->removeCapabilitiesDocument( path );
108  }
110 }
111 
113 {
114  return mServiceRegistry;
115 }
116 
118 {
119  return mServerSettings;
120 }
QgsServerCacheFilter
Class defining cache interface for QGIS Server plugins.
Definition: qgsservercachefilter.h:43
QgsServerInterfaceImpl::getEnv
QString getEnv(const QString &name) const override
Returns an enrironment variable, used to pass environment variables to Python.
Definition: qgsserverinterfaceimpl.cpp:36
QgsServerInterfaceImpl::serverSettings
QgsServerSettings * serverSettings() override
Returns the server settings.
Definition: qgsserverinterfaceimpl.cpp:117
QgsServerInterfaceImpl::setRequestHandler
void setRequestHandler(QgsRequestHandler *requestHandler) override
Set the request handler.
Definition: qgsserverinterfaceimpl.cpp:56
QgsConfigCache::removeEntry
void removeEntry(const QString &path)
Removes an entry from cache.
Definition: qgsconfigcache.cpp:169
QgsServerInterfaceImpl::registerServerCache
void registerServerCache(QgsServerCacheFilter *serverCache, int priority=0) override
Registers a server cache filter.
Definition: qgsserverinterfaceimpl.cpp:88
QgsCapabilitiesCache
A cache for capabilities xml documents (by configuration file path)
Definition: qgscapabilitiescache.h:35
QgsServerInterfaceImpl::requestHandler
QgsRequestHandler * requestHandler() override
Returns the QgsRequestHandler, to be used only in server plugins.
Definition: qgsserverinterfaceimpl.h:51
qgsconfigcache.h
QgsConfigCache::instance
static QgsConfigCache * instance()
Returns the current instance.
Definition: qgsconfigcache.cpp:26
QgsAccessControl::registerAccessControl
void registerAccessControl(QgsAccessControlFilter *accessControl, int priority=0)
Register an access control filter.
Definition: qgsaccesscontrol.cpp:204
QgsCapabilitiesCache::removeCapabilitiesDocument
void removeCapabilitiesDocument(const QString &path)
Remove capabilities document.
Definition: qgscapabilitiescache.cpp:86
QgsServerInterfaceImpl::serviceRegistry
QgsServiceRegistry * serviceRegistry() override
Returns the service registry.
Definition: qgsserverinterfaceimpl.cpp:112
QgsServerInterfaceImpl::filters
QgsServerFiltersMap filters() override
Returns the list of current QgsServerFilter.
Definition: qgsserverinterfaceimpl.h:53
QgsServerCacheManager::registerServerCache
void registerServerCache(QgsServerCacheFilter *serverCache, int priority=0)
Register a server cache filter.
Definition: qgsservercachemanager.cpp:201
QgsServerInterfaceImpl::QgsServerInterfaceImpl
QgsServerInterfaceImpl(QgsCapabilitiesCache *capCache, QgsServiceRegistry *srvRegistry, QgsServerSettings *serverSettings)
Constructor.
Definition: qgsserverinterfaceimpl.cpp:24
qgsserverinterfaceimpl.h
QgsServerInterfaceImpl::removeConfigCacheEntry
void removeConfigCacheEntry(const QString &path) override
Remove entry from config cache.
Definition: qgsserverinterfaceimpl.cpp:103
QgsServerSettings
Provides a way to retrieve settings by prioritizing according to environment variables,...
Definition: qgsserversettings.h:85
QgsServerFilter
Class defining I/O filters for QGIS Server and implemented in plugins.
Definition: qgsserverfilter.h:44
QgsServerInterfaceImpl::~QgsServerInterfaceImpl
~QgsServerInterfaceImpl() override
Definition: qgsserverinterfaceimpl.cpp:42
QgsServerCacheManager
A helper class that centralizes caches accesses given by all the server cache filter plugins.
Definition: qgsservercachemanager.h:41
QgsAccessControlFilter
Class defining access control interface for QGIS Server plugins.
Definition: qgsaccesscontrolfilter.h:51
QgsServerInterfaceImpl::registerFilter
void registerFilter(QgsServerFilter *filter, int priority=0) override
Register a QgsServerFilter.
Definition: qgsserverinterfaceimpl.cpp:66
QgsServerInterfaceImpl::setFilters
void setFilters(QgsServerFiltersMap *filters) override
Set the filters map.
Definition: qgsserverinterfaceimpl.cpp:71
QgsServerInterfaceImpl::cacheManager
QgsServerCacheManager * cacheManager() const override
Gets the helper over all the registered server cache filters.
Definition: qgsserverinterfaceimpl.cpp:98
QgsAccessControl
A helper class that centralizes restrictions given by all the access control filter plugins.
Definition: qgsaccesscontrol.h:37
QgsServerInterfaceImpl::registerAccessControl
void registerAccessControl(QgsAccessControlFilter *accessControl, int priority=0) override
Register an access control filter.
Definition: qgsserverinterfaceimpl.cpp:77
QgsServerInterfaceImpl::setConfigFilePath
void setConfigFilePath(const QString &configFilePath) override
Set the configuration file path.
Definition: qgsserverinterfaceimpl.cpp:61
QgsServerInterfaceImpl::configFilePath
QString configFilePath() override
Returns the configuration file path.
Definition: qgsserverinterfaceimpl.h:81
QgsServiceRegistry
QgsServiceRegistry Class defining the registry manager for QGIS server services.
Definition: qgsserviceregistry.h:50
QgsServerFiltersMap
QMultiMap< int, QgsServerFilter * > QgsServerFiltersMap
Definition: qgsserverfilter.h:89
QgsRequestHandler
This class is an interface hiding the details of reading input and writing output from/to a wms reque...
Definition: qgsrequesthandler.h:39
QgsServerInterfaceImpl::clearRequestHandler
void clearRequestHandler() override
Clear the request handler.
Definition: qgsserverinterfaceimpl.cpp:51