Skip to content
Permalink
Browse files

Merge pull request #3866 from dmarteau/master

Implements service modules registry - Experimental
  • Loading branch information
rldhont committed Jan 10, 2017
2 parents 3a03c98 + ff3487d commit 9be984c7ece622f98a61c347d2135c8f7f130490
Showing with 9,160 additions and 4,742 deletions.
  1. +12 −0 CMakeLists.txt
  2. +2 −0 cmake_templates/qgsconfig.h.in
  3. +1 −0 mac/cmake/0vars.cmake.in
  4. +24 −29 python/server/qgsrequesthandler.sip
  5. +17 −15 python/server/qgsserver.sip
  6. +14 −8 python/server/qgsserverinterface.sip
  7. +100 −0 python/server/qgsserverrequest.sip
  8. +119 −0 python/server/qgsserverresponse.sip
  9. +69 −0 python/server/qgsservice.sip
  10. +51 −0 python/server/qgsservicemodule.sip
  11. +90 −0 python/server/qgsserviceregistry.sip
  12. +7 −0 python/server/server.sip
  13. +0 −1 src/core/composer/qgsatlascomposition.h
  14. +13 −5 src/server/CMakeLists.txt
  15. +12 −2 src/server/qgis_map_serv.cpp
  16. +158 −0 src/server/qgsbufferserverresponse.cpp
  17. +125 −0 src/server/qgsbufferserverresponse.h
  18. +307 −0 src/server/qgsfcgiserverresponse.cpp
  19. +104 −0 src/server/qgsfcgiserverresponse.h
  20. +71 −0 src/server/qgsfilterresponsedecorator.cpp
  21. +78 −0 src/server/qgsfilterresponsedecorator.h
  22. +0 −44 src/server/qgsgetrequesthandler.cpp
  23. +0 −103 src/server/qgshttprequesthandler.h
  24. +6 −5 src/server/qgsowsserver.h
  25. +0 −89 src/server/qgspostrequesthandler.cpp
  26. +161 −264 src/server/{qgshttprequesthandler.cpp → qgsrequesthandler.cpp}
  27. +85 −93 src/server/qgsrequesthandler.h
  28. +119 −138 src/server/qgsserver.cpp
  29. +24 −15 src/server/qgsserver.h
  30. +15 −1 src/server/qgsserverinterface.h
  31. +14 −5 src/server/qgsserverinterfaceimpl.cpp
  32. +6 −4 src/server/qgsserverinterfaceimpl.h
  33. +116 −0 src/server/qgsserverrequest.cpp
  34. +135 −0 src/server/qgsserverrequest.h
  35. +77 −0 src/server/qgsserverresponse.cpp
  36. +153 −0 src/server/qgsserverresponse.h
  37. +11 −16 src/server/{qgspostrequesthandler.h → qgsservice.cpp}
  38. +73 −0 src/server/qgsservice.h
  39. +36 −0 src/server/qgsservicemodule.cpp
  40. +58 −0 src/server/qgsservicemodule.h
  41. +173 −0 src/server/qgsservicenativeloader.cpp
  42. +93 −0 src/server/qgsservicenativeloader.h
  43. +243 −0 src/server/qgsserviceregistry.cpp
  44. +115 −0 src/server/qgsserviceregistry.h
  45. +1 −1 src/server/qgssldconfigparser.h
  46. +0 −6 src/server/qgswcsserver.cpp
  47. +0 −2 src/server/qgswcsserver.h
  48. +0 −6 src/server/qgswfsserver.cpp
  49. +0 −2 src/server/qgswfsserver.h
  50. +0 −3,563 src/server/qgswmsserver.cpp
  51. +0 −301 src/server/qgswmsserver.h
  52. +11 −0 src/server/services/CMakeLists.txt
  53. +41 −0 src/server/services/DummyService/CMakeLists.txt
  54. +70 −0 src/server/services/DummyService/dummy.cpp
  55. +28 −0 src/server/services/qgsmodule.h
  56. +73 −0 src/server/services/wms/CMakeLists.txt
  57. +180 −0 src/server/services/wms/qgsdxfwriter.cpp
  58. +26 −0 src/server/services/wms/qgsdxfwriter.h
  59. +65 −0 src/server/services/wms/qgsfilterrestorer.cpp
  60. +64 −0 src/server/services/wms/qgsfilterrestorer.h
  61. +186 −0 src/server/services/wms/qgswms.cpp
  62. +53 −0 src/server/services/wms/qgswmsdescribelayer.cpp
  63. +34 −0 src/server/services/wms/qgswmsdescribelayer.h
  64. +88 −0 src/server/services/wms/qgswmsgetcapabilities.cpp
  65. +35 −0 src/server/services/wms/qgswmsgetcapabilities.h
  66. +53 −0 src/server/services/wms/qgswmsgetcontext.cpp
  67. +34 −0 src/server/services/wms/qgswmsgetcontext.h
  68. +185 −0 src/server/services/wms/qgswmsgetfeatureinfo.cpp
  69. +34 −0 src/server/services/wms/qgswmsgetfeatureinfo.h
  70. +63 −0 src/server/services/wms/qgswmsgetlegendgraphics.cpp
  71. +34 −0 src/server/services/wms/qgswmsgetlegendgraphics.h
  72. +63 −0 src/server/services/wms/qgswmsgetmap.cpp
  73. +34 −0 src/server/services/wms/qgswmsgetmap.h
  74. +81 −0 src/server/services/wms/qgswmsgetprint.cpp
  75. +17 −15 src/server/{qgsgetrequesthandler.h → services/wms/qgswmsgetprint.h}
  76. +53 −0 src/server/services/wms/qgswmsgetschemaextension.cpp
  77. +34 −0 src/server/services/wms/qgswmsgetschemaextension.h
  78. +54 −0 src/server/services/wms/qgswmsgetstyle.cpp
  79. +34 −0 src/server/services/wms/qgswmsgetstyle.h
  80. +53 −0 src/server/services/wms/qgswmsgetstyles.cpp
  81. +34 −0 src/server/services/wms/qgswmsgetstyles.h
  82. +3,107 −0 src/server/services/wms/qgswmsservertransitional.cpp
  83. +307 −0 src/server/services/wms/qgswmsservertransitional.h
  84. +492 −0 src/server/services/wms/qgswmsutils.cpp
  85. +90 −0 src/server/services/wms/qgswmsutils.h
  86. +2 −0 tests/src/python/CMakeLists.txt
  87. +1 −2 tests/src/python/qgis_wrapped_server.py
  88. +5 −6 tests/src/python/test_qgsserver.py
  89. +1 −1 tests/src/python/test_qgsserver_accesscontrol.py
  90. +98 −0 tests/src/python/test_qgsserver_modules.py
  91. +155 −0 tests/src/python/test_qgsserver_services.py
