QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsserversettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsserversettings.cpp
3 ---------------------
4 begin : December 19, 2016
5 copyright : (C) 2016 by Paul Blottiere
6 email : paul dot blottiere at oslandia dot com
7
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#include "qgsserversettings.h"
20#include "moc_qgsserversettings.cpp"
21#include "qgsapplication.h"
22#include "qgsvariantutils.h"
23
24#include <QSettings>
25#include <QDir>
26
31
32void QgsServerSettings::initSettings()
33{
34 mSettings.clear();
35
36 // options path
37 const Setting sOptPath = { QgsServerSettingsEnv::QGIS_OPTIONS_PATH,
39 QStringLiteral( "Override the default path for user configuration" ),
40 QString(),
41 QMetaType::Type::QString,
42 QVariant( "" ),
43 QVariant()
44 };
45 mSettings[ sOptPath.envVar ] = sOptPath;
46
47 // parallel rendering
50 QStringLiteral( "Activate/Deactivate parallel rendering for WMS getMap request" ),
51 QStringLiteral( "/qgis/parallel_rendering" ),
52 QMetaType::Type::Bool,
53 QVariant( false ),
54 QVariant()
55 };
56 mSettings[ sParRend.envVar ] = sParRend;
57
58 // max threads
59 const Setting sMaxThreads = { QgsServerSettingsEnv::QGIS_SERVER_MAX_THREADS,
61 QStringLiteral( "Number of threads to use when parallel rendering is activated" ),
62 QStringLiteral( "/qgis/max_threads" ),
63 QMetaType::Type::Int,
64 QVariant( -1 ),
65 QVariant()
66 };
67 mSettings[ sMaxThreads.envVar ] = sMaxThreads;
68
69 // log level
70 const Setting sLogLevel = { QgsServerSettingsEnv::QGIS_SERVER_LOG_LEVEL,
72 QStringLiteral( "Log level" ),
73 QString(),
74 QMetaType::Type::Int,
75 QVariant::fromValue( Qgis::MessageLevel::NoLevel ),
76 QVariant()
77 };
78 mSettings[ sLogLevel.envVar ] = sLogLevel;
79
80 // log file
81 const Setting sLogFile = { QgsServerSettingsEnv::QGIS_SERVER_LOG_FILE,
83 QStringLiteral( "Log file" ),
84 QString(),
85 QMetaType::Type::QString,
86 QVariant( "" ),
87 QVariant()
88 };
89 mSettings[ sLogFile.envVar ] = sLogFile;
90
91 // log to stderr
92 const Setting sLogStderr = { QgsServerSettingsEnv::QGIS_SERVER_LOG_STDERR,
94 QStringLiteral( "Activate/Deactivate logging to stderr" ),
95 QString(),
96 QMetaType::Type::Bool,
97 QVariant( false ),
98 QVariant()
99 };
100 mSettings[ sLogStderr.envVar ] = sLogStderr;
101
102 // project file
103 const Setting sProject = { QgsServerSettingsEnv::QGIS_PROJECT_FILE,
105 QStringLiteral( "QGIS project file" ),
106 QString(),
107 QMetaType::Type::QString,
108 QVariant( "" ),
109 QVariant()
110 };
111 mSettings[ sProject.envVar ] = sProject;
112
113 // cache directory
114 const Setting sCacheDir = { QgsServerSettingsEnv::QGIS_SERVER_CACHE_DIRECTORY,
116 QStringLiteral( "Specify the cache directory" ),
117 QStringLiteral( "/cache/directory" ),
118 QMetaType::Type::QString,
119 QVariant( QgsApplication::qgisSettingsDirPath() + "cache" ),
120 QVariant()
121 };
122 mSettings[ sCacheDir.envVar ] = sCacheDir;
123
124 // cache size
125 const Setting sCacheSize = { QgsServerSettingsEnv::QGIS_SERVER_CACHE_SIZE,
127 QStringLiteral( "Specify the cache size (0 = automatic size)" ),
128 QStringLiteral( "/cache/size-bytes" ),
129 QMetaType::Type::LongLong,
130 0,
131 QVariant()
132 };
133 mSettings[ sCacheSize.envVar ] = sCacheSize;
134
135 // system locale override
136 const Setting sOverrideSystemLocale = { QgsServerSettingsEnv::QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE,
138 QStringLiteral( "Override system locale" ),
139 QStringLiteral( "/locale/userLocale" ),
140 QMetaType::Type::QString,
141 QVariant( "" ),
142 QVariant()
143 };
144 mSettings[ sOverrideSystemLocale.envVar ] = sOverrideSystemLocale;
145
146 // bad layers handling
147 const Setting sIgnoreBadLayers = { QgsServerSettingsEnv::QGIS_SERVER_IGNORE_BAD_LAYERS,
149 QStringLiteral( "Ignore bad layers" ),
150 QString(),
151 QMetaType::Type::Bool,
152 QVariant( false ),
153 QVariant()
154 };
155 mSettings[ sIgnoreBadLayers.envVar ] = sIgnoreBadLayers;
156
157 // trust layer metadata
158 const Setting sTrustLayerMetadata = { QgsServerSettingsEnv::QGIS_SERVER_TRUST_LAYER_METADATA,
160 QStringLiteral( "Trust layer metadata" ),
161 QString(),
162 QMetaType::Type::Bool,
163 QVariant( false ),
164 QVariant()
165 };
166 mSettings[ sTrustLayerMetadata.envVar ] = sTrustLayerMetadata;
167
168
169 // force to open layers in read-only mode
170 const Setting sForceReadOnlyLayers = { QgsServerSettingsEnv::QGIS_SERVER_FORCE_READONLY_LAYERS,
172 QStringLiteral( "Force to open layers in read-only mode" ),
173 QString(),
174 QMetaType::Type::Bool,
175 QVariant( false ),
176 QVariant()
177 };
178 mSettings[ sForceReadOnlyLayers.envVar ] = sForceReadOnlyLayers;
179
180 // don't load layouts
181 const Setting sDontLoadLayouts = { QgsServerSettingsEnv::QGIS_SERVER_DISABLE_GETPRINT,
183 QStringLiteral( "Don't load layouts" ),
184 QString(),
185 QMetaType::Type::Bool,
186 QVariant( false ),
187 QVariant()
188 };
189 mSettings[ sDontLoadLayouts.envVar ] = sDontLoadLayouts;
190
191 // show group separator
192 const Setting sShowGroupSeparator = { QgsServerSettingsEnv::QGIS_SERVER_SHOW_GROUP_SEPARATOR,
194 QStringLiteral( "Show group (thousands) separator" ),
195 QStringLiteral( "/locale/showGroupSeparator" ),
196 QMetaType::Type::QString,
197 QVariant( false ),
198 QVariant()
199 };
200 mSettings[ sShowGroupSeparator.envVar ] = sShowGroupSeparator;
201
202 // max height
203 const Setting sMaxHeight = { QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_HEIGHT,
205 QStringLiteral( "Maximum height for a WMS request. The lower one of this and the project configuration is used." ),
206 QStringLiteral( "/qgis/max_wms_height" ),
207 QMetaType::Type::LongLong,
208 QVariant( -1 ),
209 QVariant()
210 };
211 mSettings[ sMaxHeight.envVar ] = sMaxHeight;
212
213 // max width
214 const Setting sMaxWidth = { QgsServerSettingsEnv::QGIS_SERVER_WMS_MAX_WIDTH,
216 QStringLiteral( "Maximum width for a WMS request. The most conservative between this and the project one is used" ),
217 QStringLiteral( "/qgis/max_wms_width" ),
218 QMetaType::Type::LongLong,
219 QVariant( -1 ),
220 QVariant()
221 };
222 mSettings[ sMaxWidth.envVar ] = sMaxWidth;
223
224 // API templates and static override directory
225 const Setting sApiResourcesDirectory = { QgsServerSettingsEnv::QGIS_SERVER_API_RESOURCES_DIRECTORY,
227 QStringLiteral( "Base directory where HTML templates and static assets (e.g. images, js and css files) are searched for" ),
228 QStringLiteral( "/qgis/server_api_resources_directory" ),
229 QMetaType::Type::QString,
230 QDir( QgsApplication::pkgDataPath() ).absoluteFilePath( QStringLiteral( "resources/server/api" ) ),
231 QString()
232 };
233
234 mSettings[ sApiResourcesDirectory.envVar ] = sApiResourcesDirectory;
235
236 // API WFS3 max limit
237 const Setting sApiWfs3MaxLimit = { QgsServerSettingsEnv::QGIS_SERVER_API_WFS3_MAX_LIMIT,
239 QStringLiteral( "Maximum value for \"limit\" in a features request, defaults to 10000" ),
240 QStringLiteral( "/qgis/server_api_wfs3_max_limit" ),
241 QMetaType::Type::LongLong,
242 QVariant( 10000 ),
243 QVariant()
244 };
245
246 mSettings[ sApiWfs3MaxLimit.envVar ] = sApiWfs3MaxLimit;
247
248 // projects directory for landing page service
249 const Setting sProjectsDirectories = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES,
251 QStringLiteral( "Directories used by the landing page service to find .qgs and .qgz projects" ),
252 QStringLiteral( "/qgis/server_projects_directories" ),
253 QMetaType::Type::QString,
254 QVariant( "" ),
255 QVariant()
256 };
257
258 mSettings[ sProjectsDirectories.envVar ] = sProjectsDirectories;
259
260 // postgresql connection string for landing page service
261 const Setting sProjectsPgConnections = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS,
263 QStringLiteral( "PostgreSQL connection strings used by the landing page service to find projects" ),
264 QStringLiteral( "/qgis/server_projects_pg_connections" ),
265 QMetaType::Type::QString,
266 QVariant( "" ),
267 QVariant()
268 };
269
270 mSettings[ sProjectsPgConnections.envVar ] = sProjectsPgConnections;
271
272 // landing page base URL prefix
273 const Setting sLandingPageBaseUrlPrefix = { QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PREFIX,
275 QStringLiteral( "Landing page base URL path prefix" ),
276 QStringLiteral( "/qgis/server_landing_page_base_url_prefix" ),
277 QMetaType::Type::QString,
278 QVariant( "" ),
279 QVariant()
280 };
281
282 mSettings[ sLandingPageBaseUrlPrefix.envVar ] = sLandingPageBaseUrlPrefix;
283
284 // log profile
285 const Setting sLogProfile = { QgsServerSettingsEnv::QGIS_SERVER_LOG_PROFILE,
287 QStringLiteral( "Add detailed profile information to the logs, only effective when QGIS_SERVER_LOG_LEVEL=0" ),
288 QStringLiteral( "/qgis/server_log_profile" ),
289 QMetaType::Type::Bool,
290 QVariant( false ),
291 QVariant()
292 };
293
294 mSettings[ sLogProfile.envVar ] = sLogProfile;
295
296 // the default service URL.
297 const Setting sServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_SERVICE_URL,
299 QStringLiteral( "The default service URL" ),
300 QStringLiteral( "/qgis/server_service_url" ),
301 QMetaType::Type::QString,
302 QVariant( "" ),
303 QVariant()
304 };
305 mSettings[ sServiceUrl.envVar ] = sServiceUrl;
306
307 // the default WMS service URL.
308 const Setting sWmsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WMS_SERVICE_URL,
310 QStringLiteral( "The default WMS service URL" ),
311 QStringLiteral( "/qgis/server_wms_service_url" ),
312 QMetaType::Type::QString,
313 QVariant( "" ),
314 QVariant()
315 };
316 mSettings[ sServiceUrl.envVar ] = sWmsServiceUrl;
317
318 // the default WFS service URL.
319 const Setting sWfsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WFS_SERVICE_URL,
321 QStringLiteral( "The default WFS service URL" ),
322 QStringLiteral( "/qgis/server_wfs_service_url" ),
323 QMetaType::Type::QString,
324 QVariant( "" ),
325 QVariant()
326 };
327 mSettings[ sServiceUrl.envVar ] = sWfsServiceUrl;
328
329 // the default WCS service URL.
330 const Setting sWcsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WCS_SERVICE_URL,
332 QStringLiteral( "The default WcS service URL" ),
333 QStringLiteral( "/qgis/server_wcs_service_url" ),
334 QMetaType::Type::QString,
335 QVariant( "" ),
336 QVariant()
337 };
338 mSettings[ sServiceUrl.envVar ] = sWfsServiceUrl;
339
340 // the default WMTS service URL.
341 const Setting sWmtsServiceUrl = { QgsServerSettingsEnv::QGIS_SERVER_WMTS_SERVICE_URL,
343 QStringLiteral( "The default WMTS service URL" ),
344 QStringLiteral( "/qgis/server_wmts_service_url" ),
345 QMetaType::Type::QString,
346 QVariant( "" ),
347 QVariant()
348 };
349 mSettings[ sServiceUrl.envVar ] = sWmtsServiceUrl;
350
351 // the default config cache check interval
352 const Setting sConfigCacheCheckInterval = { QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL,
354 QStringLiteral( "The default project cache check interval (in ms)" ),
355 QStringLiteral( "/qgis/server_project_cache_check_interval" ),
356 QMetaType::Type::Int,
357 QVariant( 0 ),
358 QVariant()
359 };
360 mSettings[ sConfigCacheCheckInterval.envVar ] = sConfigCacheCheckInterval;
361
362 // the default config cache strategy
363 const Setting sProjectCacheStrategy = { QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_STRATEGY,
365 QStringLiteral( "Project's cache strategy. Possible values are 'off','filesystem' or 'periodic'" ),
366 QStringLiteral( "/qgis/server_project_cache_strategy" ),
367 QMetaType::Type::QString,
368 QVariant( "" ),
369 QVariant()
370 };
371 mSettings[ sProjectCacheStrategy.envVar ] = sProjectCacheStrategy;
372
373 const Setting sAllowedExtraSqlTokens = { QgsServerSettingsEnv::QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS,
375 QStringLiteral( "List of comma separated SQL tokens to be added to the list of allowed tokens that the services accepts when filtering features" ),
376 QStringLiteral( "/qgis/server_allowed_extra_sql_tokens" ),
377 QMetaType::Type::QString,
378 QVariant( "" ),
379 QVariant()
380 };
381 mSettings[ sAllowedExtraSqlTokens.envVar ] = sAllowedExtraSqlTokens;
382
383 const Setting sApplicationName = { QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME,
385 QStringLiteral( "The QGIS Server application name" ),
386 QStringLiteral( "/qgis/application_full_name" ),
387 QMetaType::Type::QString,
389 QVariant()
390 };
391 mSettings[ sApplicationName.envVar ] = sApplicationName;
392
393 const Setting sCapabilitiesCacheSize = { QgsServerSettingsEnv::QGIS_SERVER_CAPABILITIES_CACHE_SIZE,
395 QStringLiteral( "The QGIS Server capabilities cache size" ),
396 QStringLiteral( "/qgis/capabilities_cache_size" ),
397 QMetaType::Type::Int,
398 QVariant( 40 ),
399 QVariant()
400 };
401 mSettings[ sCapabilitiesCacheSize.envVar ] = sCapabilitiesCacheSize;
402}
403
405{
406 // init settings each time to take into account QgsApplication and
407 // QCoreApplication configuration for some default values
408 initSettings();
409
410 // store environment variables
411 QMap<QgsServerSettingsEnv::EnvVar, QString> env = getEnv();
412
413 // load QSettings if QGIS_OPTIONS_PATH is defined
414 loadQSettings( env[ QgsServerSettingsEnv::QGIS_OPTIONS_PATH ] );
415
416 // prioritize values: 'env var' -> 'ini file' -> 'default value'
417 prioritize( env );
418}
419
420bool QgsServerSettings::load( const QString &envVarName )
421{
422 bool rc( false );
423 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
424 const int value = metaEnum.keyToValue( envVarName.toStdString().c_str() );
425
426 if ( value >= 0 )
427 {
428 const QString envValue( getenv( envVarName.toStdString().c_str() ) );
429 prioritize( QMap<QgsServerSettingsEnv::EnvVar, QString> { {( QgsServerSettingsEnv::EnvVar ) value, envValue } } );
430 rc = true;
431 }
432
433 return rc;
434}
435
436QMap<QgsServerSettingsEnv::EnvVar, QString> QgsServerSettings::getEnv() const
437{
438 QMap<QgsServerSettingsEnv::EnvVar, QString> env;
439
440 const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
441 for ( int i = 0; i < metaEnum.keyCount(); i++ )
442 {
443 env[( QgsServerSettingsEnv::EnvVar ) metaEnum.value( i )] = getenv( metaEnum.key( i ) );
444 }
445
446 return env;
447}
448
449QVariant QgsServerSettings::value( QgsServerSettingsEnv::EnvVar envVar, bool actual ) const
450{
451 if ( actual )
452 {
453 const QString envValue( getenv( name( envVar ).toStdString().c_str() ) );
454
455 if ( ! envValue.isEmpty() )
456 return envValue;
457 }
458
459 if ( mSettings[ envVar ].src == QgsServerSettingsEnv::DEFAULT_VALUE )
460 {
461 return mSettings[ envVar ].defaultVal;
462 }
463 else
464 {
465 return mSettings[ envVar ].val;
466 }
467}
468
469void QgsServerSettings::loadQSettings( const QString &envOptPath ) const
470{
471 if ( ! envOptPath.isEmpty() )
472 {
473 QSettings::setDefaultFormat( QSettings::IniFormat );
474 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, envOptPath );
475 }
476}
477
478void QgsServerSettings::prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QString> &env )
479{
480 const auto constKeys( env.keys() );
481 for ( const QgsServerSettingsEnv::EnvVar &e : constKeys )
482 {
483 Setting s = mSettings[ e ];
484
485 QVariant varValue;
486 if ( ! env.value( e ).isEmpty() )
487 {
488 varValue.setValue( env.value( e ) );
489 }
490
491 if ( !QgsVariantUtils::isNull( varValue ) && varValue.canConvert( s.type ) )
492 {
493 s.val = varValue;
495 }
496 else if ( ! s.iniKey.isEmpty() && QSettings().contains( s.iniKey ) && QSettings().value( s.iniKey ).canConvert( s.type ) )
497 {
498 s.val = QSettings().value( s.iniKey );
500 }
501 else
502 {
503 s.val = QVariant();
505 }
506
507 // an empty string can be returned from QSettings. In this case, we want
508 // to use the default value
509 if ( s.type == QMetaType::Type::QString && s.val.toString().isEmpty() )
510 {
511 s.val = QVariant();
513 }
514
515 mSettings[ e ] = s;
516 }
517}
518
520{
521 const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
522 return metaEnumEnv.valueToKey( env );
523}
524
526{
527 const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );
528
529 QgsMessageLog::logMessage( "QGIS Server Settings: ", "Server", Qgis::MessageLevel::Info );
530 for ( const Setting &s : std::as_const( mSettings ) )
531 {
532 const QString src = metaEnumSrc.valueToKey( s.src );
533 const QString var = name( s.envVar );
534
535 const QString msg = " - " + var + " / '" + s.iniKey + "' (" + s.descr + "): '" + value( s.envVar ).toString() + "' (read from " + src + ")";
537 }
538
539 if ( ! iniFile().isEmpty() )
540 {
541 const QString msg = "Ini file used to initialize settings: " + iniFile();
543 }
544}
545
546// getter
548{
549 return QSettings().fileName();
550}
551
556
558{
559 return value( QgsServerSettingsEnv::QGIS_SERVER_MAX_THREADS ).toInt();
560}
561
563{
564 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_FILE ).toString();
565}
566
568{
569 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_STDERR ).toBool();
570}
571
576
578{
579 return value( QgsServerSettingsEnv::QGIS_PROJECT_FILE ).toString();
580}
581
583{
584 return value( QgsServerSettingsEnv::QGIS_SERVER_CACHE_SIZE ).toLongLong();
585}
586
588{
589 return value( QgsServerSettingsEnv::QGIS_SERVER_CACHE_DIRECTORY ).toString();
590}
591
596
601
606
611
616
621
626
631
633{
634 return value( QgsServerSettingsEnv::QGIS_SERVER_API_WFS3_MAX_LIMIT ).toLongLong();
635}
636
641
646
651
656
658{
659 return value( QgsServerSettingsEnv::QGIS_SERVER_LOG_PROFILE, false ).toBool();
660}
661
662QString QgsServerSettings::serviceUrl( const QString &service ) const
663{
664 QString result;
665 if ( service.compare( QLatin1String( "WMS" ) ) )
666 {
667 result = value( QgsServerSettingsEnv::QGIS_SERVER_WMS_SERVICE_URL ).toString();
668 }
669 else if ( service.compare( QLatin1String( "WFS" ) ) )
670 {
671 result = value( QgsServerSettingsEnv::QGIS_SERVER_WFS_SERVICE_URL ).toString();
672 }
673 else if ( service.compare( QLatin1String( "WCS" ) ) )
674 {
675 result = value( QgsServerSettingsEnv::QGIS_SERVER_WCS_SERVICE_URL ).toString();
676 }
677 else if ( service.compare( QLatin1String( "WMTS" ) ) )
678 {
679 result = value( QgsServerSettingsEnv::QGIS_SERVER_WMTS_SERVICE_URL ).toString();
680 }
681
682 if ( result.isEmpty() )
683 {
684 result = value( QgsServerSettingsEnv::QGIS_SERVER_SERVICE_URL ).toString();
685 }
686
687 return result;
688}
689
694
696{
697 QString result = value( QgsServerSettingsEnv::QGIS_SERVER_PROJECT_CACHE_STRATEGY ).toString();
698 if ( result.compare( QLatin1String( "filesystem" ) ) &&
699 result.compare( QLatin1String( "periodic" ) ) &&
700 result.compare( QLatin1String( "off" ) ) )
701 {
702 QgsMessageLog::logMessage( QStringLiteral( "Invalid cache strategy, expecting 'filesystem', 'periodic' or 'off'. Using 'filesystem' as default." ), "Server", Qgis::MessageLevel::Warning );
703 result = QStringLiteral( "filesystem" );
704 }
705 return result;
706}
707
709{
710 const QString strVal { value( QgsServerSettingsEnv::QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS ).toString().trimmed() };
711 if ( strVal.isEmpty() )
712 {
713 return QStringList();
714 }
715 return strVal.split( ',' );
716}
717
719{
720 return value( QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME ).toString().trimmed();
721}
722
724{
725 bool ok;
726 int size = value( QgsServerSettingsEnv::QGIS_SERVER_CAPABILITIES_CACHE_SIZE ).toInt( &ok );
727 if ( ok && size >= 1 )
728 return size;
729
730 QgsMessageLog::logMessage( QStringLiteral( "Invalid capabilities cache size, expecting integer - defaulting to 40" ), "Server", Qgis::MessageLevel::Warning );
731 return 40;
732}
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:154
@ NoLevel
No level.
Definition qgis.h:159
@ Warning
Warning message.
Definition qgis.h:156
@ Info
Information message.
Definition qgis.h:155
static QString pkgDataPath()
Returns the common root path of all application data directories.
static QString applicationFullName()
Returns the QGIS application full name.
static QString qgisSettingsDirPath()
Returns the path to the settings directory in user's home dir.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
EnvVar
Environment variables to configure the server.
@ QGIS_SERVER_WCS_SERVICE_URL
To set the WCS service URL if it's not present in the project.
@ QGIS_SERVER_WMTS_SERVICE_URL
To set the WMTS service URL if it's not present in the project.
@ QGIS_SERVER_IGNORE_BAD_LAYERS
Do not consider the whole project unavailable if it contains bad layers.
@ QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS
Adds these tokens to the list of allowed tokens that the services accept when filtering features.
@ QGIS_SERVER_CAPABILITIES_CACHE_SIZE
Define the QGIS Server capabilities cache size.
@ QGIS_SERVER_LANDING_PAGE_PREFIX
Prefix of the path component of the landing page base URL, default is empty.
@ QGIS_SERVER_TRUST_LAYER_METADATA
Trust layer metadata. Improves project read time.
@ QGIS_SERVER_WFS_SERVICE_URL
To set the WFS service URL if it's not present in the project.
@ QGIS_SERVER_OVERRIDE_SYSTEM_LOCALE
Override system locale.
@ QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS
PostgreSQL connection strings used by the landing page service to find projects.
@ QGIS_SERVER_API_WFS3_MAX_LIMIT
Maximum value for "limit" in a features request, defaults to 10000.
@ QGIS_SERVER_API_RESOURCES_DIRECTORY
Base directory where HTML templates and static assets (e.g. images, js and css files) are searched fo...
@ QGIS_SERVER_WMS_MAX_WIDTH
Maximum width for a WMS request. The most conservative between this and the project one is used.
@ QGIS_SERVER_FORCE_READONLY_LAYERS
Force to open layers in read-only mode.
@ QGIS_SERVER_PROJECT_CACHE_STRATEGY
Set the project cache strategy. Possible values are 'filesystem', 'periodic' or 'off'.
@ QGIS_SERVER_APPLICATION_NAME
Define the QGIS Server application name.
@ QGIS_SERVER_WMS_MAX_HEIGHT
Maximum height for a WMS request. The most conservative between this and the project one is used.
@ QGIS_SERVER_WMS_SERVICE_URL
To set the WMS service URL if it's not present in the project.
@ QGIS_SERVER_DISABLE_GETPRINT
Disabled WMS GetPrint request and don't load layouts. Improves project read time.
@ QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL
Set the interval in milliseconds for cache invalidation strategy 'interval', default to 0 which selec...
@ QGIS_SERVER_SHOW_GROUP_SEPARATOR
Show group (thousands) separator when formatting numeric values, defaults to false.
@ QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES
Directories used by the landing page service to find .qgs and .qgz projects.
@ QGIS_SERVER_LOG_PROFILE
When QGIS_SERVER_LOG_LEVEL is 0 this flag adds to the logs detailed information about the time taken ...
@ QGIS_SERVER_SERVICE_URL
To set the service URL if it's not present in the project.
QString serviceUrl(const QString &service) const
Returns the service URL from the setting.
QString cacheDirectory() const
Returns the cache directory.
bool getPrintDisabled() const
Returns true if WMS GetPrint request is disabled and the project's reading flag QgsProject::ReadFlag:...
QString landingPageProjectsPgConnections() const
Returns the PostgreSQL connection strings used by the landing page service to find projects.
int maxThreads() const
Returns the maximum number of threads to use.
bool logStderr() const
Returns whether logging to stderr is activated.
QgsServerSettings()
Constructor.
QString projectFile() const
Returns the QGS project file to use.
QString apiResourcesDirectory() const
Returns the server-wide base directory where HTML templates and static assets (e.g.
int projectCacheCheckInterval() const
Returns the config cache check interval (in ms) for the 'periodic' strategy.
Qgis::MessageLevel logLevel() const
Returns the log level.
bool logProfile() const
Returns true if profile information has to be added to the logs, default value is false.
QStringList allowedExtraSqlTokens() const
Returns the list of strings that represent the allowed extra SQL tokens accepted as components of a f...
bool forceReadOnlyLayers() const
Returns true if the reading flag force layer read only is activated.
int wmsMaxWidth() const
Returns the server-wide max width of a WMS GetMap request.
int capabilitiesCacheSize() const
Returns the maximum number of project capabilities to cache.
static QString name(QgsServerSettingsEnv::EnvVar env)
Returns the string representation of a setting.
QString landingPageBaseUrlPrefix() const
Returns the landing page base URL regular expression, defaults to /.
void logSummary() const
Log a summary of settings currently loaded.
QString logFile() const
Returns the log file.
qlonglong apiWfs3MaxLimit() const
Returns the server-wide maximum allowed value for "limit" in a features request.
int wmsMaxHeight() const
Returns the server-wide max height of a WMS GetMap request.
QString landingPageProjectsDirectories() const
Returns the directories used by the landing page service to find .qgs and .qgz projects.
bool parallelRendering() const
Returns parallel rendering setting.
QString applicationName() const
Returns the QGIS Server application name.
bool showGroupSeparator() const
Show group (thousand) separator.
bool ignoreBadLayers() const
Returns true if the bad layers are ignored and false when the presence of a bad layers invalidates th...
QString iniFile() const
Returns the ini file loaded by QSetting.
QString projectCacheStrategy() const
Returns the project's cache strategy The default value is 'filesystem', the value can be changed by s...
QString overrideSystemLocale() const
Overrides system locale.
bool trustLayerMetadata() const
Returns true if the reading flag trust layer metadata is activated.
void load()
Load settings according to current environment variables.
qint64 cacheSize() const
Returns the cache size.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.