Skip to content
Permalink
Browse files

Revert "Merge pull request #3886 from pblottiere/servermultithread"

This reverts commit 350a2b5, reversing
changes made to 590a981.
  • Loading branch information
rldhont committed Jan 9, 2017
1 parent 350a2b5 commit 3e80a52995cc549ebe4687709e4b4568ccf963fb

This file was deleted.

@@ -27,5 +27,4 @@
%Include qgswmsprojectparser.sip
%Include qgswfsprojectparser.sip
%Include qgsconfigcache.sip
%Include qgsserversettings.sip
%Include qgsserver.sip
@@ -29,7 +29,6 @@ SET ( qgis_mapserv_SRCS
qgswmsserver.cpp
qgswfsserver.cpp
qgswcsserver.cpp
qgsserversettings.cpp
qgsmapserviceexception.cpp
qgsmslayercache.cpp
qgsmslayerbuilder.cpp
@@ -68,7 +67,6 @@ SET (qgis_mapserv_MOC_HDRS
# qgshttptransaction.h
qgsmslayercache.h
qgsserverlogger.h
qgsserversettings.h
qgsserverstreamingdevice.h
)

@@ -22,25 +22,12 @@

#include <QStringList>

void QgsAccessControl::resolveFilterFeatures( const QList<QgsMapLayer*> &layers )
{
Q_FOREACH ( QgsMapLayer* l, layers )
{
if ( l->type() == QgsMapLayer::LayerType::VectorLayer )
{
const QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( l );
mFilterFeaturesExpressions[vl->id()] = resolveFilterFeatures( vl );
}
}

mResolved = true;
}

QString QgsAccessControl::resolveFilterFeatures( const QgsVectorLayer* layer ) const
//! Filter the features of the layer
void QgsAccessControl::filterFeatures( const QgsVectorLayer* layer, QgsFeatureRequest& featureRequest ) const
{
QStringList expressions = QStringList();
QgsAccessControlFilterMap::const_iterator acIterator;

for ( acIterator = mPluginsAccessControls->constBegin(); acIterator != mPluginsAccessControls->constEnd(); ++acIterator )
{
QString expression = acIterator.value()->layerFilterExpression( layer );
@@ -49,34 +36,9 @@ QString QgsAccessControl::resolveFilterFeatures( const QgsVectorLayer* layer ) c
expressions.append( expression );
}
}

QString expression;
if ( !expressions.isEmpty() )
{
expression = QStringLiteral( "((" ).append( expressions.join( QStringLiteral( ") AND (" ) ) ).append( "))" );
}

return expression;
}

//! Filter the features of the layer
void QgsAccessControl::filterFeatures( const QgsVectorLayer* layer, QgsFeatureRequest& featureRequest ) const
{

QString expression;

if ( mResolved && mFilterFeaturesExpressions.keys().contains( layer->id() ) )
{
expression = mFilterFeaturesExpressions[layer->id()];
}
else
{
expression = resolveFilterFeatures( layer );
}

if ( !expression.isEmpty() )
{
featureRequest.setFilterExpression( expression );
featureRequest.setFilterExpression( QStringLiteral( "((" ).append( expressions.join( QStringLiteral( ") AND (" ) ) ).append( "))" ) );
}
}

@@ -40,15 +40,12 @@ class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
QgsAccessControl()
{
mPluginsAccessControls = new QgsAccessControlFilterMap();
mResolved = false;
}

//! Constructor
QgsAccessControl( const QgsAccessControl& copy )
{
mPluginsAccessControls = new QgsAccessControlFilterMap( *copy.mPluginsAccessControls );
mFilterFeaturesExpressions = copy.mFilterFeaturesExpressions;
mResolved = copy.mResolved;
}


@@ -57,11 +54,6 @@ class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
delete mPluginsAccessControls;
}

/** Resolve features' filter of layers
* @param layers to filter
*/
void resolveFilterFeatures( const QList<QgsMapLayer*> &layers );

