Search in sources :

Example 1 with NoEncoderForKeyException

use of org.n52.svalbard.encode.exception.NoEncoderForKeyException in project arctic-sea by 52North.

the class SoapBinding method encodeSoapResponse.

private Object encodeSoapResponse(SoapChain chain) throws OwsExceptionReport, NoEncoderForKeyException {
    EncoderKey key = new XmlEncoderKey(chain.getSoapResponse().getSoapNamespace(), chain.getSoapResponse().getClass());
    Encoder<?, SoapResponse> encoder = getEncoder(key);
    if (encoder != null) {
        try {
            return encoder.encode(chain.getSoapResponse());
        } catch (OwsEncodingException ex) {
            throw ex.getCause();
        } catch (EncodingException ex) {
            throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
        }
    } else {
        NoEncoderForKeyException cause = new NoEncoderForKeyException(key);
        throw new NoApplicableCodeException().withMessage(cause.getMessage()).causedBy(cause);
    }
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) EncoderKey(org.n52.svalbard.encode.EncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException)

Example 2 with NoEncoderForKeyException

use of org.n52.svalbard.encode.exception.NoEncoderForKeyException in project arctic-sea by 52North.

the class SoapBinding method writeOwsExceptionReport.

private void writeOwsExceptionReport(SoapChain chain, OwsExceptionReport owse) throws HTTPException, IOException {
    try {
        String version = chain.hasBodyRequest() ? chain.getBodyRequest().getVersion() : null;
        getEventBus().submit(new ExceptionEvent(owse));
        chain.getSoapResponse().setException(owse.setVersion(version));
        if (!chain.getSoapResponse().hasSoapVersion()) {
            chain.getSoapResponse().setSoapVersion(SOAPConstants.SOAP_1_2_PROTOCOL);
        }
        if (!chain.getSoapResponse().hasSoapNamespace()) {
            chain.getSoapResponse().setSoapNamespace(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
        }
        if (chain.getSoapResponse().hasException() && chain.getSoapResponse().getException().hasStatus()) {
            chain.getHttpResponse().setStatus(chain.getSoapResponse().getException().getStatus().getCode());
        }
        checkSoapInjection(chain);
        httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), encodeSoapResponse(chain), this);
    } catch (OwsExceptionReport | NoEncoderForKeyException t) {
        throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, t);
    }
}
Also used : ExceptionEvent(org.n52.iceland.event.events.ExceptionEvent) NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) HTTPException(org.n52.iceland.exception.HTTPException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 3 with NoEncoderForKeyException

use of org.n52.svalbard.encode.exception.NoEncoderForKeyException in project arctic-sea by 52North.

the class SoapChainResponseWriter method write.

private void write(SoapChain chain, OutputStream out) throws EncodingException, IOException {
    String namespace = chain.getSoapResponse().getSoapNamespace();
    EncoderKey key = CodingHelper.getEncoderKey(namespace, chain.getSoapResponse());
    Encoder<?, SoapResponse> encoder = getEncoder(key);
    if (encoder == null) {
        throw new NoEncoderForKeyException(key);
    }
    write(encoder, chain, out);
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) EncoderKey(org.n52.svalbard.encode.EncoderKey)

Example 4 with NoEncoderForKeyException

use of org.n52.svalbard.encode.exception.NoEncoderForKeyException in project arctic-sea by 52North.

the class AbstractAqdResponseEncoder method getEncoder.

/**
 * Get the {@link Encoder} for the {@link OwsServiceResponse} and the
 * requested contentType
 *
 * @param asr
 *            {@link OwsServiceResponse} to get {@link Encoder} for
 * @return {@link Encoder} for the {@link OwsServiceResponse}
 */
protected Encoder<Object, OwsServiceResponse> getEncoder(OwsServiceResponse asr) {
    OperationResponseEncoderKey key = new OperationResponseEncoderKey(new OwsOperationKey(asr), getContentType());
    Encoder<Object, OwsServiceResponse> encoder = getEncoder(key);
    if (encoder == null) {
        throw new RuntimeException(new NoEncoderForKeyException(key));
    }
    return encoder;
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) XmlObject(org.apache.xmlbeans.XmlObject) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 5 with NoEncoderForKeyException

use of org.n52.svalbard.encode.exception.NoEncoderForKeyException in project arctic-sea by 52North.

the class SimpleBinding method encodeResponse.

protected Object encodeResponse(OwsServiceResponse response, MediaType contentType) throws OwsExceptionReport {
    try {
        OperationResponseEncoderKey key = new OperationResponseEncoderKey(new OwsOperationKey(response), contentType);
        Encoder<Object, OwsServiceResponse> encoder = getEncoder(key);
        if (encoder == null) {
            throw new NoEncoderForKeyException(key);
        }
        return encoder.encode(response);
    } catch (EncodingException ex) {
        throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
    }
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Aggregations

NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)6 OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)3 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)3 XmlObject (org.apache.xmlbeans.XmlObject)2 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)2 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)2 SoapResponse (org.n52.shetland.w3c.soap.SoapResponse)2 EncoderKey (org.n52.svalbard.encode.EncoderKey)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 ExceptionEvent (org.n52.iceland.event.events.ExceptionEvent)1 HTTPException (org.n52.iceland.exception.HTTPException)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 OperationResponseEncoderKey (org.n52.svalbard.encode.OperationResponseEncoderKey)1 XmlEncoderKey (org.n52.svalbard.encode.XmlEncoderKey)1