use of org.n52.shetland.ogc.ows.exception.OperationNotSupportedException 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;
}
use of org.n52.shetland.ogc.ows.exception.OperationNotSupportedException in project arctic-sea by 52North.
the class EventHandlerFinderTest method findSubclassAsHandler.
@Test
public void findSubclassAsHandler() {
Map<String, StatisticsServiceEventHandler<?>> handlers = new HashMap<>();
CodedExceptionEventHandler handler = new CodedExceptionEventHandler();
OperationNotSupportedException exception = new OperationNotSupportedException("GetCapabilities");
handlers.put("CodedException", handler);
Assert.assertNotNull(EventHandlerFinder.findHandler(exception, handlers));
}
use of org.n52.shetland.ogc.ows.exception.OperationNotSupportedException in project arctic-sea by 52North.
the class GenericServiceOperator method receiveRequest.
/**
* {@inheritDoc}
*
* @throws OperationNotSupportedException if no matching
* {@link RequestOperator} could be
* found or if the operator returned
* a {@code null}-response.
*/
@Override
public OwsServiceResponse receiveRequest(OwsServiceRequest request) throws OwsExceptionReport {
String operationName = request.getOperationName();
RequestOperator operator = this.requestOperatorRepository.getRequestOperator(this.key, operationName);
if (operator == null) {
throw new OperationNotSupportedException(operationName);
}
OwsServiceResponse response = operator.receiveRequest(request);
if (response == null) {
throw new OperationNotSupportedException(operationName);
}
return response;
}
use of org.n52.shetland.ogc.ows.exception.OperationNotSupportedException in project arctic-sea by 52North.
the class GenericRequestOperator method receiveRequest.
@Override
public OwsServiceResponse receiveRequest(final OwsServiceRequest abstractRequest) throws OwsExceptionReport {
this.eventBus.submit(new RequestEvent(abstractRequest));
if (requestType.isAssignableFrom(abstractRequest.getClass())) {
Q request = requestType.cast(abstractRequest);
checkForModifierAndProcess(request);
this.validator.validate(request);
A response = receive(request);
this.eventBus.submit(new ResponseEvent(response));
checkForModifierAndProcess(request, response);
return response;
} else {
throw new OperationNotSupportedException(abstractRequest.getOperationName());
}
}
Aggregations