Search in sources :

Example 6 with NoDecoderForKeyException

use of org.n52.svalbard.decode.exception.NoDecoderForKeyException in project arctic-sea by 52North.

the class SoapBinding method createSoapResponse.

// private void parseBodyRequest(SoapChain chain) throws OwsExceptionReport,
// OwsExceptionReport {
// 
// final XmlObject xmlObject = chain.getSoapRequest().getSoapBodyContent();
// DecoderKey key = CodingHelper.getDecoderKey(xmlObject);
// final Decoder<?, XmlObject> bodyDecoder = getDecoder(key);
// if (bodyDecoder == null) {
// throw new NoDecoderForKeyException(key).setStatus(BAD_REQUEST);
// }
// final Object aBodyRequest = bodyDecoder.decode(xmlObject);
// if (!(aBodyRequest instanceof AbstractServiceRequest)) {
// throw new NoApplicableCodeException().withMessage(
// "The returned object is not an AbstractServiceRequest implementation").setStatus(BAD_REQUEST);
// }
// AbstractServiceRequest bodyRequest = (AbstractServiceRequest)
// aBodyRequest;
// bodyRequest.setRequestContext(getRequestContext(chain.getHttpRequest()));
// if (bodyRequest instanceof CommunicationObjectWithSoapHeader) {
// ((CommunicationObjectWithSoapHeader)
// bodyRequest).setSoapHeader(chain.getSoapRequest().getSoapHeader());
// }
// chain.setBodyRequest(bodyRequest);
// }
private void createSoapResponse(SoapChain chain) {
    SoapResponse soapResponse = new SoapResponse();
    soapResponse.setSoapVersion(chain.getSoapRequest().getSoapVersion());
    soapResponse.setSoapNamespace(chain.getSoapRequest().getSoapNamespace());
    soapResponse.setHeader(checkSoapHeaders(chain.getSoapRequest().getSoapHeader()));
    chain.setSoapResponse(soapResponse);
}
Also used : SoapResponse(org.n52.shetland.w3c.soap.SoapResponse)

Example 7 with NoDecoderForKeyException

use of org.n52.svalbard.decode.exception.NoDecoderForKeyException in project arctic-sea by 52North.

the class GetResultTemplateResponseEncoder method encodeResultEncoding.

private void encodeResultEncoding(GetResultTemplateResponse t, ObjectNode json) throws EncodingException {
    ObjectNode jre = json.putObject(JSONConstants.RESULT_ENCODING);
    SweAbstractEncoding encoding = null;
    SosResultEncoding re = t.getResultEncoding();
    if (re.isDecoded()) {
        encoding = t.getResultEncoding().get().get();
    } else {
        try {
            XmlNamespaceDecoderKey key = new XmlNamespaceDecoderKey(SweConstants.NS_SWE_20, SweAbstractEncoding.class);
            Decoder<SweAbstractEncoding, XmlObject> decoder = this.decoderRepository.getDecoder(key);
            if (decoder == null) {
                throw new NoDecoderForKeyException(key);
            }
            encoding = decoder.decode(XmlObject.Factory.parse(re.getXml().get()));
        } catch (XmlException | DecodingException ex) {
            throw new EncodingException(ex);
        }
    }
    if (encoding instanceof SweTextEncoding) {
        encodeSweTextEncoding(encoding, jre);
    } else {
        LOG.warn("Unsupported encoding: {}", encoding == null ? null : encoding.getClass());
    }
}
Also used : NoDecoderForKeyException(org.n52.svalbard.decode.exception.NoDecoderForKeyException) XmlNamespaceDecoderKey(org.n52.svalbard.decode.XmlNamespaceDecoderKey) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EncodingException(org.n52.svalbard.encode.exception.EncodingException) SweAbstractEncoding(org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding)

Aggregations

NoDecoderForKeyException (org.n52.svalbard.decode.exception.NoDecoderForKeyException)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 XmlObject (org.apache.xmlbeans.XmlObject)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 XmlException (org.apache.xmlbeans.XmlException)2 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)2 OperationDecoderKey (org.n52.svalbard.decode.OperationDecoderKey)2 XmlNamespaceDecoderKey (org.n52.svalbard.decode.XmlNamespaceDecoderKey)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 IOException (java.io.IOException)1 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)1 SosResultEncoding (org.n52.shetland.ogc.sos.SosResultEncoding)1 SosResultStructure (org.n52.shetland.ogc.sos.SosResultStructure)1 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweAbstractEncoding (org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding)1 SweTextEncoding (org.n52.shetland.ogc.swe.encoding.SweTextEncoding)1