2014-10-10 19:28:20 +02:00
|
|
|
/***************************************************************************
|
|
|
|
qgsrequesthandler.sip
|
|
|
|
|
|
|
|
This class is an interface hiding the details of reading input and
|
|
|
|
writing output from/to a wms request mechanism
|
|
|
|
-------------------
|
|
|
|
begin : 2014-09-10
|
|
|
|
copyright : (C) 2014 by Alessandro Pasotti
|
|
|
|
email : a dot pasotti at itopen dot it
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class QgsRequestHandler
|
|
|
|
* \brief This class is an interface hiding the details of reading input and
|
|
|
|
* writing output from/to a wms request mechanism.
|
|
|
|
*
|
|
|
|
* Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage
|
|
|
|
* as a standalone command line executable
|
|
|
|
*/
|
|
|
|
|
2014-10-09 15:05:19 +02:00
|
|
|
class QgsRequestHandler
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsmapserviceexception.h"
|
|
|
|
#include "qgsrequesthandler.h"
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Allow plugins to return a QgsMapServiceException*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual void setServiceException( QgsMapServiceException ex /Transfer/ ) = 0;
|
2015-07-07 14:57:18 +02:00
|
|
|
virtual void setDefaultHeaders();
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set an HTTP header*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual void setHeader( const QString &name, const QString &value ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove an HTTP header*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual int removeHeader( const QString &name ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Delete all HTTP headers*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual void clearHeaders( ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Append the bytestream to response body*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual void appendBody( const QByteArray &body ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Clears the response body*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual void clearBody( ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the response body*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual QByteArray body();
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set the info format string such as "text/xml"*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual void setInfoFormat( const QString &format ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Check whether there is any header set or the body is not empty*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual bool responseReady() const = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Send out HTTP headers and flush output buffer*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual void sendResponse( ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Pointer to last raised exception*/
|
2014-10-09 15:05:19 +02:00
|
|
|
virtual bool exceptionRaised() const = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return a copy of the parsed parameters as a key-value pair, to modify
|
2014-10-10 19:28:20 +02:00
|
|
|
* a parameter setParameter( const QString &key, const QString &value)
|
|
|
|
* and removeParameter(const QString &key) must be used
|
|
|
|
*/
|
2015-02-03 02:21:52 +01:00
|
|
|
QMap<QString, QString> parameterMap();
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set a request parameter*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual void setParameter( const QString &key, const QString &value ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove a request parameter*/
|
2015-02-03 02:21:52 +01:00
|
|
|
virtual int removeParameter( const QString &key ) = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return a request parameter*/
|
The plugin define the following methods:
* layerFilterExpression
Return an additional filter, used in
WMS/GetMap, WMS/GetFeatureInfo, WFS/GetFeature to filter the features
* layerFilterSubsetString
Return an additional the subset string (typically SQL) filter.
Faster than the layerFilterExpression but not supported on all the
type of layer
* layerPermissions
Change the rights on the layer per user (known by the plugin)
Concern rights: publish, insert, update, delete.
Mostly used in WFS/Transaction, and the publish in all requests.
* authorizedLayerAttributes
Be able to show some attributes only for a subset of user
Used in: WMS/GetFeatureInfo, WFS/GetFeature
* allowToEdit
Be able to don't allow to edit a particular feature, in our case base
on the Geometry
Used in: WFS/Transaction
* cacheKey
Cache key to used to create the capabilities cache, "" for no cache,
shouldn't contains any "-", default to ""
2015-05-19 15:53:51 +02:00
|
|
|
virtual QString parameter( const QString &key ) const = 0;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the requested format string*/
|
2014-10-09 15:05:19 +02:00
|
|
|
QString format() const;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the mime type for the response*/
|
2014-10-10 19:28:20 +02:00
|
|
|
QString infoFormat() const;
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return true if the HTTP headers were already sent to the client*/
|
2015-02-04 01:37:05 +01:00
|
|
|
bool headersSent();
|
2015-02-04 07:15:49 +01:00
|
|
|
private:
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Parses the input and creates a request neutral Parameter/Value map*/
|
2015-02-04 07:15:49 +01:00
|
|
|
virtual void parseInput() = 0;
|
2014-10-09 15:05:19 +02:00
|
|
|
};
|