Skip to content

Commit

Permalink
Update enum
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Apr 11, 2019
1 parent 3ec23ca commit 8e67b26
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/server/services/wms/qgswms.cpp
Expand Up @@ -90,7 +90,7 @@ namespace QgsWms
const QString req = parameters.request();
if ( req.isEmpty() )
{
throw QgsServiceException( QgsServiceException::OGC_OPERATION_NOT_SUPPORTED,
throw QgsServiceException( QgsServiceException::OGC_OperationNotSupported,
QStringLiteral( "Please check the value of the REQUEST parameter" ), 501 );
}

Expand Down Expand Up @@ -153,7 +153,7 @@ namespace QgsWms
else
{
// Operation not supported
throw QgsServiceException( QgsServiceException::OGC_OPERATION_NOT_SUPPORTED,
throw QgsServiceException( QgsServiceException::OGC_OperationNotSupported,
QString( "Request %1 is not supported" ).arg( req ), 501 );
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/server/services/wms/qgswmsgetlegendgraphics.cpp
Expand Up @@ -131,25 +131,25 @@ namespace QgsWms
{
if ( parameters.allLayersNickname().isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
parameters[QgsWmsParameter::LAYERS] );
}

if ( parameters.format() == QgsWmsParameters::Format::NONE )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
parameters[QgsWmsParameter::FORMAT] );
}

if ( ! parameters.bbox().isEmpty() && !parameters.rule().isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "BBOX parameter cannot be combined with RULE." ) );
}

if ( ! parameters.bbox().isEmpty() && parameters.bboxAsRectangle().isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
parameters[QgsWmsParameter::BBOX] );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsgetprint.cpp
Expand Up @@ -50,7 +50,7 @@ namespace QgsWms
contentType = QStringLiteral( "application/pdf" );
break;
default:
throw QgsBadRequestException( QgsServiceException::OGC_INVALID_FORMAT,
throw QgsBadRequestException( QgsServiceException::OGC_InvalidFormat,
parameters[QgsWmsParameter::FORMAT] );
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/server/services/wms/qgswmsgetstyles.cpp
Expand Up @@ -59,14 +59,14 @@ namespace QgsWms

if ( layersName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::LAYERS );
}

QStringList layerList = layersName.split( ',', QString::SkipEmptyParts );
if ( layerList.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::LAYERS );
}

Expand Down Expand Up @@ -96,13 +96,13 @@ namespace QgsWms

if ( styleName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::STYLE );
}

if ( layerName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::LAYERS );
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswmsparameters.cpp
Expand Up @@ -1836,7 +1836,7 @@ namespace QgsWms

void QgsWmsParameters::raiseError( const QString &msg ) const
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE, msg );
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue, msg );
}

QgsWmsParameter QgsWmsParameters::idParameter( const QgsWmsParameter::Name name, const int id ) const
Expand Down
4 changes: 2 additions & 2 deletions src/server/services/wms/qgswmsrendercontext.cpp
Expand Up @@ -436,7 +436,7 @@ void QgsWmsRenderContext::searchLayersToRenderSld()
{
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = lname;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
throw QgsBadRequestException( QgsServiceException::OGC_LayerNotDefined,
param );
}
}
Expand Down Expand Up @@ -482,7 +482,7 @@ void QgsWmsRenderContext::searchLayersToRenderStyle()
{
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = nickname;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
throw QgsBadRequestException( QgsServiceException::OGC_LayerNotDefined,
param );
}
}
Expand Down
54 changes: 27 additions & 27 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -284,7 +284,7 @@ namespace QgsWms
const QString templateName = mWmsParameters.composerTemplate();
if ( templateName.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
QgsWmsParameter::TEMPLATE );
}

Expand All @@ -293,14 +293,14 @@ namespace QgsWms
QgsPrintLayout *sourceLayout( dynamic_cast<QgsPrintLayout *>( lManager->layoutByName( templateName ) ) );
if ( !sourceLayout )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
mWmsParameters[QgsWmsParameter::TEMPLATE ] );
}