@@ -445,6 +445,8 @@ IF (WIN32)
SET (DEFAULT_PLUGIN_SUBDIR plugins)
SET (DEFAULT_INCLUDE_SUBDIR include)

SET (DEFAULT_SERVER_MODULE_SUBDIR server)

IF (MSVC)
SET (DEFAULT_BIN_SUBDIR bin)
SET (DEFAULT_CGIBIN_SUBDIR bin)
@@ -518,6 +520,10 @@ ELSE (WIN32)
SET (DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis)
SET (QGIS_PLUGIN_SUBDIR_REV ../../MacOS)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)

# Set server moodules path to DEFAULT_LIBEXEC_SUBDIR+'/server'
SET (DEFAULT_SERVER_MODULE_SUBDIR ${DEFAULT_LIBEXEC_SUBDIR}/server)

# path for framework references when running from build directory
# changed later to reference in-app resources upon install
SET (CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
@@ -541,6 +547,8 @@ ELSE (WIN32)
SET (DEFAULT_LIBEXEC_SUBDIR lib${LIB_SUFFIX}/qgis)
SET (DEFAULT_PLUGIN_SUBDIR lib${LIB_SUFFIX}/qgis/plugins)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)

SET (DEFAULT_SERVER_MODULE_SUBDIR ${DEFAULT_LIBEXEC_SUBDIR}/server)
ENDIF (APPLE)

ENDIF (WIN32)
@@ -587,6 +595,8 @@ SET (QGIS_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING "Subdirectory wh
SET (QGIS_PLUGIN_SUBDIR ${DEFAULT_PLUGIN_SUBDIR} CACHE STRING "Subdirectory where plugins will be installed")
SET (QGIS_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING "Subdirectory where header files will be installed")

SET (QGIS_SERVER_MODULE_SUBDIR ${DEFAULT_SERVER_MODULE_SUBDIR} CACHE STRING "Subdirectory where server modules will be installed")

# mark *_SUBDIR variables as advanced as this is not something
# that an average user would use
MARK_AS_ADVANCED (QGIS_BIN_SUBDIR QGIS_CGIBIN_SUBDIR QGIS_LIB_SUBDIR QGIS_LIBEXEC_SUBDIR QGIS_DATA_SUBDIR QGIS_PLUGIN_SUBDIR QGIS_INCLUDE_SUBDIR)
@@ -600,6 +610,8 @@ SET (QGIS_DATA_DIR ${QGIS_DATA_SUBDIR})
SET (QGIS_PLUGIN_DIR ${QGIS_PLUGIN_SUBDIR})
SET (QGIS_INCLUDE_DIR ${QGIS_INCLUDE_SUBDIR})

SET (QGIS_SERVER_MODULE_DIR ${QGIS_SERVER_MODULE_SUBDIR})

# set the default locations where the targets (executables, libraries) will land when compiled
# this is to allow running qgis from the source tree without having to actually do a "make install"
SET (QGIS_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output)
@@ -28,6 +28,8 @@
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}"

