Search in sources :

Example 1 with OperationNotSupportedException

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;
}
Also used : MediaTypes(org.n52.janmayen.http.MediaTypes) InvalidParameterValueException(org.n52.shetland.ogc.ows.exception.InvalidParameterValueException) Decoder(org.n52.svalbard.decode.Decoder) HTTPException(org.n52.iceland.exception.HTTPException) LoggerFactory(org.slf4j.LoggerFactory) MediaType(org.n52.janmayen.http.MediaType) SosConstants(org.n52.shetland.ogc.sos.SosConstants) LocationHintException(org.n52.janmayen.exception.LocationHintException) Strings(com.google.common.base.Strings) HttpServletRequest(javax.servlet.http.HttpServletRequest) Collectors.toMap(java.util.stream.Collectors.toMap) Locale(java.util.Locale) Map(java.util.Map) Collector(java.util.stream.Collector) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse) MediaTypeBindingKey(org.n52.iceland.binding.MediaTypeBindingKey) SimpleBinding(org.n52.iceland.binding.SimpleBinding) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) CompositeException(org.n52.janmayen.exception.CompositeException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) Logger(org.slf4j.Logger) HttpServletResponse(javax.servlet.http.HttpServletResponse) OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) Set(java.util.Set) Setting(org.n52.faroe.annotation.Setting) IOException(java.io.IOException) MiscSettings(org.n52.iceland.service.MiscSettings) BindingKey(org.n52.iceland.binding.BindingKey) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) MissingRequestParameterException(org.n52.iceland.exception.ows.concrete.MissingRequestParameterException) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) InvalidServiceParameterException(org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException) ConformanceClasses(org.n52.svalbard.ConformanceClasses) OperationDecoderKey(org.n52.svalbard.decode.OperationDecoderKey) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) Streams(org.n52.janmayen.stream.Streams) VersionNotSupportedException(org.n52.iceland.exception.ows.concrete.VersionNotSupportedException) Configurable(org.n52.faroe.annotation.Configurable) CompositeOwsException(org.n52.shetland.ogc.ows.exception.CompositeOwsException) Collections(java.util.Collections) RequestParams(org.n52.shetland.ogc.ows.OWSConstants.RequestParams) MissingServiceParameterException(org.n52.shetland.ogc.ows.exception.MissingServiceParameterException) OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) InvalidServiceParameterException(org.n52.iceland.exception.ows.concrete.InvalidServiceParameterException) MissingRequestParameterException(org.n52.iceland.exception.ows.concrete.MissingRequestParameterException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) VersionNotSupportedException(org.n52.iceland.exception.ows.concrete.VersionNotSupportedException) MissingServiceParameterException(org.n52.shetland.ogc.ows.exception.MissingServiceParameterException) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) OperationDecoderKey(org.n52.svalbard.decode.OperationDecoderKey)

Example 2 with OperationNotSupportedException

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));
}
Also used : OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) HashMap(java.util.HashMap) CodedExceptionEventHandler(org.n52.iceland.statistics.impl.handlers.exceptions.CodedExceptionEventHandler) StatisticsServiceEventHandler(org.n52.iceland.statistics.api.interfaces.StatisticsServiceEventHandler) Test(org.junit.Test)

Example 3 with OperationNotSupportedException

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;
}
Also used : OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) RequestOperator(org.n52.iceland.request.operator.RequestOperator) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 4 with OperationNotSupportedException

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());
    }
}
Also used : OperationNotSupportedException(org.n52.shetland.ogc.ows.exception.OperationNotSupportedException) RequestEvent(org.n52.iceland.event.events.RequestEvent) ResponseEvent(org.n52.iceland.event.events.ResponseEvent)

Aggregations

OperationNotSupportedException (org.n52.shetland.ogc.ows.exception.OperationNotSupportedException)4 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)2 Strings (com.google.common.base.Strings)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Set (java.util.Set)1 Collector (java.util.stream.Collector)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Test (org.junit.Test)1 Configurable (org.n52.faroe.annotation.Configurable)1 Setting (org.n52.faroe.annotation.Setting)1 BindingKey (org.n52.iceland.binding.BindingKey)1 MediaTypeBindingKey (org.n52.iceland.binding.MediaTypeBindingKey)1 SimpleBinding (org.n52.iceland.binding.SimpleBinding)1 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)1