Search in sources :

Example 31 with MediaType

use of org.n52.janmayen.http.MediaType 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 32 with MediaType

use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.

the class SosDecoderv100 method parseDescribeSensor.

/**
 * parses the XmlBean representing the describeSensor request and creates a
 * DescribeSensor request
 *
 * @param descSensorDoc
 *            XmlBean created from the incoming request stream
 * @return Returns SosDescribeSensorRequest representing the request
 */
private OwsServiceCommunicationObject parseDescribeSensor(DescribeSensorDocument descSensorDoc) {
    DescribeSensorRequest request = new DescribeSensorRequest();
    DescribeSensor descSensor = descSensorDoc.getDescribeSensor();
    request.setService(descSensor.getService());
    request.setVersion(descSensor.getVersion());
    // parse outputFormat through MediaType to ensure it's a mime type and
    // eliminate whitespace variations
    request.setProcedureDescriptionFormat(MediaType.normalizeString(descSensor.getOutputFormat()));
    request.setProcedure(descSensor.getProcedure());
    return request;
}
Also used : DescribeSensor(net.opengis.sos.x10.DescribeSensorDocument.DescribeSensor) DescribeSensorRequest(org.n52.shetland.ogc.sos.request.DescribeSensorRequest)

Aggregations

MediaType (org.n52.janmayen.http.MediaType)28 Test (org.junit.Test)21 HTTPException (org.n52.iceland.exception.HTTPException)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)3 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)2 ExceptionEvent (org.n52.iceland.event.events.ExceptionEvent)2 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)2 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)2 CountingOutputStream (com.google.common.io.CountingOutputStream)1 UncheckedTimeoutException (com.google.common.util.concurrent.UncheckedTimeoutException)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 DescribeSensor (net.opengis.sos.x10.DescribeSensorDocument.DescribeSensor)1 Binding (org.n52.iceland.binding.Binding)1 ResponseProxy (org.n52.iceland.coding.encode.ResponseProxy)1