use of org.n52.iceland.exception.ows.concrete.VersionNotSupportedException in project arctic-sea by 52North.
the class SimpleBinding method checkServiceOperatorKeyTypes.
protected void checkServiceOperatorKeyTypes(OwsServiceRequest request) throws OwsExceptionReport {
String service = request.getService();
String version = request.getVersion();
if (service == null || service.isEmpty()) {
throw new MissingServiceParameterException();
} else if (!getServiceOperatorRepository().isServiceSupported(service)) {
throw new InvalidServiceParameterException(service);
} else if (request instanceof GetCapabilitiesRequest) {
GetCapabilitiesRequest gcr = (GetCapabilitiesRequest) request;
if (gcr.isSetAcceptVersions() && !gcr.getAcceptVersions().stream().anyMatch(v -> isVersionSupported(service, v))) {
throw new InvalidAcceptVersionsParameterException(gcr.getAcceptVersions());
}
} else if (version == null || version.isEmpty()) {
throw new MissingVersionParameterException();
} else if (!isVersionSupported(service, version)) {
throw new VersionNotSupportedException();
}
}
use of org.n52.iceland.exception.ows.concrete.VersionNotSupportedException in project arctic-sea by 52North.
the class KvpBinding method parseRequest.
protected OwsServiceRequest parseRequest(HttpServletRequest req) throws OwsExceptionReport {
if (req.getParameterMap() == null || req.getParameterMap().isEmpty()) {
throw new MissingRequestParameterException();
}
Map<String, String> parameters = Streams.stream(req.getParameterNames()).collect(toMap(name -> name.replace("amp;", "").toLowerCase(Locale.ROOT), req::getParameter));
String service = parameters.get(RequestParams.service.name());
String version = parameters.get(RequestParams.version.name());
String operation = parameters.get(RequestParams.request.name());
if (Strings.isNullOrEmpty(service)) {
throw new MissingServiceParameterException();
}
if (!isServiceSupported(service)) {
throw new InvalidServiceParameterException(service);
}
if (Strings.isNullOrEmpty(operation)) {
throw new MissingRequestParameterException();
}
if (version != null && !isVersionSupported(service, version)) {
throw new VersionNotSupportedException();
}
Decoder<OwsServiceRequest, Map<String, String>> decoder = getDecoder(new OperationDecoderKey(service, version, operation, MediaTypes.APPLICATION_KVP));
if (decoder == null) {
throw new OperationNotSupportedException(operation);
}
OwsServiceRequest request;
try {
request = decoder.decode(parameters);
} catch (OwsDecodingException ex) {
throw ex.getCause();
} catch (DecodingException ex) {
throw toOwsExceptionReport(ex);
}
if (this.includeOriginalRequest) {
request.setOriginalRequest(String.join("?", req.getRequestURL(), req.getQueryString()));
}
return request;
}
Aggregations