Skip to content

Commit

Permalink
Revert "Merge pull request #3886 from pblottiere/servermultithread"
Browse files Browse the repository at this point in the history
This reverts commit 350a2b5, reversing
changes made to 590a981.
  • Loading branch information
rldhont committed Jan 9, 2017
1 parent 350a2b5 commit 3e80a52
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 1,055 deletions.
89 changes: 0 additions & 89 deletions python/server/qgsserversettings.sip

This file was deleted.

1 change: 0 additions & 1 deletion python/server/server.sip
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
%Include qgswmsprojectparser.sip
%Include qgswfsprojectparser.sip
%Include qgsconfigcache.sip
%Include qgsserversettings.sip
%Include qgsserver.sip
2 changes: 0 additions & 2 deletions src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SET ( qgis_mapserv_SRCS
qgswmsserver.cpp
qgswfsserver.cpp
qgswcsserver.cpp
qgsserversettings.cpp
qgsmapserviceexception.cpp
qgsmslayercache.cpp
qgsmslayerbuilder.cpp
Expand Down Expand Up @@ -68,7 +67,6 @@ SET (qgis_mapserv_MOC_HDRS
# qgshttptransaction.h
qgsmslayercache.h
qgsserverlogger.h
qgsserversettings.h
qgsserverstreamingdevice.h
)

Expand Down
44 changes: 3 additions & 41 deletions src/server/qgsaccesscontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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( "))" ) );
}
}

Expand Down
13 changes: 0 additions & 13 deletions src/server/qgsaccesscontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand All @@ -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
Expand Down Expand Up @@ -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
20 changes: 13 additions & 7 deletions src/server/qgsmslayercache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include "qgsserversettings.h"
#include <QFile>

QgsMSLayerCache* QgsMSLayerCache::instance()
Expand All @@ -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& ) ) );
}

Expand All @@ -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 );
Expand Down
7 changes: 0 additions & 7 deletions src/server/qgsmslayercache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/server/qgsowsserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define QGSOWSSERVER_H

#include "qgsrequesthandler.h"
#include "qgsserversettings.h"
#ifdef HAVE_SERVER_PYTHON_PLUGINS
#include "qgsaccesscontrol.h"
#endif
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 3e80a52

Please sign in to comment.