Skip to content

Commit

Permalink
Fix warnings when building without HAVE_SERVER_PYTHON_PLUGINS
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and rldhont committed Oct 23, 2019
1 parent 6e48189 commit 49b110e
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 46 deletions.
8 changes: 4 additions & 4 deletions src/server/services/wcs/qgswcsdescribecoverage.cpp
Expand Up @@ -36,16 +36,14 @@ namespace QgsWcs
void writeDescribeCoverage( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
QDomDocument doc;
const QDomDocument *describeDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
describeDocument = &doc;
Expand Down Expand Up @@ -80,6 +78,8 @@ namespace QgsWcs

#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif

//wcs:WCS_Capabilities element
Expand Down
8 changes: 4 additions & 4 deletions src/server/services/wcs/qgswcsgetcapabilities.cpp
Expand Up @@ -37,16 +37,14 @@ namespace QgsWcs
void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
QDomDocument doc;
const QDomDocument *capabilitiesDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
Expand Down Expand Up @@ -280,6 +278,8 @@ namespace QgsWcs
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif
/*
* Adding layer list in ContentMetadata
Expand Down
2 changes: 2 additions & 0 deletions src/server/services/wcs/qgswcsgetcoverage.cpp
Expand Up @@ -52,6 +52,8 @@ namespace QgsWcs

#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif
//defining coverage name
QString coveName;
Expand Down
10 changes: 6 additions & 4 deletions src/server/services/wfs/qgswfsdescribefeaturetype.cpp
Expand Up @@ -42,16 +42,14 @@ namespace QgsWfs
void writeDescribeFeatureType( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
QDomDocument doc;
const QDomDocument *describeDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
describeDocument = &doc;
Expand Down Expand Up @@ -91,7 +89,11 @@ namespace QgsWfs
throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ),
QStringLiteral( "OUTPUTFORMAT %1 is not supported" ).arg( wfsParameters.outputFormatAsString() ) );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif

//xsd:schema
QDomElement schemaElement = doc.createElement( QStringLiteral( "schema" )/*xsd:schema*/ );
Expand Down
10 changes: 6 additions & 4 deletions src/server/services/wfs/qgswfsgetcapabilities.cpp
Expand Up @@ -41,16 +41,14 @@ namespace QgsWfs
void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
QDomDocument doc;
const QDomDocument *capabilitiesDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
Expand Down Expand Up @@ -435,7 +433,11 @@ namespace QgsWfs

QDomElement getFeatureTypeListElement( QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif

//wfs:FeatureTypeList element
QDomElement featureTypeListElement = doc.createElement( QStringLiteral( "FeatureTypeList" )/*wfs:FeatureTypeList*/ );
Expand Down
10 changes: 6 additions & 4 deletions src/server/services/wfs/qgswfsgetcapabilities_1_0_0.cpp
Expand Up @@ -43,16 +43,14 @@ namespace QgsWfs
void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
const QgsServerRequest &request, QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif
QDomDocument doc;
const QDomDocument *capabilitiesDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
Expand Down Expand Up @@ -274,7 +272,11 @@ namespace QgsWfs

QDomElement getFeatureTypeListElement( QDomDocument &doc, QgsServerInterface *serverIface, const QgsProject *project )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif

//wfs:FeatureTypeList element
QDomElement featureTypeListElement = doc.createElement( QStringLiteral( "FeatureTypeList" )/*wfs:FeatureTypeList*/ );
Expand Down
11 changes: 10 additions & 1 deletion src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -185,11 +185,14 @@ namespace QgsWfs
}
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();

//scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope
//there's LOTS of potential exit paths here, so we avoid having to restore the filters manually
std::unique_ptr< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer() );
#else
( void )serverIface;
#endif

// features counters
long sentFeatures = 0;
Expand All @@ -208,10 +211,12 @@ namespace QgsWfs
}

QgsMapLayer *layer = mapLayerMap[typeName];
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerReadPermission( layer ) )
{
throw QgsSecurityAccessException( QStringLiteral( "Feature access permission denied" ) );
}
#endif

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
Expand All @@ -226,10 +231,12 @@ namespace QgsWfs
throw QgsRequestNotWellFormedException( QStringLiteral( "TypeName '%1' layer's provider error" ).arg( typeName ) );
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl )
{
QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, vlayer, filterRestorer->originalFilters() );
}
#endif

//is there alias info for this vector layer?
QMap< int, QString > layerAliasInfo;
Expand Down Expand Up @@ -326,6 +333,7 @@ namespace QgsWfs
// subset of attributes
featureRequest.setSubsetOfAttributes( attrIndexes );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl )
{
accessControl->filterFeatures( vlayer, featureRequest );
Expand All @@ -339,6 +347,7 @@ namespace QgsWfs
accessControl->layerAttributes( vlayer, attributes ),
vlayer->fields() );
}
#endif

