QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsserver.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserver.cpp
3  A server application supporting WMS / WFS / WCS
4  -------------------
5  begin : July 04, 2006
6  copyright : (C) 2006 by Marco Hugentobler & Ionut Iosifescu Enescu
7  : (C) 2015 by Alessandro Pasotti
8  email : marco dot hugentobler at karto dot baug dot ethz dot ch
9  : elpaso at itopen dot it
10  ***************************************************************************/
11 
12 /***************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 
21 //for CMAKE_INSTALL_PREFIX
22 #include "qgsconfig.h"
23 #include "qgsserver.h"
24 #include "qgsauthmanager.h"
25 #include "qgscapabilitiescache.h"
26 #include "qgsfontutils.h"
27 #include "qgsrequesthandler.h"
28 #include "qgsproject.h"
29 #include "qgsproviderregistry.h"
30 #include "qgslogger.h"
31 #include "qgsmapserviceexception.h"
33 #include "qgsserverlogger.h"
34 #include "qgsserverrequest.h"
36 #include "qgsservice.h"
37 #include "qgsserverapi.h"
38 #include "qgsserverapicontext.h"
39 #include "qgsserverparameters.h"
40 #include "qgsapplication.h"
41 
42 #include <QDomDocument>
43 #include <QNetworkDiskCache>
44 #include <QSettings>
45 #include <QElapsedTimer>
46 
47 // TODO: remove, it's only needed by a single debug message
48 #include <fcgi_stdio.h>
49 #include <cstdlib>
50 
51 
52 
53 // Server status static initializers.
54 // Default values are for C++, SIP bindings will override their
55 // options in in init()
56 
57 QString *QgsServer::sConfigFilePath = nullptr;
58 QgsCapabilitiesCache *QgsServer::sCapabilitiesCache = nullptr;
59 QgsServerInterfaceImpl *QgsServer::sServerInterface = nullptr;
60 // Initialization must run once for all servers
61 bool QgsServer::sInitialized = false;
62 
63 QgsServiceRegistry *QgsServer::sServiceRegistry = nullptr;
64 
66 
68 {
69  // QgsApplication must exist
70  if ( qobject_cast<QgsApplication *>( qApp ) == nullptr )
71  {
72  qFatal( "A QgsApplication must exist before a QgsServer instance can be created." );
73  abort();
74  }
75  init();
76  mConfigCache = QgsConfigCache::instance();
77 }
78 
79 QFileInfo QgsServer::defaultAdminSLD()
80 {
81  return QFileInfo( QStringLiteral( "admin.sld" ) );
82 }
83 
84 void QgsServer::setupNetworkAccessManager()
85 {
86  QSettings settings;
88  QNetworkDiskCache *cache = new QNetworkDiskCache( nullptr );
89  qint64 cacheSize = sSettings()->cacheSize();
90  QString cacheDirectory = sSettings()->cacheDirectory();
91  cache->setCacheDirectory( cacheDirectory );
92  cache->setMaximumCacheSize( cacheSize );
93  QgsMessageLog::logMessage( QStringLiteral( "cacheDirectory: %1" ).arg( cache->cacheDirectory() ), QStringLiteral( "Server" ), Qgis::Info );
94  QgsMessageLog::logMessage( QStringLiteral( "maximumCacheSize: %1" ).arg( cache->maximumCacheSize() ), QStringLiteral( "Server" ), Qgis::Info );
95  nam->setCache( cache );
96 }
97 
98 QFileInfo QgsServer::defaultProjectFile()
99 {
100  QDir currentDir;
101  fprintf( FCGI_stderr, "current directory: %s\n", currentDir.absolutePath().toUtf8().constData() );
102  QStringList nameFilterList;
103  nameFilterList << QStringLiteral( "*.qgs" )
104  << QStringLiteral( "*.qgz" );
105  QFileInfoList projectFiles = currentDir.entryInfoList( nameFilterList, QDir::Files, QDir::Name );
106  for ( int x = 0; x < projectFiles.size(); x++ )
107  {
108  QgsMessageLog::logMessage( projectFiles.at( x ).absoluteFilePath(), QStringLiteral( "Server" ), Qgis::Info );
109  }
110  if ( projectFiles.isEmpty() )
111  {
112  return QFileInfo();
113  }
114  return projectFiles.at( 0 );
115 }
116 
117 void QgsServer::printRequestParameters( const QMap< QString, QString> &parameterMap, Qgis::MessageLevel logLevel )
118 {
119  if ( logLevel > Qgis::Info )
120  {
121  return;
122  }
123 
124  QMap< QString, QString>::const_iterator pIt = parameterMap.constBegin();
125  for ( ; pIt != parameterMap.constEnd(); ++pIt )
126  {
127  QgsMessageLog::logMessage( pIt.key() + ":" + pIt.value(), QStringLiteral( "Server" ), Qgis::Info );
128  }
129 }
130 
131 QString QgsServer::configPath( const QString &defaultConfigPath, const QString &configPath )
132 {
133  QString cfPath( defaultConfigPath );
134  QString projectFile = sSettings()->projectFile();
135  if ( !projectFile.isEmpty() )
136  {
137  cfPath = projectFile;
138  QgsDebugMsg( QStringLiteral( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
139  }
140  else
141  {
142  if ( configPath.isEmpty() )
143  {
144  // Read it from the environment, because a rewrite rule may have rewritten it
145  if ( getenv( "QGIS_PROJECT_FILE" ) )
146  {
147  cfPath = getenv( "QGIS_PROJECT_FILE" );
148  QgsMessageLog::logMessage( QStringLiteral( "Using configuration file path from environment: %1" ).arg( cfPath ), QStringLiteral( "Server" ), Qgis::Info );
149  }
150  else if ( ! defaultConfigPath.isEmpty() )
151  {
152  QgsMessageLog::logMessage( QStringLiteral( "Using default configuration file path: %1" ).arg( defaultConfigPath ), QStringLiteral( "Server" ), Qgis::Info );
153  }
154  }
155  else
156  {
157  cfPath = configPath;
158  QgsDebugMsg( QStringLiteral( "MAP:%1" ).arg( cfPath ) );
159  }
160  }
161  return cfPath;
162 }
163 
164 void QgsServer::initLocale()
165 {
166  // System locale override
167  if ( ! sSettings()->overrideSystemLocale().isEmpty() )
168  {
169  QLocale::setDefault( QLocale( sSettings()->overrideSystemLocale() ) );
170  }
171  // Number group separator settings
172  QLocale currentLocale;
173  if ( sSettings()->showGroupSeparator() )
174  {
175  currentLocale.setNumberOptions( currentLocale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
176  }
177  else
178  {
179  currentLocale.setNumberOptions( currentLocale.numberOptions() |= QLocale::NumberOption::OmitGroupSeparator );
180  }
181  QLocale::setDefault( currentLocale );
182 }
183 
184 bool QgsServer::init()
185 {
186  if ( sInitialized )
187  {
188  return false;
189  }
190 
191  QCoreApplication::setOrganizationName( QgsApplication::QGIS_ORGANIZATION_NAME );
192  QCoreApplication::setOrganizationDomain( QgsApplication::QGIS_ORGANIZATION_DOMAIN );
193  QCoreApplication::setApplicationName( QgsApplication::QGIS_APPLICATION_NAME );
194 
196 
197 #if defined(SERVER_SKIP_ECW)
198  QgsMessageLog::logMessage( "Skipping GDAL ECW drivers in server.", "Server", Qgis::Info );
200  QgsApplication::skipGdalDriver( "JP2ECW" );
201 #endif
202 
203  // reload settings to take into account QCoreApplication and QgsApplication
204  // configuration
205  sSettings()->load();
206 
207  // init and configure logger
209  QgsServerLogger::instance()->setLogLevel( sSettings()->logLevel() );
210  if ( ! sSettings()->logFile().isEmpty() )
211  {
212  QgsServerLogger::instance()->setLogFile( sSettings()->logFile() );
213  }
214  else if ( sSettings()->logStderr() )
215  {
217  }
218 
219  // Configure locale
220  initLocale();
221 
222  // log settings currently used
223  sSettings()->logSummary();
224 
225  setupNetworkAccessManager();
226  QDomImplementation::setInvalidDataPolicy( QDomImplementation::DropInvalidChars );
227 
228  // Instantiate the plugin directory so that providers are loaded
230  QgsMessageLog::logMessage( "Prefix PATH: " + QgsApplication::prefixPath(), QStringLiteral( "Server" ), Qgis::Info );
231  QgsMessageLog::logMessage( "Plugin PATH: " + QgsApplication::pluginPath(), QStringLiteral( "Server" ), Qgis::Info );
232  QgsMessageLog::logMessage( "PkgData PATH: " + QgsApplication::pkgDataPath(), QStringLiteral( "Server" ), Qgis::Info );
233  QgsMessageLog::logMessage( "User DB PATH: " + QgsApplication::qgisUserDatabaseFilePath(), QStringLiteral( "Server" ), Qgis::Info );
234  QgsMessageLog::logMessage( "Auth DB PATH: " + QgsApplication::qgisAuthDatabaseFilePath(), QStringLiteral( "Server" ), Qgis::Info );
235  QgsMessageLog::logMessage( "SVG PATHS: " + QgsApplication::svgPaths().join( QDir::listSeparator() ), QStringLiteral( "Server" ), Qgis::Info );
236 
237  QgsApplication::createDatabase(); //init qgis.db (e.g. necessary for user crs)
238 
239  // Initialize the authentication system
240  // creates or uses qgis-auth.db in ~/.qgis3/ or directory defined by QGIS_AUTH_DB_DIR_PATH env variable
241  // set the master password as first line of file defined by QGIS_AUTH_PASSWORD_FILE env variable
242  // (QGIS_AUTH_PASSWORD_FILE variable removed from environment after accessing)
244 
245  QString defaultConfigFilePath;
246  QFileInfo projectFileInfo = defaultProjectFile(); //try to find a .qgs/.qgz file in the server directory
247  if ( projectFileInfo.exists() )
248  {
249  defaultConfigFilePath = projectFileInfo.absoluteFilePath();
250  QgsMessageLog::logMessage( "Using default project file: " + defaultConfigFilePath, QStringLiteral( "Server" ), Qgis::Info );
251  }
252  else
253  {
254  QFileInfo adminSLDFileInfo = defaultAdminSLD();
255  if ( adminSLDFileInfo.exists() )
256  {
257  defaultConfigFilePath = adminSLDFileInfo.absoluteFilePath();
258  }
259  }
260  // Store the config file path
261  sConfigFilePath = new QString( defaultConfigFilePath );
262 
263  //create cache for capabilities XML
264  sCapabilitiesCache = new QgsCapabilitiesCache();
265 
266  QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Roman" ) << QStringLiteral( "Bold" ) );
267 
268  sServiceRegistry = new QgsServiceRegistry();
269 
270  sServerInterface = new QgsServerInterfaceImpl( sCapabilitiesCache, sServiceRegistry, sSettings() );
271 
272  // Load service module
273  QString modulePath = QgsApplication::libexecPath() + "server";
274  // qDebug() << QStringLiteral( "Initializing server modules from: %1" ).arg( modulePath );
275  sServiceRegistry->init( modulePath, sServerInterface );
276 
277  sInitialized = true;
278  QgsMessageLog::logMessage( QStringLiteral( "Server initialized" ), QStringLiteral( "Server" ), Qgis::Info );
279  return true;
280 }
281 
282 
283 
284 void QgsServer::putenv( const QString &var, const QString &val )
285 {
286  if ( val.isEmpty() )
287  {
288  qunsetenv( var.toUtf8().data() );
289  }
290  else
291  {
292  qputenv( var.toUtf8().data(), val.toUtf8() );
293  }
294  sSettings()->load( var );
295 }
296 
297 void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project )
298 {
300  QElapsedTimer time; //used for measuring request time if loglevel < 1
301 
302  qApp->processEvents();
303 
304  if ( logLevel == Qgis::Info )
305  {
306  time.start();
307  }
308 
309  response.clear();
310 
311  // Pass the filters to the requestHandler, this is needed for the following reasons:
312  // Allow server request to call sendResponse plugin hook if enabled
313  QgsFilterResponseDecorator responseDecorator( sServerInterface->filters(), response );
314 
315  //Request handler
316  QgsRequestHandler requestHandler( request, response );
317 
318  try
319  {
320  // TODO: split parse input into plain parse and processing from specific services
321  requestHandler.parseInput();
322  }
323  catch ( QgsMapServiceException &e )
324  {
325  QgsMessageLog::logMessage( "Parse input exception: " + e.message(), QStringLiteral( "Server" ), Qgis::Critical );
326  requestHandler.setServiceException( e );
327  }
328 
329  // Set the request handler into the interface for plugins to manipulate it
330  sServerInterface->setRequestHandler( &requestHandler );
331 
332  // Initialize configfilepath so that is is available
333  // before calling plugin methods
334  // Note that plugins may still change that value using
335  // setConfigFilePath() interface method
336  if ( ! project )
337  {
338  QString configFilePath = configPath( *sConfigFilePath, request.serverParameters().map() );
339  sServerInterface->setConfigFilePath( configFilePath );
340  }
341  else
342  {
343  sServerInterface->setConfigFilePath( project->fileName() );
344  }
345 
346  // Call requestReady() method (if enabled)
347  // This may also throw exceptions if there are errors in python plugins code
348  try
349  {
350  responseDecorator.start();
351  }
352  catch ( QgsException &ex )
353  {
354  // Internal server error
355  response.sendError( 500, QStringLiteral( "Internal Server Error" ) );
356  QgsMessageLog::logMessage( ex.what(), QStringLiteral( "Server" ), Qgis::Critical );
357  }
358 
359  // Plugins may have set exceptions
360  if ( !requestHandler.exceptionRaised() )
361  {
362  try
363  {
364  const QgsServerParameters params = request.serverParameters();
365  printRequestParameters( params.toMap(), logLevel );
366 
367  // Setup project (config file path)
368  if ( ! project )
369  {
370  QString configFilePath = configPath( *sConfigFilePath, params.map() );
371 
372  // load the project if needed and not empty
373  project = mConfigCache->project( configFilePath, sServerInterface->serverSettings() );
374  }
375 
376  // Set the current project instance
377  QgsProject::setInstance( const_cast<QgsProject *>( project ) );
378 
379  if ( project )
380  {
381  sServerInterface->setConfigFilePath( project->fileName() );
382  }
383 
384  // Dispatcher: if SERVICE is set, we assume a OWS service, if not, let's try an API
385  // TODO: QGIS 4 fix the OWS services and treat them as APIs
386  QgsServerApi *api = nullptr;
387  if ( params.service().isEmpty() && ( api = sServiceRegistry->apiForRequest( request ) ) )
388  {
389  QgsServerApiContext context { api->rootPath(), &request, &responseDecorator, project, sServerInterface };
390  api->executeRequest( context );
391  }
392  else
393  {
394 
395  // Project is mandatory for OWS at this point
396  if ( ! project )
397  {
398  throw QgsServerException( QStringLiteral( "Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file" ) );
399  }
400 
401  if ( ! params.fileName().isEmpty() )
402  {
403  const QString value = QString( "attachment; filename=\"%1\"" ).arg( params.fileName() );
404  requestHandler.setResponseHeader( QStringLiteral( "Content-Disposition" ), value );
405  }
406 
407  // Lookup for service
408  QgsService *service = sServiceRegistry->getService( params.service(), params.version() );
409  if ( service )
410  {
411  service->executeRequest( request, responseDecorator, project );
412  }
413  else
414  {
415  throw QgsOgcServiceException( QStringLiteral( "Service configuration error" ),
416  QStringLiteral( "Service unknown or unsupported. Current supported services (case-sensitive): WMS WFS WCS WMTS SampleService, or use a WFS3 (OGC API Features) endpoint" ) );
417  }
418  }
419  }
420  catch ( QgsServerException &ex )
421  {
422  responseDecorator.write( ex );
423  QString format;
424  QgsMessageLog::logMessage( ex.formatResponse( format ), QStringLiteral( "Server" ), Qgis::Warning );
425  }
426  catch ( QgsException &ex )
427  {
428  // Internal server error
429  response.sendError( 500, QStringLiteral( "Internal Server Error" ) );
430  QgsMessageLog::logMessage( ex.what(), QStringLiteral( "Server" ), Qgis::Critical );
431  }
432  }
433 
434  // Terminate the response
435  // This may also throw exceptions if there are errors in python plugins code
436  try
437  {
438  responseDecorator.finish();
439  }
440  catch ( QgsException &ex )
441  {
442  // Internal server error
443  response.sendError( 500, QStringLiteral( "Internal Server Error" ) );
444  QgsMessageLog::logMessage( ex.what(), QStringLiteral( "Server" ), Qgis::Critical );
445  }
446 
447 
448  // We are done using requestHandler in plugins, make sure we don't access
449  // to a deleted request handler from Python bindings
450  sServerInterface->clearRequestHandler();
451 
452  if ( logLevel == Qgis::Info )
453  {
454  QgsMessageLog::logMessage( "Request finished in " + QString::number( time.elapsed() ) + " ms", QStringLiteral( "Server" ), Qgis::Info );
455  }
456 }
457 
458 
459 #ifdef HAVE_SERVER_PYTHON_PLUGINS
460 void QgsServer::initPython()
461 {
462  // Init plugins
463  if ( ! QgsServerPlugins::initPlugins( sServerInterface ) )
464  {
465  QgsMessageLog::logMessage( QStringLiteral( "No server python plugins are available" ), QStringLiteral( "Server" ), Qgis::Info );
466  }
467  else
468  {
469  QgsMessageLog::logMessage( QStringLiteral( "Server python plugins loaded" ), QStringLiteral( "Server" ), Qgis::Info );
470  }
471 }
472 #endif
473 
QgsServiceRegistry::getService
QgsService * getService(const QString &name, const QString &version=QString())
Retrieve a service from its name.
Definition: qgsserviceregistry.cpp:89
QgsApplication::QGIS_ORGANIZATION_NAME
static const char * QGIS_ORGANIZATION_NAME
Definition: qgsapplication.h:151
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
QgsException
Defines a QGIS exception class.
Definition: qgsexception.h:35
QgsMapServiceException
Exception class for WMS service exceptions (for compatibility only).
Definition: qgsmapserviceexception.h:44
QgsServerApiContext
The QgsServerApiContext class encapsulates the resources for a particular client request: the request...
Definition: qgsserverapicontext.h:39
QgsCapabilitiesCache
A cache for capabilities xml documents (by configuration file path)
Definition: qgscapabilitiescache.h:35
QgsServerParameters::toMap
QMap< QString, QString > toMap() const
Returns all parameters in a map.
Definition: qgsserverparameters.cpp:504
QgsFilterResponseDecorator::start
void start() SIP_THROW(QgsServerException)
Call filters requestReady() method.
Definition: qgsfilterresponsedecorator.cpp:30
qgsserverparameters.h
qgsauthmanager.h
QgsServer::handleRequest
void handleRequest(QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project=nullptr)
Handles the request.
Definition: qgsserver.cpp:297
QgsServer::putenv
void putenv(const QString &var, const QString &val)
Set environment variable.
Definition: qgsserver.cpp:284
Qgis::Warning
@ Warning
Definition: qgis.h:91
QgsService
QgsService Class defining interfaces for QGIS server services.
Definition: qgsservice.h:40
QgsConfigCache::instance
static QgsConfigCache * instance()
Returns the current instance.
Definition: qgsconfigcache.cpp:26
QgsApplication::prefixPath
static QString prefixPath()
Returns the path to the application prefix directory.
Definition: qgsapplication.cpp:555
QgsServerApi::rootPath
virtual const QString rootPath() const =0
Returns the root path for the API.
QgsApplication::init
static void init(QString profileFolder=QString())
This method initializes paths etc for QGIS.
Definition: qgsapplication.cpp:198
QgsApplication::qgisAuthDatabaseFilePath
static QString qgisAuthDatabaseFilePath()
Returns the path to the user authentication database file: qgis-auth.db.
Definition: qgsapplication.cpp:1003
QgsApplication::svgPaths
static QStringList svgPaths()
Returns the paths to svg directories.
Definition: qgsapplication.cpp:1049
qgsservice.h
QgsServerResponse::clear
virtual void clear()=0
Reset all headers and content for this response.
qgsmapserviceexception.h
QgsServerRequest
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Definition: qgsserverrequest.h:39
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
qgsfontutils.h
QgsServerInterfaceImpl::filters
QgsServerFiltersMap filters() override
Returns the list of current QgsServerFilter.
Definition: qgsserverinterfaceimpl.h:53
QgsFilterResponseDecorator::finish
void finish() override
Finish the response, ending the transaction.
Definition: qgsfilterresponsedecorator.cpp:41
QgsService::executeRequest
virtual void executeRequest(const QgsServerRequest &request, QgsServerResponse &response, const QgsProject *project)=0
Execute the requests and set result in QgsServerRequest.
QgsServerInterfaceImpl
Interfaces exposed by QGIS Server and made available to plugins.
Definition: qgsserverinterfaceimpl.h:36
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsServerLogger::setLogLevel
void setLogLevel(Qgis::MessageLevel level)
Set the current log level.
Definition: qgsserverlogger.cpp:54
QgsApplication::skipGdalDriver
static void skipGdalDriver(const QString &driver)
Sets the GDAL_SKIP environment variable to include the specified driver and then calls GDALDriverMana...
Definition: qgsapplication.cpp:1664
QgsApplication::authManager
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
Definition: qgsapplication.cpp:1282
qgsapplication.h
QgsServerResponse::write
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
Definition: qgsserverresponse.cpp:25
QgsServerSettings
Provides a way to retrieve settings by prioritizing according to environment variables,...
Definition: qgsserversettings.h:85
QgsServiceRegistry::apiForRequest
QgsServerApi * apiForRequest(const QgsServerRequest &request) const
Searches the API register for an API matching the request and returns a (possibly NULL) pointer to it...
Definition: qgsserviceregistry.cpp:227
QgsServerParameters::version
QString version() const
Returns VERSION parameter as a string or an empty string if not defined.
Definition: qgsserverparameters.cpp:477
QgsServerLogger::instance
static QgsServerLogger * instance()
Gets the singleton instance.
Definition: qgsserverlogger.cpp:22
qgscapabilitiescache.h
QgsServerRequest::serverParameters
QgsServerParameters serverParameters() const
Returns parameters.
Definition: qgsserverrequest.cpp:90
QgsServiceRegistry::init
void init(const QString &nativeModulepath, QgsServerInterface *serverIface=nullptr)
Initialize registry, load modules and auto register services.
Definition: qgsserviceregistry.cpp:335
qgsserverrequest.h
Qgis::Info
@ Info
Definition: qgis.h:90
qgsproviderregistry.h
qgsserverapi.h
qgsnetworkaccessmanager.h
QgsProject::setInstance
static void setInstance(QgsProject *project)
Set the current project singleton instance to project.
Definition: qgsproject.cpp:462
QgsServerPlugins::initPlugins
static bool initPlugins(QgsServerInterface *interface)
Initializes the Python plugins.
Definition: qgsserverplugins.cpp:39
QgsException::what
QString what() const
Definition: qgsexception.h:48
QgsRequestHandler::parseInput
void parseInput()
Parses the input and creates a request neutral Parameter/Value map.
Definition: qgsrequesthandler.cpp:193
QgsApplication::createDatabase
static bool createDatabase(QString *errorMessage=nullptr)
initialize qgis.db
Definition: qgsapplication.cpp:1880
qgsserver.h
QgsApplication::QGIS_APPLICATION_NAME
static const char * QGIS_APPLICATION_NAME
Definition: qgsapplication.h:153
QgsServerParameters::service
QString service() const
Returns SERVICE parameter as a string or an empty string if not defined.
Definition: qgsserverparameters.cpp:487
QgsApplication::pkgDataPath
static QString pkgDataPath()
Returns the common root path of all application data directories.
Definition: qgsapplication.cpp:578
QgsProject::fileName
QString fileName
Definition: qgsproject.h:98
QgsRequestHandler::setResponseHeader
void setResponseHeader(const QString &name, const QString &value)
Sets an HTTP response header.
Definition: qgsrequesthandler.cpp:47
qgsserverlogger.h
QgsNetworkAccessManager
network access manager for QGIS
Definition: qgsnetworkaccessmanager.h:252
QgsOgcServiceException
Exception base class for service exceptions.
Definition: qgsserverexception.h:83
QgsNetworkAccessManager::instance
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
Definition: qgsnetworkaccessmanager.cpp:121
QgsFilterResponseDecorator
Class defining decorator for calling filter's hooks.
Definition: qgsfilterresponsedecorator.h:36
QgsServerLogger::setLogFile
void setLogFile(const QString &filename=QString())
Set the current log file.
Definition: qgsserverlogger.cpp:59
QgsServerParameters::map
QString map() const
Returns MAP parameter as a string or an empty string if not defined.
Definition: qgsserverparameters.cpp:472
QgsServerApi::executeRequest
virtual void executeRequest(const QgsServerApiContext &context) const =0
Executes a request by passing the given context to the API handlers.
QgsRequestHandler::exceptionRaised
bool exceptionRaised() const
Pointer to last raised exception.
Definition: qgsrequesthandler.cpp:42
Q_GLOBAL_STATIC
Q_GLOBAL_STATIC(QgsServerSettings, sSettings)
QgsFontUtils::loadStandardTestFonts
static bool loadStandardTestFonts(const QStringList &loadstyles)
Loads standard test fonts from filesystem or qrc resource.
Definition: qgsfontutils.cpp:225
QgsServerLogger::setLogStderr
void setLogStderr()
Activates logging to stderr.
Definition: qgsserverlogger.cpp:71
QgsRequestHandler::setServiceException
void setServiceException(const QgsServerException &ex)
Allow plugins to return a QgsMapServiceException.
Definition: qgsrequesthandler.cpp:145
Qgis::MessageLevel
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:89
QgsOgcServiceException::message
QString message() const
Returns the exception message.
Definition: qgsserverexception.h:94
QgsApplication::libexecPath
static QString libexecPath()
Returns the path with utility executables (help viewer, crssync, ...)
Definition: qgsapplication.cpp:1240
QgsServerException
Exception base class for server exceptions.
Definition: qgsserverexception.h:43
QgsServerInterfaceImpl::setConfigFilePath
void setConfigFilePath(const QString &configFilePath) override
Set the configuration file path.
Definition: qgsserverinterfaceimpl.cpp:61
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Definition: qgsmessagelog.cpp:27
QgsServiceRegistry
QgsServiceRegistry Class defining the registry manager for QGIS server services.
Definition: qgsserviceregistry.h:50
QgsServerLogger::logLevel
Qgis::MessageLevel logLevel() const
Gets the current log level.
Definition: qgsserverlogger.h:50
QgsApplication::qgisUserDatabaseFilePath
static QString qgisUserDatabaseFilePath()
Returns the path to the user qgis.db file.
Definition: qgsapplication.cpp:998
Qgis::Critical
@ Critical
Definition: qgis.h:92
QgsServer::QgsServer
QgsServer()
Creates the server instance.
Definition: qgsserver.cpp:67
QgsServerException::formatResponse
virtual QByteArray formatResponse(QString &responseFormat) const
Formats the exception for sending to client.
Definition: qgsserverexception.cpp:30
QgsServerParameters
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
Definition: qgsserverparameters.h:229
QgsRequestHandler
This class is an interface hiding the details of reading input and writing output from/to a wms reque...
Definition: qgsrequesthandler.h:39
QgsServerApi
Server generic API endpoint abstract base class.
Definition: qgsserverapi.h:81
QgsConfigCache::project
const QgsProject * project(const QString &path, QgsServerSettings *settings=nullptr)
If the project is not cached yet, then the project is read from the path.
Definition: qgsconfigcache.cpp:42
qgsrequesthandler.h
qgslogger.h
QgsServerParameters::fileName
QString fileName() const
Returns FILE_NAME parameter as a string or an empty string if not defined.
Definition: qgsserverparameters.cpp:482
QgsAuthManager::init
bool init(const QString &pluginPath=QString(), const QString &authDatabasePath=QString())
init initialize QCA, prioritize qca-ossl plugin and optionally set up the authentication database
Definition: qgsauthmanager.cpp:172
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsApplication::QGIS_ORGANIZATION_DOMAIN
static const char * QGIS_ORGANIZATION_DOMAIN
Definition: qgsapplication.h:152
qgsproject.h
QgsServerInterfaceImpl::clearRequestHandler
void clearRequestHandler() override
Clear the request handler.
Definition: qgsserverinterfaceimpl.cpp:51
QgsServerResponse::sendError
virtual void sendError(int code, const QString &message)=0
Send error This method delegates error handling at the server level.
QgsServerResponse
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
Definition: qgsserverresponse.h:44
qgsserverapicontext.h
QgsApplication::pluginPath
static QString pluginPath()
Returns the path to the application plugin directory.
Definition: qgsapplication.cpp:573
qgsfilterresponsedecorator.h