#define QGIS_SERVER_MODULE_SUBDIR "${QGIS_SERVER_MODULE_SUBDIR}"

#define QSCINTILLA_VERSION_STR "${QSCINTILLA_VERSION_STR}"

#if defined( __APPLE__ )
@@ -34,6 +34,7 @@ SET (QGIS_PLUGIN_SUBDIR "@QGIS_PLUGIN_SUBDIR@")
SET (QGIS_PLUGIN_SUBDIR_REV "@QGIS_PLUGIN_SUBDIR_REV@")
SET (QGIS_DATA_SUBDIR "@QGIS_DATA_SUBDIR@")
SET (QGIS_DATA_SUBDIR_REV "@QGIS_DATA_SUBDIR_REV@")
SET (QGIS_SERVER_MODULE_SUBDIR "@QGIS_SERVER_MODULE_SUBDIR@")

# optional components
SET (WITH_GLOBE "@WITH_GLOBE@")
@@ -17,7 +17,7 @@
* Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage
* as a standalone command line executable
*/
class QgsRequestHandler
class QgsRequestHandler /Abstract/
{
%TypeHeaderCode
#include "qgsmapserviceexception.h"
@@ -43,7 +43,7 @@ class QgsRequestHandler
// virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) = 0;

/** Allow plugins to return a QgsMapServiceException*/
virtual void setServiceException( const QgsMapServiceException& ex /Transfer/ ) = 0;
void setServiceException( const QgsMapServiceException& ex /Transfer/ );

//! @note not available in Python bindings
// virtual void setXmlResponse( const QDomDocument& doc ) = 0;
@@ -61,57 +61,52 @@ class QgsRequestHandler
// virtual void setGetFeatureResponse( QByteArray* ba ) = 0;

//! @note not available in Python bindings
virtual void endGetFeatureResponse( QByteArray* ba ) = 0;
void endGetFeatureResponse( QByteArray* ba );

//! @note not available in Python bindings
virtual void setGetCoverageResponse( QByteArray* ba ) = 0;

virtual void setDefaultHeaders();
void setGetCoverageResponse( QByteArray* ba );

/** Set an HTTP header*/
virtual void setHeader( const QString &name, const QString &value ) = 0;
void setHeader( const QString &name, const QString &value );

/** Remove an HTTP header*/
virtual int removeHeader( const QString &name ) = 0;
//! Retrieve header value
QString getHeader( const QString& name ) const;

/** Delete all HTTP headers*/
virtual void clearHeaders() = 0;
//! Return the list of all header keys
QList<QString> headerKeys() const;

/** Append the bytestream to response body*/
virtual void appendBody( const QByteArray &body ) = 0;
/** Remove an HTTP header*/
void removeHeader( const QString &name );

/** Clears the response body*/
virtual void clearBody() = 0;
/** Delete all HTTP headers*/
void clear();

/** Return the response body*/
virtual QByteArray body();
/** Append the bytestream to response body*/
void appendBody( const QByteArray &body );

/** Set the info format string such as "text/xml"*/
virtual void setInfoFormat( const QString &format ) = 0;

/** Check whether there is any header set or the body is not empty*/
virtual bool responseReady() const = 0;
void setInfoFormat( const QString &format );

/** Send out HTTP headers and flush output buffer*/
virtual void sendResponse() = 0;
void sendResponse();

/** Pointer to last raised exception*/
virtual bool exceptionRaised() const = 0;
bool exceptionRaised() const;

/** Return a copy of the parsed parameters as a key-value pair, to modify
* a parameter setParameter( const QString &key, const QString &value)
* and removeParameter(const QString &key) must be used
*/
QMap<QString, QString> parameterMap();
QMap<QString, QString> parameterMap() const;

/** Set a request parameter*/
virtual void setParameter( const QString &key, const QString &value ) = 0;
void setParameter( const QString &key, const QString &value );

/** Remove a request parameter*/
virtual int removeParameter( const QString &key ) = 0;
void removeParameter( const QString &key );

/** Return a request parameter*/
virtual QString parameter( const QString &key ) const = 0;
QString parameter( const QString &key ) const;

/** Return the requested format string*/
QString format() const;
@@ -120,13 +115,13 @@ class QgsRequestHandler
QString infoFormat() const;

/** Return true if the HTTP headers were already sent to the client*/
bool headersSent();
bool headersSent() const;


//! @note not available in Python bindings
// virtual QPair<QByteArray, QByteArray> getResponse() = 0;

private:
/** Parses the input and creates a request neutral Parameter/Value map*/
virtual void parseInput() = 0;
void parseInput();
};
@@ -165,7 +165,7 @@ class QgsServer
/** Creates the server instance
* @param captureOutput set to false for stdout output (FCGI)
*/
QgsServer( bool captureOutput = true );
QgsServer();
~QgsServer();

