Search in sources :

Example 16 with HTTPException

use of org.n52.iceland.exception.HTTPException 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)

Example 17 with HTTPException

use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.

the class JSONBinding method doPostOperation.

@Override
public void doPostOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
    OwsServiceRequest request = null;
    try {
        request = parseRequest(req);
        checkServiceOperatorKeyTypes(request);
        OwsServiceResponse response = getServiceOperator(request).receiveRequest(request);
        writeResponse(req, res, response);
    } catch (OwsExceptionReport oer) {
        oer.setVersion(request != null ? request.getVersion() : null);
        LOG.warn("Unexpected error", oer);
        writeOwsExceptionReport(req, res, oer);
    }
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 18 with HTTPException

use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.

the class KvpBinding method doGetOperation.

@Override
public void doGetOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
    LOGGER.debug("KVP-REQUEST: {}", req.getQueryString());
    OwsServiceRequest serviceRequest = null;
    try {
        serviceRequest = parseRequest(req);
        // add request context information
        serviceRequest.setRequestContext(getRequestContext(req));
        OwsServiceResponse response = getServiceOperator(serviceRequest).receiveRequest(serviceRequest);
        writeResponse(req, res, response);
    } catch (OwsExceptionReport oer) {
        oer.setVersion(serviceRequest != null ? serviceRequest.getVersion() : null);
        writeOwsExceptionReport(req, res, oer);
    }
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Aggregations

HTTPException (org.n52.iceland.exception.HTTPException)10 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)8 Stopwatch (com.google.common.base.Stopwatch)5 MediaType (org.n52.janmayen.http.MediaType)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ExceptionEvent (org.n52.iceland.event.events.ExceptionEvent)4 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)4 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)4 Binding (org.n52.iceland.binding.Binding)2 CountingOutputStream (com.google.common.io.CountingOutputStream)1 UncheckedTimeoutException (com.google.common.util.concurrent.UncheckedTimeoutException)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)1 ResponseProxy (org.n52.iceland.coding.encode.ResponseProxy)1 CountingOutputStreamEvent (org.n52.iceland.event.events.CountingOutputStreamEvent)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 SoapChain (org.n52.shetland.w3c.soap.SoapChain)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1