/** Filter the features of the layer
* @param layer the layer to control
* @param filterFeatures the request to fill
@@ -130,13 +122,8 @@ class SERVER_EXPORT QgsAccessControl : public QgsFeatureFilterProvider
void registerAccessControl( QgsAccessControlFilter* accessControl, int priority = 0 );

private:
QString resolveFilterFeatures( const QgsVectorLayer* layer ) const;

//! The AccessControl plugins registry
QgsAccessControlFilterMap* mPluginsAccessControls;

QMap<QString, QString> mFilterFeaturesExpressions;
bool mResolved;
};

#endif
@@ -21,7 +21,6 @@
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include "qgsserversettings.h"
#include <QFile>

QgsMSLayerCache* QgsMSLayerCache::instance()
@@ -33,8 +32,20 @@ QgsMSLayerCache* QgsMSLayerCache::instance()
}

QgsMSLayerCache::QgsMSLayerCache()
: mProjectMaxLayers( 100 )
: mProjectMaxLayers( 0 )
{
mDefaultMaxLayers = 100;
//max layer from environment variable overrides default
char* maxLayerEnv = getenv( "MAX_CACHE_LAYERS" );
if ( maxLayerEnv )
{
bool conversionOk = false;
int maxLayerInt = QString( maxLayerEnv ).toInt( &conversionOk );
if ( conversionOk )
{
mDefaultMaxLayers = maxLayerInt;
}
}
QObject::connect( &mFileSystemWatcher, SIGNAL( fileChanged( const QString& ) ), this, SLOT( removeProjectFileLayers( const QString& ) ) );
}

@@ -48,11 +59,6 @@ QgsMSLayerCache::~QgsMSLayerCache()
mEntries.clear();
}

void QgsMSLayerCache::setMaxCacheLayers( int maxCacheLayers )
{
mDefaultMaxLayers = maxCacheLayers;
}

void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile, const QList<QString>& tempFiles )
{
QgsMessageLog::logMessage( "Layer cache: insert Layer '" + layerName + "' configFile: " + configFile, QStringLiteral( "Server" ), QgsMessageLog::INFO );
@@ -56,13 +56,6 @@ class QgsMSLayerCache: public QObject
static QgsMSLayerCache* instance();
~QgsMSLayerCache();

/**
* Set the maximum number of layers in cache.
* @param maxCacheLayers the number of layers in cache
* @note added in QGIS 3.0
*/
void setMaxCacheLayers( int maxCacheLayers );

/** Inserts a new layer into the cash
@param url the layer datasource
@param layerName the layer name (to distinguish between different layers in a request using the same datasource
@@ -19,7 +19,6 @@
#define QGSOWSSERVER_H

#include "qgsrequesthandler.h"
#include "qgsserversettings.h"
#ifdef HAVE_SERVER_PYTHON_PLUGINS
#include "qgsaccesscontrol.h"
#endif
@@ -33,15 +32,13 @@ class QgsOWSServer
public:
QgsOWSServer(
const QString& configFilePath
, const QgsServerSettings& settings
, const QMap<QString, QString>& parameters
, QgsRequestHandler* rh
#ifdef HAVE_SERVER_PYTHON_PLUGINS
, QgsAccessControl* ac
, const QgsAccessControl* ac
#endif
)
: mSettings( settings )
, mParameters( parameters )
: mParameters( parameters )
, mRequestHandler( rh )
, mConfigFilePath( configFilePath )
#ifdef HAVE_SERVER_PYTHON_PLUGINS
@@ -61,13 +58,12 @@ class QgsOWSServer
QgsOWSServer() {}

protected:
QgsServerSettings mSettings;
QMap<QString, QString> mParameters;
QgsRequestHandler* mRequestHandler;
QString mConfigFilePath;
#ifdef HAVE_SERVER_PYTHON_PLUGINS
//! The access control helper
QgsAccessControl* mAccessControl;
const QgsAccessControl* mAccessControl;

/** Apply filter strings from the access control to the layers.
* @param layer the concerned layer

0 comments on commit 3e80a52

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