use of org.n52.svalbard.encode.XmlEncoderKey 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.XmlEncoderKey in project arctic-sea by 52North.
the class AbstractOmV20XmlStreamWriter method writeParameter.
/**
* Write om:parameter to stream
*
* @throws XMLStreamException
* If an error occurs when writing to stream
* @throws EncodingException
* If an error occurs when creating elements to be written
*/
protected void writeParameter() throws XMLStreamException, EncodingException {
XmlEncoderKey key = new XmlEncoderKey(OmConstants.NS_OM_2, NamedValue.class);
Encoder<XmlObject, NamedValue<?>> encoder = getEncoder(key);
if (encoder != null) {
for (NamedValue<?> namedValue : getElement().getParameter()) {
start(OmConstants.QN_OM_20_PARAMETER);
writeXmlObject(encoder.encode(namedValue), OmConstants.QN_OM_20_NAMED_VALUE);
end(OmConstants.QN_OM_20_PARAMETER);
}
}
}
use of org.n52.svalbard.encode.XmlEncoderKey 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)));
}
use of org.n52.svalbard.encode.XmlEncoderKey in project arctic-sea by 52North.
the class SensorMLEncoderv101 method addSweSimpleTypeToField.
/**
* Adds a SOS SWE simple type to a XML SWE field.
*
* @param xbField
* XML SWE field
* @param sosSweData
* SOS field element content
*
* @throws EncodingException
* if an error occurs
*/
private void addSweSimpleTypeToField(AnyScalarPropertyType xbField, SweAbstractDataComponent sosSweData) throws EncodingException {
Encoder<?, SweAbstractDataComponent> encoder = getEncoder(new XmlEncoderKey(SweConstants.NS_SWE_101, SweDataArray.class));
if (encoder == null) {
throw new EncodingException("The %s is not supported by this SOS for SWE fields!", sosSweData.getClass().getSimpleName());
}
XmlObject encoded = (XmlObject) encoder.encode(sosSweData);
if (!(sosSweData instanceof SweAbstractSimpleType)) {
throw new EncodingException("The SosSweAbstractDataComponent '%s' is not supported by this SOS SensorML encoder!", sosSweData);
}
SweAbstractSimpleType<?> sosSweSimpleType = (SweAbstractSimpleType<?>) sosSweData;
sosSweSimpleType.accept(new ScalarSweDataComponentAdder(xbField)).orElseThrow(() -> new EncodingException("The SWE simpleType '%s' is not supported by this SOS SensorML encoder!", sosSweSimpleType.getDataComponentType().name())).set(encoded);
}
Aggregations