Skip to content

Commit

Permalink
Expose server interfaces methodsi to python for clearing server layer…
Browse files Browse the repository at this point in the history
… cache.
  • Loading branch information
dmarteau committed Jun 3, 2016
1 parent f9ab722 commit a4a0c9b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 1 deletion.
5 changes: 5 additions & 0 deletions python/server/qgsserverinterface.sip
Expand Up @@ -64,6 +64,11 @@ class QgsServerInterface
virtual QString configFilePath() = 0;
/** Set the config file path */
virtual void setConfigFilePath( const QString& configFilePath) = 0;
/** Remove entry from config cache */
virtual void removeConfigCacheEntry( const QString& path ) = 0;
/** Remove entry from layer cache */
virtual void removeProjectLayers( const QString& path ) = 0;


private:
/** Constructor */
Expand Down
7 changes: 7 additions & 0 deletions src/server/qgsconfigcache.cpp
Expand Up @@ -207,3 +207,10 @@ void QgsConfigCache::removeChangedEntry( const QString& path )

mFileSystemWatcher.removePath( path );
}


void QgsConfigCache::removeEntry( const QString& path )
{
removeChangedEntry( path );
}

2 changes: 2 additions & 0 deletions src/server/qgsconfigcache.h
Expand Up @@ -61,6 +61,8 @@ class SERVER_EXPORT QgsConfigCache : public QObject
, const QMap<QString, QString>& parameterMap = ( QMap< QString, QString >() )
);

void removeEntry( const QString& path );

private:
QgsConfigCache();

Expand Down
6 changes: 6 additions & 0 deletions src/server/qgsmslayercache.cpp
Expand Up @@ -226,3 +226,9 @@ void QgsMSLayerCache::logCacheContents() const
QgsMessageLog::logMessage( "Url: " + it.value().url + " Layer name: " + it.value().layerPointer->name() + " Project: " + it.value().configFile, "Server", QgsMessageLog::INFO );
}
}


void QgsMSLayerCache::removeProjectLayers( const QString& path )
{
removeProjectFileLayers( path );
}
3 changes: 3 additions & 0 deletions src/server/qgsmslayercache.h
Expand Up @@ -73,6 +73,9 @@ class QgsMSLayerCache: public QObject
//for debugging
void logCacheContents() const;

/** Expose method for use in server interface */
void removeProjectLayers( const QString& path );

protected:
/** Protected singleton constructor*/
QgsMSLayerCache();
Expand Down
15 changes: 15 additions & 0 deletions src/server/qgsserverinterface.h
Expand Up @@ -111,6 +111,21 @@ class SERVER_EXPORT QgsServerInterface
*/
virtual void setConfigFilePath( const QString& configFilePath ) = 0;

/**
* Remove entry from config cache
* @param path the path of the file to remove
*/
virtual void removeConfigCacheEntry( const QString& path ) = 0;

/**
* Remove entries from layer cache
* @param path the path of the project which own the layers to be removed
*/
virtual void removeProjectLayers( const QString& path ) = 0;




private:
QString mConfigFilePath;
};
Expand Down
17 changes: 16 additions & 1 deletion src/server/qgsserverinterfaceimpl.cpp
Expand Up @@ -18,7 +18,8 @@


#include "qgsserverinterfaceimpl.h"

#include "qgsconfigcache.h"
#include "qgsmslayercache.h"

/** Constructor */
QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache* capCache )
Expand Down Expand Up @@ -72,3 +73,17 @@ void QgsServerInterfaceImpl::registerAccessControl( QgsAccessControlFilter* acce
{
mAccessControls->registerAccessControl( accessControl, priority );
}


void QgsServerInterfaceImpl::removeConfigCacheEntry( const QString& path )
{
QgsConfigCache::instance()->removeEntry( path );
}

void QgsServerInterfaceImpl::removeProjectLayers( const QString& path )
{
QgsMSLayerCache::instance()->removeProjectLayers( path );
}



2 changes: 2 additions & 0 deletions src/server/qgsserverinterfaceimpl.h
Expand Up @@ -61,6 +61,8 @@ class QgsServerInterfaceImpl : public QgsServerInterface
QString configFilePath() override { return mConfigFilePath; }
void setConfigFilePath( const QString& configFilePath ) override;
void setFilters( QgsServerFiltersMap *filters ) override;
void removeConfigCacheEntry( const QString& path ) override;
void removeProjectLayers( const QString& path ) override;

private:

Expand Down

2 comments on commit a4a0c9b

@rldhont
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elpaso can we backport this commit to release-2_14 ?

@elpaso
Copy link
Contributor

@elpaso elpaso commented on a4a0c9b Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rldhont sorry I missed this comment. Sure we can (but maybe too late now), it's really useful, I'm doing all kind of trickery to fake the cache in the tests.

Please sign in to comment.