Skip to content
Permalink
Browse files

Fix build without HAVE_SERVER_PYTHON_PLUGINS

  • Loading branch information
dmarteau committed Apr 3, 2019
1 parent 80a4fc9 commit 47fba3266e8bf52b3d0d3e807c59be059ddf9ea2
@@ -29,7 +29,7 @@ QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache *capCache,
mRequestHandler = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
mAccessControls = new QgsAccessControl();
mCacheManager.reset( new QgsServerCacheManager() );
mCacheManager = new QgsServerCacheManager();
#endif
}

@@ -43,7 +43,7 @@ QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
delete mAccessControls;
mCacheManager.reset();
delete mCacheManager;
#endif
}

@@ -97,7 +97,7 @@ void QgsServerInterfaceImpl::registerServerCache( QgsServerCacheFilter *serverCa

QgsServerCacheManager *QgsServerInterfaceImpl::cacheManager() const
{
return mCacheManager.get();
return mCacheManager;
}

void QgsServerInterfaceImpl::removeConfigCacheEntry( const QString &path )
@@ -92,7 +92,7 @@ class SERVER_EXPORT QgsServerInterfaceImpl : public QgsServerInterface
QString mConfigFilePath;
QgsServerFiltersMap mFilters;
QgsAccessControl *mAccessControls = nullptr;
std::unique_ptr<QgsServerCacheManager> mCacheManager = nullptr;
QgsServerCacheManager *mCacheManager = nullptr;
QgsCapabilitiesCache *mCapabilitiesCache = nullptr;
QgsRequestHandler *mRequestHandler = nullptr;
QgsServiceRegistry *mServiceRegistry = nullptr;
@@ -43,7 +43,6 @@ namespace QgsWcs
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
describeDocument = &doc;
@@ -58,7 +57,9 @@ namespace QgsWcs
}
describeDocument = &doc;
}

#else
doc = createDescribeCoverageDocument( serverIface, project, version, request );
#endif
response.setHeader( "Content-Type", "text/xml; charset=utf-8" );
response.write( describeDocument->toByteArray() );
}
@@ -42,7 +42,6 @@ namespace QgsWcs
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
@@ -57,7 +56,9 @@ namespace QgsWcs
}
capabilitiesDocument = &doc;
}

#else
doc = createGetCapabilitiesDocument( serverIface, project, version, request );
#endif
response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
response.write( capabilitiesDocument->toByteArray() );
}
@@ -44,7 +44,6 @@ namespace QgsWfs
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
describeDocument = &doc;
@@ -59,7 +58,9 @@ namespace QgsWfs
}
describeDocument = &doc;
}

#else
doc = createDescribeFeatureTypeDocument( serverIface, project, version, request );
#endif
response.setHeader( "Content-Type", "text/xml; charset=utf-8" );
response.write( describeDocument->toByteArray() );
}
@@ -152,7 +153,7 @@ namespace QgsWfs
{
continue;
}

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerReadPermission( layer ) )
{
if ( !typeNameList.isEmpty() )
@@ -164,7 +165,7 @@ namespace QgsWfs
continue;
}
}

#endif
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );
QgsVectorDataProvider *provider = vLayer->dataProvider();
if ( !provider )
@@ -48,7 +48,6 @@ namespace QgsWfs
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
@@ -63,7 +62,9 @@ namespace QgsWfs
}
capabilitiesDocument = &doc;
}

#else
doc = createGetCapabilitiesDocument( serverIface, project, version, request );
#endif
response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
response.write( capabilitiesDocument->toByteArray() );
}
@@ -458,11 +459,12 @@ namespace QgsWfs
{
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerReadPermission( layer ) )
{
continue;
}

#endif
QDomElement layerElem = doc.createElement( QStringLiteral( "FeatureType" ) );

//create Name
@@ -49,7 +49,6 @@ namespace QgsWfs
QgsServerCacheManager *cacheManager = nullptr;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
cacheManager = serverIface->cacheManager();
#endif
if ( cacheManager && cacheManager->getCachedDocument( &doc, project, request, accessControl ) )
{
capabilitiesDocument = &doc;
@@ -64,7 +63,9 @@ namespace QgsWfs
}
capabilitiesDocument = &doc;
}

#else
doc = createGetCapabilitiesDocument( serverIface, project, version, request );
#endif
response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
response.write( capabilitiesDocument->toByteArray() );
}
@@ -294,11 +295,12 @@ namespace QgsWfs
{
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerReadPermission( layer ) )
{
continue;
}

#endif
QDomElement layerElem = doc.createElement( QStringLiteral( "FeatureType" ) );

//create Name
@@ -179,9 +179,11 @@ namespace QgsWfs

QgsAccessControl *accessControl = serverIface->accessControls();

#ifdef HAVE_SERVER_PYTHON_PLUGINS
//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() );
#endif

