Skip to content

Commit

Permalink
Merge pull request #1219 from lat-lon/fixWmsExceptions-7678-1182
Browse files Browse the repository at this point in the history
Fix exception type for WMS
  • Loading branch information
stephanr authored Nov 17, 2021
2 parents bc4e5ea + 0aa5efb commit 2f97fc6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,13 @@ private void parse130( Map<String, String> map, MapOptionsMaps exts )
throw new OWSException( "The BBOX parameter is missing.", OWSException.MISSING_PARAMETER_VALUE );
}

double[] vals = splitAsDoubles( box, "," );
double[] vals;
try {
vals = splitAsDoubles( box, "," );
} catch ( NumberFormatException e ) {
throw new OWSException( "The value of the BBOX parameter is invalid: " + box,
OWSException.INVALID_PARAMETER_VALUE );
}
if ( vals.length != 4 ) {
throw new OWSException( "The value of the BBOX parameter had too many values: " + box,
OWSException.INVALID_PARAMETER_VALUE );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
package org.deegree.services.wms.controller;

import static javax.imageio.ImageIO.write;
import static org.deegree.commons.ows.exception.OWSException.NO_APPLICABLE_CODE;
import static org.deegree.commons.ows.exception.OWSException.OPERATION_NOT_SUPPORTED;
import static org.deegree.commons.utils.ArrayUtils.join;
import static org.deegree.commons.utils.CollectionUtils.getStringJoiner;
Expand Down Expand Up @@ -345,7 +346,7 @@ public void doKVP( Map<String, String> map, HttpServletRequest request, HttpResp
WMSRequestType req;
String requestName = map.get( "REQUEST" );
try {
req = (WMSRequestType) ( (ImplementationMetadata<?>) ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata() ).getRequestTypeByName( requestName );
req = parseRequest( requestName );
} catch ( IllegalArgumentException e ) {
controllers.get( version ).sendException( new OWSException( get( "WMS.OPERATION_NOT_KNOWN", requestName ),
OWSException.OPERATION_NOT_SUPPORTED ),
Expand Down Expand Up @@ -373,7 +374,20 @@ public void doKVP( Map<String, String> map, HttpServletRequest request, HttpResp
LOG.trace( "Stack trace of OWSException being sent", e );

controllers.get( version ).handleException( map, req, e, response, this );
} catch ( Exception e ) {
LOG.debug( "OWS-Exception: {}", e.getMessage() );
LOG.trace( e.getMessage(), e );
controllers.get( version ).handleException( map, req, new OWSException( e.getMessage(), NO_APPLICABLE_CODE ), response, this );
}
}

private WMSRequestType parseRequest( String requestName ) {
WMSRequestType requestType = (WMSRequestType) ( (ImplementationMetadata<?>) ( (OWSProvider) getMetadata().getProvider() ).getImplementationMetadata() ).getRequestTypeByName(
requestName );
if ( requestType == null ) {
throw new IllegalArgumentException( "Request type " + requestName + "is not known." );
}
return requestType;
}

private void handleRequest( WMSRequestType req, HttpResponseBuffer response, Map<String, String> map,
Expand Down Expand Up @@ -1168,10 +1182,10 @@ private String getVersionValueFromRequest( Map<String, String> map ) {

/**
* <code>Controller</code>
*
*
* @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
* @author last edited by: $Author$
*
*
* @version $Revision$, $Date$
*/
public interface Controller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ private void writeExceptionCatchExceptions( Map<String, String> map, OWSExceptio
}

private boolean isSupportedFormatForRequestType( WMSRequestType req, String exceptions ) {
if ( req == null ) {
if ( EXCEPTION_BLANK.equals( exceptions ) || EXCEPTION_INIMAGE.equals( exceptions ) )
return false;
return true;
}
switch ( req ) {
case map:
case GetMap:
Expand Down

0 comments on commit 2f97fc6

Please sign in to comment.