use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method checkAndAddIdentifier.
private void checkAndAddIdentifier(ObservationProcess op, ObservationProcessType opt) throws EncodingException {
if (op.isSetIdentifier() && !opt.isSetIdentifier()) {
CodeWithAuthority codeWithAuthority = op.getIdentifierCodeWithAuthority();
Encoder<?, CodeWithAuthority> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, codeWithAuthority));
if (encoder != null) {
XmlObject xmlObject = (XmlObject) encoder.encode(codeWithAuthority);
opt.addNewIdentifier().set(xmlObject);
} else {
throw new EncodingException("Error while encoding geometry value, needed encoder is missing!");
}
}
}
use of org.n52.svalbard.encode.Encoder 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());
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfObservationsAreMissing.
@Test
public void shouldThrowExceptionIfObservationsAreMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertObservationRequestEncoder.class.getSimpleName() + " can not encode 'missing observation(s)'"));
InsertObservationRequest request = new InsertObservationRequest("SOS", "2.0.0");
request.setOfferings(Arrays.asList(OFFERING_ID));
encoder.create(request);
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfVersionIsMissing.
@Test
public void shouldThrowExceptionIfVersionIsMissing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertObservationRequestEncoder.class.getSimpleName() + " can not encode 'missing version'"));
encoder.create(new InsertObservationRequest("SOS", ""));
}
use of org.n52.svalbard.encode.Encoder in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method shouldThrowExceptionIfVersionIsNot200Missing.
@Test
public void shouldThrowExceptionIfVersionIsNot200Missing() throws EncodingException {
thrown.expect(UnsupportedEncoderInputException.class);
thrown.expectMessage(Is.is("Encoder " + InsertObservationRequestEncoder.class.getSimpleName() + " can not encode 'SOS 1.0.0 insert observation request'"));
encoder.create(new InsertObservationRequest("SOS", "1.0.0"));
}
Aggregations