Search in sources :

Example 1 with OperationResponseEncoderKey

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;
}
Also used : Encoder(org.n52.svalbard.encode.Encoder) EncoderRepository(org.n52.svalbard.encode.EncoderRepository) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey)

Example 2 with OperationResponseEncoderKey

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;
}
Also used : MediaType(org.n52.janmayen.http.MediaType)

Example 3 with OperationResponseEncoderKey

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

Example 4 with OperationResponseEncoderKey

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);
    }
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 5 with OperationResponseEncoderKey

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());
}
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)

Aggregations

OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)5 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)4 OperationResponseEncoderKey (org.n52.svalbard.encode.OperationResponseEncoderKey)4 XmlObject (org.apache.xmlbeans.XmlObject)3 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)3 Test (org.junit.Test)1 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)1 MediaType (org.n52.janmayen.http.MediaType)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 DescribeSensorResponseEncoder (org.n52.svalbard.encode.DescribeSensorResponseEncoder)1 Encoder (org.n52.svalbard.encode.Encoder)1 EncoderKey (org.n52.svalbard.encode.EncoderKey)1 EncoderRepository (org.n52.svalbard.encode.EncoderRepository)1 EncodingContext (org.n52.svalbard.encode.EncodingContext)1 StreamingEncoder (org.n52.svalbard.encode.StreamingEncoder)1 XmlEncoderKey (org.n52.svalbard.encode.XmlEncoderKey)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1