// Check that layout has at least one page
if ( sourceLayout->pageCollection()->pageCount() < 1 )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The template has no pages" ) );
}

Expand All @@ -315,14 +315,14 @@ namespace QgsWms
if ( !atlas || !atlas->enabled() )
{
//error
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The template has no atlas enabled" ) );
}

QgsVectorLayer *cLayer = atlas->coverageLayer();
if ( !cLayer )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The atlas has no coverage layer" ) );
}

Expand All @@ -333,7 +333,7 @@ namespace QgsWms
atlas->updateFeatures();
if ( atlas->count() > maxAtlasFeatures )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QString( "The project configuration allows printing maximum %1 atlas features at a time" ).arg( maxAtlasFeatures ) );
}
}
Expand All @@ -353,14 +353,14 @@ namespace QgsWms
int nAtlasFeatures = atlasPk.size() / pkIndexes.size();
if ( nAtlasFeatures * pkIndexes.size() != atlasPk.size() ) //Test is atlasPk.size() is a multiple of pkIndexes.size(). Bail out if not
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "Wrong number of ATLAS_PK parameters" ) );
}

//number of atlas features might be restricted
if ( nAtlasFeatures > maxAtlasFeatures )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QString( "%1 atlas features have been requestet, but the project configuration only allows printing %2 atlas features at a time" )
.arg( nAtlasFeatures ).arg( maxAtlasFeatures ) );
}
Expand Down Expand Up @@ -526,7 +526,7 @@ namespace QgsWms
}
else //unknown format
{
throw QgsBadRequestException( QgsServiceException::OGC_INVALID_FORMAT,
throw QgsBadRequestException( QgsServiceException::OGC_InvalidFormat,
mWmsParameters[QgsWmsParameter::FORMAT] );
}

Expand Down Expand Up @@ -846,15 +846,15 @@ namespace QgsWms
{
QgsWmsParameter param( QgsWmsParameter::I );
param.mValue = i;
throw QgsBadRequestException( QgsServiceException::OGC_INVALID_POINT,
throw QgsBadRequestException( QgsServiceException::OGC_InvalidPoint,
param );
}

if ( j < 0 || j > mapSettings.outputSize().height() )
{
QgsWmsParameter param( QgsWmsParameter::J );
param.mValue = j;
throw QgsBadRequestException( QgsServiceException::OGC_INVALID_POINT,
throw QgsBadRequestException( QgsServiceException::OGC_InvalidPoint,
param );
}

Expand All @@ -870,7 +870,7 @@ namespace QgsWms
// The QUERY_LAYERS parameter is Mandatory
if ( mWmsParameters.queryLayersNickname().isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue,
mWmsParameters[QgsWmsParameter::QUERY_LAYERS] );
}

Expand All @@ -887,13 +887,13 @@ namespace QgsWms
if ( mWmsParameters.j().isEmpty() )
parameter = mWmsParameters[QgsWmsParameter::J];

throw QgsBadRequestException( QgsServiceException::QGIS_MISSING_PARAMETER_VALUE, parameter );
throw QgsBadRequestException( QgsServiceException::QGIS_MissingParameterValue, parameter );
}

const QgsWmsParameters::Format infoFormat = mWmsParameters.infoFormat();
if ( infoFormat == QgsWmsParameters::Format::NONE )
{
throw QgsBadRequestException( QgsServiceException::OGC_INVALID_FORMAT,
throw QgsBadRequestException( QgsServiceException::OGC_InvalidFormat,
mWmsParameters[QgsWmsParameter::INFO_FORMAT] );
}

Expand Down Expand Up @@ -970,7 +970,7 @@ namespace QgsWms
QgsRectangle mapExtent = mWmsParameters.bboxAsRectangle();
if ( !mWmsParameters.bbox().isEmpty() && mapExtent.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
mWmsParameters[QgsWmsParameter::BBOX] );
}

Expand Down Expand Up @@ -1001,12 +1001,12 @@ namespace QgsWms

if ( width <= 0 )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
mWmsParameters[QgsWmsParameter::WIDTH] );
}
else if ( height <= 0 )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
mWmsParameters[QgsWmsParameter::HEIGHT] );
}