if ( onlyOneLayer )
{
Expand Down
5 changes: 5 additions & 0 deletions src/server/services/wfs/qgswfstransaction.cpp
Expand Up @@ -217,6 +217,9 @@ namespace QgsWfs

void performTransaction( transactionRequest &aRequest, QgsServerInterface *serverIface, const QgsProject *project )
{
#ifndef HAVE_SERVER_PYTHON_PLUGINS
( void )serverIface;
#endif
// store typeName
QStringList typeNameList;

Expand All @@ -242,8 +245,10 @@ namespace QgsWfs
typeNameList << name;
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
// get access controls
QgsAccessControl *accessControl = serverIface->accessControls();
#endif

//scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope
//there's LOTS of potential exit paths here, so we avoid having to restore the filters manually
Expand Down
4 changes: 4 additions & 0 deletions src/server/services/wfs/qgswfstransaction_1_0_0.cpp
Expand Up @@ -225,8 +225,12 @@ namespace QgsWfs
typeNameList << name;
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
// get access controls
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif

//scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope
//there's LOTS of potential exit paths here, so we avoid having to restore the filters manually
Expand Down
2 changes: 2 additions & 0 deletions src/server/services/wms/qgswmsdescribelayer.cpp
Expand Up @@ -107,6 +107,8 @@ namespace QgsWms
// access control
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif
// Use layer ids
bool useLayerIds = QgsServerProjectUtils::wmsUseLayerIds( *project );
Expand Down
21 changes: 15 additions & 6 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Expand Up @@ -94,9 +94,8 @@ namespace QgsWms
const QString &version, const QgsServerRequest &request,
QgsServerResponse &response, bool projectSettings )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif

QDomDocument doc;
Expand All @@ -109,18 +108,20 @@ namespace QgsWms
cacheKeyList << ( projectSettings ? QStringLiteral( "projectSettings" ) : version );
cacheKeyList << request.url().host();
bool cache = true;

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl )
cache = accessControl->fillCacheKey( cacheKeyList );
#endif
QString cacheKey = cacheKeyList.join( '-' );

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
}
#endif

if ( !capabilitiesDocument && cache ) //capabilities xml not in cache plugins
{
Expand All @@ -133,16 +134,20 @@ namespace QgsWms

doc = getCapabilities( serverIface, project, version, request, projectSettings );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( cacheManager &&
cacheManager->setCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
}
else if ( cache )
#endif

if ( !capabilitiesDocument )
{
capabilitiesCache->insertCapabilitiesDocument( configFilePath, cacheKey, &doc );
capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey );
}

if ( !capabilitiesDocument )
{
capabilitiesDocument = &doc;
Expand Down Expand Up @@ -1662,7 +1667,11 @@ namespace QgsWms
void appendDrawingOrder( QDomDocument &doc, QDomElement &parentElem, QgsServerInterface *serverIface,
const QgsProject *project )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif
bool useLayerIds = QgsServerProjectUtils::wmsUseLayerIds( *project );
QStringList restrictedLayers = QgsServerProjectUtils::wmsRestrictedLayers( *project );

Expand Down
6 changes: 2 additions & 4 deletions src/server/services/wms/qgswmsgetcontext.cpp
Expand Up @@ -55,17 +55,15 @@ namespace QgsWms
const QString &version, const QgsServerRequest &request,
QgsServerResponse &response )
{
QgsAccessControl *accessControl = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
QgsAccessControl *accessControl = serverIface->accessControls();
#endif

QDomDocument doc;
const QDomDocument *contextDocument = nullptr;

QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
contextDocument = &doc;
Expand Down
10 changes: 5 additions & 5 deletions src/server/services/wms/qgswmsgetlegendgraphics.cpp
Expand Up @@ -39,12 +39,9 @@ namespace QgsWms
QgsWmsParameters wmsParameters( QUrlQuery( request.url() ) );

// Get cached image
QgsAccessControl *accessControl = nullptr;
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
accessControl = serverIface->accessControls();
cacheManager = serverIface->cacheManager();
#endif
QgsAccessControl *accessControl = serverIface->accessControls();
QgsServerCacheManager *cacheManager = serverIface->cacheManager();
if ( cacheManager )
{
ImageOutputFormat outputFormat = parseImageFormat( format );
Expand Down Expand Up @@ -78,6 +75,7 @@ namespace QgsWms
return;
}
}
#endif

QgsRenderer renderer( serverIface, project, wmsParameters );

Expand All @@ -86,12 +84,14 @@ namespace QgsWms
if ( result )
{
writeImage( response, *result, format, renderer.getImageQuality() );
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( cacheManager )
{
QByteArray content = response.data();
if ( !content.isEmpty() )
cacheManager->setCachedImage( &content, project, request, accessControl );
}
#endif
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/server/services/wms/qgswmsgetstyles.cpp
Expand Up @@ -131,7 +131,11 @@ namespace QgsWms
myDocument.appendChild( root );

// access control
#ifdef HAVE_SERVER_PYTHON_PLUGINS
QgsAccessControl *accessControl = serverIface->accessControls();
#else
( void )serverIface;
#endif
// Use layer ids
bool useLayerIds = QgsServerProjectUtils::wmsUseLayerIds( *project );
// WMS restricted layers
Expand Down

0 comments on commit 49b110e

Please sign in to comment.