/** Set environment variable
@@ -175,29 +175,31 @@ class QgsServer
*/
void putenv( const QString &var, const QString &val );

/** Handles the request. The output is normally printed trough FCGI printf
* by the request handler or, in case the server has been invoked from python
* bindings, a flag is set that captures all the output headers and body, instead
* of printing it returns the output as a QPair of QByteArray.
/** Handles the request.
* The query string is normally read from environment
* but can be also passed in args and in this case overrides the environment
* variable
*
* @param queryString optional QString containing the query string
* @return the response headers and body QPair of QByteArray if called from python bindings, empty otherwise
* @param request a QgsServerRequest holding request parameters
* @param response a QgsServerResponse for handling response I/O)
*/
QPair<QByteArray, QByteArray> handleRequest( const QString& queryString = QString() );
/*
// The following code was used to test type conversion in python bindings
QPair<QByteArray, QByteArray> testQPair( QPair<QByteArray, QByteArray> pair );
*/
void handleRequest( QgsServerRequest& request, QgsServerResponse& response );

/** Handles the request from query strinf
* The query string is normally read from environment
* but can be also passed in args and in this case overrides the environment
* variable.
*
* @param queryString QString containing the query string
* @return the response headers and body QPair of QByteArray
*/
QPair<QByteArray, QByteArray> handleRequest( const QString& queryString );

/** Returns a pointer to the server interface */
%If (HAVE_SERVER_PYTHON_PLUGINS)
QgsServerInterface* serverInterface();
%End
QgsServerInterface* serverInterface();

private:
QgsServer( const QgsServer& );
QgsServer & operator=( const QgsServer& );
};

@@ -39,7 +39,7 @@ typedef QMultiMap<int, QgsServerFilter*> QgsServerFiltersMap;
class QgsServerInterface
{
%TypeHeaderCode
#include "qgsserverinterface.h"
#include "qgsserverinterface.h"
%End

public:
@@ -61,26 +61,26 @@ class QgsServerInterface
* Get pointer to the capabiblities cache
* @return QgsCapabilitiesCache
*/
virtual QgsCapabilitiesCache* capabilitiesCache() = 0 /KeepReference/;
virtual QgsCapabilitiesCache* capabilitiesCache() = 0 / KeepReference /;

/**
* Get pointer to the request handler
* @return QgsRequestHandler
*/
virtual QgsRequestHandler* requestHandler() = 0 /KeepReference/;
virtual QgsRequestHandler* requestHandler() = 0 / KeepReference /;

/**
* Register a QgsServerFilter
* @param filter the QgsServerFilter to add
* @param priority an optional priority for the filter order
*/
virtual void registerFilter( QgsServerFilter* filter /Transfer/, int priority = 0 ) = 0;
virtual void registerFilter( QgsServerFilter* filter / Transfer / , int priority = 0 ) = 0;

/**
* Set the filters map
* @param filters the QgsServerFiltersMap
*/
virtual void setFilters( QgsServerFiltersMap* filters /Transfer/) = 0;
virtual void setFilters( QgsServerFiltersMap* filters / Transfer / ) = 0;

/**
* Return the list of current QgsServerFilter
@@ -92,13 +92,13 @@ class QgsServerInterface
* @param accessControl the access control to register
* @param priority the priority used to order them
*/
virtual void registerAccessControl( QgsAccessControlFilter* accessControl /Transfer/, int priority = 0 ) = 0;
virtual void registerAccessControl( QgsAccessControlFilter* accessControl / Transfer / , int priority = 0 ) = 0;

/** Gets the registred access control filters */
virtual const QgsAccessControl* accessControls() const = 0;

//! Return an enrironment variable, used to pass environment variables to python
virtual QString getEnv(const QString& name ) const = 0;
virtual QString getEnv( const QString& name ) const = 0;

/**
* Return the configuration file path
@@ -110,7 +110,7 @@ class QgsServerInterface
* Set the configuration file path
* @param configFilePath QString with the configuration file path
*/
virtual void setConfigFilePath( const QString& configFilePath) = 0;
virtual void setConfigFilePath( const QString& configFilePath ) = 0;

/**
* Remove entry from config cache
@@ -124,6 +124,12 @@ class QgsServerInterface
*/
virtual void removeProjectLayers( const QString& path ) = 0;

/**
* Return the service registry
* @return QgsServiceResgistry
*/
virtual QgsServiceRegistry* serviceRegistry() = 0 / KeepReference /;

private:
/** Constructor */
QgsServerInterface();

0 comments on commit 9be984c

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