Search in sources :

Example 1 with InvalidParameterValueException

use of org.n52.shetland.ogc.ows.exception.InvalidParameterValueException in project arctic-sea by 52North.

the class KvpBinding method toOwsExceptionReport.

private OwsExceptionReport toOwsExceptionReport(Throwable ex) {
    if (ex instanceof OwsExceptionReport) {
        return (OwsExceptionReport) ex;
    }
    Throwable cause = ex.getCause();
    if (cause instanceof OwsExceptionReport) {
        return (OwsExceptionReport) cause;
    }
    if (ex instanceof CompositeException) {
        return toOwsExceptionReport((CompositeException) ex);
    }
    if (cause instanceof CompositeException) {
        return toOwsExceptionReport((CompositeException) cause);
    }
    String location = null;
    if (ex instanceof LocationHintException) {
        location = ((LocationHintException) ex).getLocation().orElse(null);
    } else if (cause instanceof LocationHintException) {
        location = ((LocationHintException) cause).getLocation().orElse(null);
    }
    return new InvalidParameterValueException().withMessage(ex.getMessage()).causedBy(ex).at(location);
}
Also used : LocationHintException(org.n52.janmayen.exception.LocationHintException) InvalidParameterValueException(org.n52.shetland.ogc.ows.exception.InvalidParameterValueException) CompositeException(org.n52.janmayen.exception.CompositeException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 2 with InvalidParameterValueException

use of org.n52.shetland.ogc.ows.exception.InvalidParameterValueException in project arctic-sea by 52North.

the class AbstractXmlBinding method decode.

protected T decode(HttpServletRequest request) throws OwsExceptionReport {
    String characterEncoding = getCharacterEncoding(request);
    String xmlString = xmlToString(request, characterEncoding);
    LOGGER.debug("XML-REQUEST: {}", xmlString);
    DecoderKey key = getDecoderKey(xmlString, characterEncoding);
    LOGGER.trace("Found decoder key: {}", key);
    Decoder<T, String> decoder = getDecoder(key);
    if (decoder == null) {
        // if this a GetCapabilities request, then the service is not supported
        String opOrType = null;
        Optional<String> service = Optional.empty();
        if (key instanceof XmlNamespaceOperationDecoderKey) {
            XmlNamespaceOperationDecoderKey xmlNamespaceKey = (XmlNamespaceOperationDecoderKey) key;
            opOrType = xmlNamespaceKey.getType();
        } else if (key instanceof XmlStringOperationDecoderKey) {
            XmlStringOperationDecoderKey xmlStringKey = (XmlStringOperationDecoderKey) key;
            opOrType = xmlStringKey.getOperation();
            service = Optional.of(xmlStringKey.getService());
        }
        if (OWSConstants.Operations.GetCapabilities.toString().equalsIgnoreCase(opOrType)) {
            if (service.isPresent()) {
                throw new InvalidParameterValueException(OWSConstants.GetCapabilitiesParams.service, service.get()).withMessage("The service '%s' is not supported.", service);
            } else {
                throw new MissingParameterValueException(OWSConstants.GetCapabilitiesParams.service).withMessage("The parameter '%s' is missing.", OWSConstants.GetCapabilitiesParams.service);
            }
        } else {
            throw new InvalidParameterValueException().withMessage("No decoder found for incoming message " + "based on derived decoder key: %s\nMessage: %s", key, xmlString);
        }
    } else {
        LOGGER.trace("Using decoder: {}", decoder);
    }
    try {
        return decoder.decode(xmlString);
    } catch (OwsDecodingException ex) {
        throw ex.getCause();
    } catch (DecodingException ex) {
        throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
    }
}
Also used : XmlNamespaceOperationDecoderKey(org.n52.svalbard.decode.XmlNamespaceOperationDecoderKey) MissingParameterValueException(org.n52.shetland.ogc.ows.exception.MissingParameterValueException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) InvalidParameterValueException(org.n52.shetland.ogc.ows.exception.InvalidParameterValueException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) DecoderKey(org.n52.svalbard.decode.DecoderKey) XmlStringOperationDecoderKey(org.n52.svalbard.decode.XmlStringOperationDecoderKey) XmlNamespaceOperationDecoderKey(org.n52.svalbard.decode.XmlNamespaceOperationDecoderKey) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) XmlStringOperationDecoderKey(org.n52.svalbard.decode.XmlStringOperationDecoderKey)

Example 3 with InvalidParameterValueException

use of org.n52.shetland.ogc.ows.exception.InvalidParameterValueException in project arctic-sea by 52North.

the class EXIBinding method parseRequest.

/**
 * Parse and decode the incoming EXI encoded {@link InputStream}
 *
 * @param request
 *            {@link HttpServletRequest} with EXI encoded
 *            {@link InputStream}
 * @return {@link OwsServiceRequest} from EXI encoded {@link InputStream}
 * @throws OwsExceptionReport
 *             If an error occurs during parsing
 */
protected OwsServiceRequest parseRequest(HttpServletRequest request) throws OwsExceptionReport {
    XmlObject doc = decode(request);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("EXI-REQUEST: {}", doc.xmlText());
    }
    Decoder<OwsServiceRequest, XmlObject> decoder = getDecoder(CodingHelper.getDecoderKey(doc));
    try {
        return decoder.decode(doc).setRequestContext(getRequestContext(request));
    } catch (OwsDecodingException ex) {
        throw ex.getCause();
    } catch (DecodingException ex) {
        throw new InvalidParameterValueException().withMessage(ex.getMessage()).causedBy(ex).at(ex.getLocation().orElse(null));
    }
}
Also used : OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) InvalidParameterValueException(org.n52.shetland.ogc.ows.exception.InvalidParameterValueException) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OwsDecodingException(org.n52.iceland.coding.decode.OwsDecodingException) OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest)

Aggregations

InvalidParameterValueException (org.n52.shetland.ogc.ows.exception.InvalidParameterValueException)3 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)2 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 XmlObject (org.apache.xmlbeans.XmlObject)1 CompositeException (org.n52.janmayen.exception.CompositeException)1 LocationHintException (org.n52.janmayen.exception.LocationHintException)1 MissingParameterValueException (org.n52.shetland.ogc.ows.exception.MissingParameterValueException)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)1 DecoderKey (org.n52.svalbard.decode.DecoderKey)1 XmlNamespaceOperationDecoderKey (org.n52.svalbard.decode.XmlNamespaceOperationDecoderKey)1 XmlStringOperationDecoderKey (org.n52.svalbard.decode.XmlStringOperationDecoderKey)1