use of org.n52.svalbard.encode.OperationResponseEncoderKey in project arctic-sea by 52North.
the class SimpleBindingTest method mockEncoderRepository.
@SuppressWarnings({ "rawtypes", "unchecked" })
private EncoderRepository mockEncoderRepository() {
EncoderRepository encoderRepository = mock(EncoderRepository.class);
OwsOperationKey operationKey = new OwsOperationKey(response);
OperationResponseEncoderKey operationEncoderKey = new OperationResponseEncoderKey(operationKey, MediaTypes.APPLICATION_JSON);
Encoder encoder = Mockito.mock(Encoder.class);
when(encoderRepository.getEncoder(operationEncoderKey)).thenReturn(encoder);
return encoderRepository;
}
use of org.n52.svalbard.encode.OperationResponseEncoderKey in project arctic-sea by 52North.
the class UVFEncoder method createEncoderKeys.
private Set<EncoderKey> createEncoderKeys() {
Set<EncoderKey> keys = Sets.newHashSet();
for (String s : MEDIA_TYPES) {
MediaType mediaType = MediaType.parse(s);
keys.add((EncoderKey) new OperationResponseEncoderKey(SosConstants.SOS, Sos1Constants.SERVICEVERSION, SosConstants.Operations.GetObservation, mediaType));
keys.add((EncoderKey) new OperationResponseEncoderKey(SosConstants.SOS, Sos2Constants.SERVICEVERSION, SosConstants.Operations.GetObservation, mediaType));
keys.add((EncoderKey) new OperationResponseEncoderKey(SosConstants.SOS, Sos1Constants.SERVICEVERSION, SosConstants.Operations.GetObservationById, mediaType));
keys.add((EncoderKey) new OperationResponseEncoderKey(SosConstants.SOS, Sos2Constants.SERVICEVERSION, SosConstants.Operations.GetObservationById, mediaType));
}
return keys;
}
use of org.n52.svalbard.encode.OperationResponseEncoderKey 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.OperationResponseEncoderKey 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);
}
}
use of org.n52.svalbard.encode.OperationResponseEncoderKey in project arctic-sea by 52North.
the class AbstractSoapEncoder method getBodyContent.
/**
* Get the content for the SOAPBody as {@link XmlObject}
*
* @param response SOAP response
*
* @return SOAPBody content as {@link XmlObject}
*
* @throws EncodingException If no encoder is available, the object to encode is not supported or an error occurs
* during the encoding
*/
protected XmlObject getBodyContent(SoapResponse response) throws EncodingException {
OperationResponseEncoderKey key = new OperationResponseEncoderKey(new OwsOperationKey(response.getBodyContent()), MediaTypes.APPLICATION_XML);
Encoder<Object, OwsServiceResponse> encoder = getEncoder(key);
if (encoder == null) {
throw new NoEncoderForKeyException(key);
}
return (XmlObject) encoder.encode(response.getBodyContent());
}
Aggregations