Search in sources :

Example 1 with EncoderKey

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);
    }
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) EncoderKey(org.n52.svalbard.encode.EncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException)

Example 2 with EncoderKey

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);
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) EncoderKey(org.n52.svalbard.encode.EncoderKey)

Example 3 with EncoderKey

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;
}
Also used : XmlDocumentEncoderKey(org.n52.svalbard.encode.XmlDocumentEncoderKey) EncoderKey(org.n52.svalbard.encode.EncoderKey) OperationRequestEncoderKey(org.n52.svalbard.encode.OperationRequestEncoderKey) XmlPropertyTypeEncoderKey(org.n52.svalbard.encode.XmlPropertyTypeEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) OperationRequestEncoderKey(org.n52.svalbard.encode.OperationRequestEncoderKey) HashSet(java.util.HashSet)

Example 4 with EncoderKey

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

Example 5 with EncoderKey

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)));
}
Also used : EncoderKey(org.n52.svalbard.encode.EncoderKey) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) DescribeSensorResponseEncoder(org.n52.svalbard.encode.DescribeSensorResponseEncoder) Test(org.junit.Test)

Aggregations

EncoderKey (org.n52.svalbard.encode.EncoderKey)4 XmlEncoderKey (org.n52.svalbard.encode.XmlEncoderKey)3 SoapResponse (org.n52.shetland.w3c.soap.SoapResponse)2 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)2 HashSet (java.util.HashSet)1 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 OperationRequestEncoderKey (org.n52.svalbard.encode.OperationRequestEncoderKey)1 OperationResponseEncoderKey (org.n52.svalbard.encode.OperationResponseEncoderKey)1 XmlDocumentEncoderKey (org.n52.svalbard.encode.XmlDocumentEncoderKey)1 XmlPropertyTypeEncoderKey (org.n52.svalbard.encode.XmlPropertyTypeEncoderKey)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1