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);
}
}
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);
}
}
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);
}
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;
}
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);
}
}
Aggregations