// features counters
long sentFeatures = 0;
@@ -200,11 +202,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 )
{
@@ -217,12 +220,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;
QgsStringMap aliasMap = vlayer->attributeAliases();
@@ -312,7 +315,7 @@ namespace QgsWfs
featureRequest.setFlags( featureRequest.flags() | ( withGeom ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry ) );
// subset of attributes
featureRequest.setSubsetOfAttributes( attrIndexes );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl )
{
accessControl->filterFeatures( vlayer, featureRequest );
@@ -326,7 +329,7 @@ namespace QgsWfs
accessControl->layerAttributes( vlayer, attributes ),
vlayer->fields() );
}

#endif
if ( onlyOneLayer )
{
requestPrecision = QgsServerProjectUtils::wfsLayerPrecision( *project, vlayer->id() );
@@ -299,6 +299,7 @@ namespace QgsWfs
{
throw QgsSecurityAccessException( QStringLiteral( "No permissions to do WFS changes on layer '%1'" ).arg( name ) );
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerUpdatePermission( vlayer )
&& !accessControl->layerDeletePermission( vlayer ) && !accessControl->layerInsertPermission( vlayer ) )
{
@@ -309,7 +310,7 @@ namespace QgsWfs
{
QgsOWSServerFilterRestorer::applyAccessControlLayerFilters( accessControl, vlayer, filterRestorer->originalFilters() );
}

#endif
// store layers
mapLayerMap[name] = vlayer;
}
@@ -338,13 +339,14 @@ namespace QgsWfs
action.errorMsg = QStringLiteral( "No permissions to do WFS updates on layer '%1'" ).arg( typeName );
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerUpdatePermission( vlayer ) )
{
action.error = true;
action.errorMsg = QStringLiteral( "No permissions to do WFS updates on layer '%1'" ).arg( typeName );
continue;
}

#endif
//get provider
QgsVectorDataProvider *provider = vlayer->dataProvider();

@@ -368,12 +370,12 @@ namespace QgsWfs
<< QgsExpressionContextUtils::projectScope( project )
<< QgsExpressionContextUtils::layerScope( vlayer );
featureRequest.setExpressionContext( expressionContext );

#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl )
{
accessControl->filterFeatures( vlayer, featureRequest );
}

#endif
// get iterator
QgsFeatureIterator fit = vlayer->getFeatures( featureRequest );
QgsFeature feature;
@@ -390,13 +392,15 @@ namespace QgsWfs
// Update the features
while ( fit.nextFeature( feature ) )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->allowToEdit( vlayer, feature ) )
{
action.error = true;
action.errorMsg = QStringLiteral( "Feature modify permission denied on layer '%1'" ).arg( typeName );
vlayer->rollBack();
break;
}
#endif
QMap< QString, QString >::const_iterator it = propertyMap.constBegin();
for ( ; it != propertyMap.constEnd(); ++it )
{
@@ -485,6 +489,7 @@ namespace QgsWfs
{
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
// verifying changes
if ( accessControl )
{
@@ -500,6 +505,7 @@ namespace QgsWfs
}
}
}
#endif
if ( action.error )
{
continue;
@@ -543,13 +549,14 @@ namespace QgsWfs
action.errorMsg = QStringLiteral( "No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerDeletePermission( vlayer ) )
{
action.error = true;
action.errorMsg = QStringLiteral( "No permissions to do WFS deletes on layer '%1'" ).arg( typeName );
continue;
}

#endif
//get provider
QgsVectorDataProvider *provider = vlayer->dataProvider();

@@ -581,13 +588,15 @@ namespace QgsWfs
QgsFeatureIds fids;
while ( fit.nextFeature( feature ) )
{
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->allowToEdit( vlayer, feature ) )
{
action.error = true;
action.errorMsg = QStringLiteral( "Feature modify permission denied" );
vlayer->rollBack();
break;
}
#endif
fids << feature.id();
}
if ( action.error )
@@ -640,13 +649,14 @@ namespace QgsWfs
action.errorMsg = QStringLiteral( "No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( accessControl && !accessControl->layerDeletePermission( vlayer ) )
{
action.error = true;
action.errorMsg = QStringLiteral( "No permissions to do WFS inserts on layer '%1'" ).arg( typeName );
continue;
}

#endif
//get provider
QgsVectorDataProvider *provider = vlayer->dataProvider();

@@ -674,6 +684,7 @@ namespace QgsWfs
action.errorMsg = QStringLiteral( "%1 '%2'" ).arg( ex.message() ).arg( typeName );
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
// control features
if ( accessControl )
{
@@ -690,6 +701,7 @@ namespace QgsWfs
featureIt++;
}
}
#endif
if ( action.error )
{
continue;

0 comments on commit 47fba32

Please sign in to comment.
You can’t perform that action at this time.