use of org.n52.svalbard.encode.EncoderKey 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.EncoderKey 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.EncoderKey in project arctic-sea by 52North.
the class CodingHelper method xmlEncoderKeysForOperationAndMediaType.
public static Set<EncoderKey> xmlEncoderKeysForOperationAndMediaType(String service, String version, String... operations) {
HashSet<EncoderKey> set = new HashSet<>(operations.length);
for (String operation : operations) {
set.add(new OperationRequestEncoderKey(service, version, operation, MediaTypes.TEXT_XML));
set.add(new OperationRequestEncoderKey(service, version, operation, MediaTypes.APPLICATION_XML));
}
return set;
}
use of org.n52.svalbard.encode.EncoderKey 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.EncoderKey in project arctic-sea by 52North.
the class DescribeSensorResponseEncoderTest method should_return_correct_encoder_keys.
@Test
public void should_return_correct_encoder_keys() {
Set<EncoderKey> returnedKeySet = new DescribeSensorResponseEncoder().getKeys();
assertThat(returnedKeySet.size(), is(3));
assertThat(returnedKeySet, hasItem(new XmlEncoderKey(SwesConstants.NS_SWES_20, DescribeSensorResponse.class)));
assertThat(returnedKeySet, hasItem(new OperationResponseEncoderKey(SosConstants.SOS, Sos2Constants.SERVICEVERSION, SosConstants.Operations.DescribeSensor, MediaTypes.TEXT_XML)));
assertThat(returnedKeySet, hasItem(new OperationResponseEncoderKey(SosConstants.SOS, Sos2Constants.SERVICEVERSION, SosConstants.Operations.DescribeSensor, MediaTypes.APPLICATION_XML)));
}
Aggregations