use of org.n52.shetland.ogc.ows.exception.MissingParameterValueException 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);
}
}
Aggregations