Skip to content

Commit 7abd691

Browse files
committedJun 3, 2016
Merge pull request #3172 from dmarteau/master
Expose server interfaces methods to python for clearing server cache
2 parents 04e1e96 + a4a0c9b commit 7abd691

File tree

8 files changed

+56
-1
lines changed

8 files changed

+56
-1
lines changed
 

‎python/server/qgsserverinterface.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class QgsServerInterface
6464
virtual QString configFilePath() = 0;
6565
/** Set the config file path */
6666
virtual void setConfigFilePath( const QString& configFilePath) = 0;
67+
/** Remove entry from config cache */
68+
virtual void removeConfigCacheEntry( const QString& path ) = 0;
69+
/** Remove entry from layer cache */
70+
virtual void removeProjectLayers( const QString& path ) = 0;
71+
6772

6873
private:
6974
/** Constructor */

‎src/server/qgsconfigcache.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,10 @@ void QgsConfigCache::removeChangedEntry( const QString& path )
207207

208208
mFileSystemWatcher.removePath( path );
209209
}
210+
211+
212+
void QgsConfigCache::removeEntry( const QString& path )
213+
{
214+
removeChangedEntry( path );
215+
}
216+

‎src/server/qgsconfigcache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class SERVER_EXPORT QgsConfigCache : public QObject
6161
, const QMap<QString, QString>& parameterMap = ( QMap< QString, QString >() )
6262
);
6363

64+
void removeEntry( const QString& path );
65+
6466
private:
6567
QgsConfigCache();
6668

‎src/server/qgsmslayercache.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,9 @@ void QgsMSLayerCache::logCacheContents() const
226226
QgsMessageLog::logMessage( "Url: " + it.value().url + " Layer name: " + it.value().layerPointer->name() + " Project: " + it.value().configFile, "Server", QgsMessageLog::INFO );
227227
}
228228
}
229+
230+
231+
void QgsMSLayerCache::removeProjectLayers( const QString& path )
232+
{
233+
removeProjectFileLayers( path );
234+
}

‎src/server/qgsmslayercache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class QgsMSLayerCache: public QObject
7373
//for debugging
7474
void logCacheContents() const;
7575

76+
/** Expose method for use in server interface */
77+
void removeProjectLayers( const QString& path );
78+
7679
protected:
7780
/** Protected singleton constructor*/
7881
QgsMSLayerCache();

‎src/server/qgsserverinterface.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ class SERVER_EXPORT QgsServerInterface
111111
*/
112112
virtual void setConfigFilePath( const QString& configFilePath ) = 0;
113113

114+
/**
115+
* Remove entry from config cache
116+
* @param path the path of the file to remove
117+
*/
118+
virtual void removeConfigCacheEntry( const QString& path ) = 0;
119+
120+
/**
121+
* Remove entries from layer cache
122+
* @param path the path of the project which own the layers to be removed
123+
*/
124+
virtual void removeProjectLayers( const QString& path ) = 0;
125+
126+
127+
128+
114129
private:
115130
QString mConfigFilePath;
116131
};

‎src/server/qgsserverinterfaceimpl.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919

2020
#include "qgsserverinterfaceimpl.h"
21-
21+
#include "qgsconfigcache.h"
22+
#include "qgsmslayercache.h"
2223

2324
/** Constructor */
2425
QgsServerInterfaceImpl::QgsServerInterfaceImpl( QgsCapabilitiesCache* capCache )
@@ -72,3 +73,17 @@ void QgsServerInterfaceImpl::registerAccessControl( QgsAccessControlFilter* acce
7273
{
7374
mAccessControls->registerAccessControl( accessControl, priority );
7475
}
76+
77+
78+
void QgsServerInterfaceImpl::removeConfigCacheEntry( const QString& path )
79+
{
80+
QgsConfigCache::instance()->removeEntry( path );
81+
}
82+
83+
void QgsServerInterfaceImpl::removeProjectLayers( const QString& path )
84+
{
85+
QgsMSLayerCache::instance()->removeProjectLayers( path );
86+
}
87+
88+
89+

‎src/server/qgsserverinterfaceimpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class QgsServerInterfaceImpl : public QgsServerInterface
6161
QString configFilePath() override { return mConfigFilePath; }
6262
void setConfigFilePath( const QString& configFilePath ) override;
6363
void setFilters( QgsServerFiltersMap *filters ) override;
64+
void removeConfigCacheEntry( const QString& path ) override;
65+
void removeProjectLayers( const QString& path ) override;
6466

6567
private:
6668

0 commit comments

Comments
 (0)
Please sign in to comment.