Search in sources :

Example 26 with MediaType

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

the class MediaTypeTest method applicationXmlWithQAndVAndSpaces.

@Test
public void applicationXmlWithQAndVAndSpaces() {
    MediaType mt = MediaType.parse(" application/xml; q=1; v=2 ");
    errors.checkThat(mt.getType(), is("application"));
    errors.checkThat(mt.getSubtype(), is("xml"));
    errors.checkThat(mt.getParameters().size(), is(2));
    errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
    errors.checkThat(mt.getParameter("v").iterator().next(), is("2"));
}
Also used : MediaType(org.n52.janmayen.http.MediaType) Test(org.junit.Test)

Example 27 with MediaType

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

the class MediaTypeTest method applicationXmlWithQAndSixSpace.

@Test
public void applicationXmlWithQAndSixSpace() {
    MediaType mt = MediaType.parse(" application/xml; q=1 ");
    errors.checkThat(mt.getType(), is("application"));
    errors.checkThat(mt.getSubtype(), is("xml"));
    errors.checkThat(mt.getParameters().size(), is(1));
    errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
}
Also used : MediaType(org.n52.janmayen.http.MediaType) Test(org.junit.Test)

Example 28 with MediaType

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

the class MediaTypeTest method applicationXmlWithQAndV.

@Test
public void applicationXmlWithQAndV() {
    MediaType mt = MediaType.parse("application/xml;q=1;v=2");
    errors.checkThat(mt.getType(), is("application"));
    errors.checkThat(mt.getSubtype(), is("xml"));
    errors.checkThat(mt.getParameters().size(), is(2));
    errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
    errors.checkThat(mt.getParameter("v").iterator().next(), is("2"));
}
Also used : MediaType(org.n52.janmayen.http.MediaType) Test(org.junit.Test)

Example 29 with MediaType

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

the class MediaTypeTest method applicationXmlWithQuotedParameterAndSpaces.

@Test
public void applicationXmlWithQuotedParameterAndSpaces() {
    MediaType mt = MediaType.parse(" application/xml; a=\"asdf\" ");
    errors.checkThat(mt.getType(), is("application"));
    errors.checkThat(mt.getSubtype(), is("xml"));
    errors.checkThat(mt.getParameters().size(), is(1));
    errors.checkThat(mt.getParameter("a").iterator().next(), is("asdf"));
}
Also used : MediaType(org.n52.janmayen.http.MediaType) Test(org.junit.Test)

Example 30 with MediaType

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

the class SimpleBinding method writeOwsExceptionReport.

protected void writeOwsExceptionReport(HttpServletRequest request, HttpServletResponse response, OwsExceptionReport oer) throws HTTPException {
    try {
        this.eventBus.submit(new ExceptionEvent(oer));
        MediaType contentType = chooseResponseContentTypeForExceptionReport(HTTPHeaders.getAcceptHeader(request), getDefaultContentType());
        Object encoded = encodeOwsExceptionReport(oer, contentType);
        if (isUseHttpResponseCodes() && oer.hasStatus()) {
            response.setStatus(oer.getStatus().getCode());
        }
        httpUtils.writeObject(request, response, contentType, encoded, this);
    } catch (IOException | OwsExceptionReport e) {
        throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : ExceptionEvent(org.n52.iceland.event.events.ExceptionEvent) HTTPException(org.n52.iceland.exception.HTTPException) MediaType(org.n52.janmayen.http.MediaType) IOException(java.io.IOException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

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