Expand Down Expand Up @@ -1054,7 +1054,7 @@ namespace QgsWms
QgsRectangle mapExtent = mWmsParameters.bboxAsRectangle();
if ( !mWmsParameters.bbox().isEmpty() && mapExtent.isEmpty() )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
mWmsParameters[QgsWmsParameter::BBOX] );
}

Expand All @@ -1080,12 +1080,12 @@ namespace QgsWms

if ( mWmsParameters.versionAsNumber() >= QgsProjectVersion( 1, 3, 0 ) )
{
code = QgsServiceException::OGC_INVALID_CRS;
code = QgsServiceException::OGC_InvalidCRS;
parameter = mWmsParameters[ QgsWmsParameter::CRS ];
}
else
{
code = QgsServiceException::OGC_INVALID_SRS;
code = QgsServiceException::OGC_InvalidSRS;
parameter = mWmsParameters[ QgsWmsParameter::SRS ];
}

Expand Down Expand Up @@ -1322,7 +1322,7 @@ namespace QgsWms
{
QgsWmsParameter param( QgsWmsParameter::LAYER );
param.mValue = queryLayer;
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_DEFINED,
throw QgsBadRequestException( QgsServiceException::OGC_LayerNotDefined,
param );
}
else if ( ( validLayer && !queryableLayer ) || ( !validLayer && mContext.isValidGroup( queryLayer ) ) )
Expand Down Expand Up @@ -1359,7 +1359,7 @@ namespace QgsWms
// Only throw if it's not a group or the group has no queryable children
if ( ! hasGroupAndQueryable )
{
throw QgsBadRequestException( QgsServiceException::OGC_LAYER_NOT_QUERYABLE,
throw QgsBadRequestException( QgsServiceException::OGC_LayerNotQueryable,
param );
}
}
Expand Down Expand Up @@ -1897,7 +1897,7 @@ namespace QgsWms
int width = this->width();
if ( wmsMaxWidth != -1 && width > wmsMaxWidth )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The requested map width is too large" ) );
}

Expand All @@ -1919,7 +1919,7 @@ namespace QgsWms
int height = this->height();
if ( wmsMaxHeight != -1 && height > wmsMaxHeight )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The requested map height is too large" ) );
}

Expand Down Expand Up @@ -1948,7 +1948,7 @@ namespace QgsWms
|| std::numeric_limits<int>::max() / static_cast<uint>( bytes_per_line ) < static_cast<uint>( height )
|| std::numeric_limits<int>::max() / sizeof( uchar * ) < static_cast<uint>( height ) )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "The requested map size is too large" ) );
}
}
Expand Down Expand Up @@ -2778,7 +2778,7 @@ namespace QgsWms
QString errorMsg;
if ( !filterXml.setContent( filter.mFilter, true, &errorMsg ) )
{
throw QgsBadRequestException( QgsServiceException::QGIS_INVALID_PARAMETER_VALUE,
throw QgsBadRequestException( QgsServiceException::QGIS_InvalidParameterValue,
QStringLiteral( "Filter string rejected. Error message: %1. The XML string was: %2" ).arg( errorMsg, filter.mFilter ) );
}
QDomElement filterElem = filterXml.firstChildElement();
Expand Down Expand Up @@ -2992,7 +2992,7 @@ namespace QgsWms
bool rc = layer->styleManager()->setCurrentStyle( style );
if ( ! rc )
{
throw QgsBadRequestException( QgsServiceException::OGC_STYLE_NOT_DEFINED,
throw QgsBadRequestException( QgsServiceException::OGC_StyleNotDefined,
QStringLiteral( "Style '%1' does not exist for layer '%2'" ).arg( style, layer->name() ) );
}
}
Expand Down

0 comments on commit 8e67b26

Please sign in to comment.