Search in sources :

Example 41 with Encoder

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!");
        }
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 42 with Encoder

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());
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 43 with Encoder

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);
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) Test(org.junit.Test)

Example 44 with Encoder

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", ""));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) Test(org.junit.Test)

Example 45 with Encoder

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"));
}
Also used : InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 XmlObject (org.apache.xmlbeans.XmlObject)19 EncodingException (org.n52.svalbard.encode.exception.EncodingException)17 XmlOptions (org.apache.xmlbeans.XmlOptions)7 InsertResultTemplateRequest (org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)7 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)7 Before (org.junit.Before)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)5 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)5 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)5 OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)5 InsertObservationRequest (org.n52.shetland.ogc.sos.request.InsertObservationRequest)5 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)5 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)4 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)4 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)4 InsertResultRequest (org.n52.shetland.ogc.sos.request.InsertResultRequest)4 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)4 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)4 CodeType (org.n52.shetland.ogc.gml.CodeType)3