Search in sources :

Example 11 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport 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 12 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SoapBinding method createBodyResponse.

private void createBodyResponse(SoapChain chain) throws OwsExceptionReport {
    OwsServiceRequest req = chain.getSoapRequest().getSoapBodyContent();
    chain.setBodyResponse(getServiceOperator(req).receiveRequest(req));
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest)

Example 13 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class SoapBinding method writeOwsExceptionReport.

private void writeOwsExceptionReport(SoapChain chain, OwsExceptionReport owse) throws HTTPException, IOException {
    try {
        String version = chain.hasBodyRequest() ? chain.getBodyRequest().getVersion() : null;
        getEventBus().submit(new ExceptionEvent(owse));
        chain.getSoapResponse().setException(owse.setVersion(version));
        if (!chain.getSoapResponse().hasSoapVersion()) {
            chain.getSoapResponse().setSoapVersion(SOAPConstants.SOAP_1_2_PROTOCOL);
        }
        if (!chain.getSoapResponse().hasSoapNamespace()) {
            chain.getSoapResponse().setSoapNamespace(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
        }
        if (chain.getSoapResponse().hasException() && chain.getSoapResponse().getException().hasStatus()) {
            chain.getHttpResponse().setStatus(chain.getSoapResponse().getException().getStatus().getCode());
        }
        checkSoapInjection(chain);
        httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), encodeSoapResponse(chain), this);
    } catch (OwsExceptionReport | NoEncoderForKeyException t) {
        throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, t);
    }
}
Also used : ExceptionEvent(org.n52.iceland.event.events.ExceptionEvent) NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) HTTPException(org.n52.iceland.exception.HTTPException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 14 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class AbstractGetCapabilitiesHandler method handle.

@Override
public GetCapabilitiesResponse handle(GetCapabilitiesRequest request) throws OwsExceptionReport {
    String service = request.getService();
    String version = negotiateVersion(request);
    GetCapabilitiesResponse response = createResponse(service, version);
    response.setCapabilities(createCapabilities(request, service, version));
    return response;
}
Also used : GetCapabilitiesResponse(org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse)

Example 15 with OwsExceptionReport

use of org.n52.shetland.ogc.ows.exception.OwsExceptionReport in project arctic-sea by 52North.

the class GenericRequestOperator method checkForModifierAndProcess.

private void checkForModifierAndProcess(OwsServiceRequest request, OwsServiceResponse response) throws OwsExceptionReport {
    if (!this.modifierRepository.hasRequestResponseModifier(request, response)) {
        return;
    }
    List<RequestResponseModifier> defaultModifier = new LinkedList<>();
    List<RequestResponseModifier> remover = new LinkedList<>();
    List<RequestResponseModifier> merger = new LinkedList<>();
    this.modifierRepository.getRequestResponseModifier(request, response).stream().forEach(modifier -> {
        if (modifier.getFacilitator().isMerger()) {
            merger.add(modifier);
        } else if (modifier.getFacilitator().isAdderRemover()) {
            remover.add(modifier);
        } else {
            defaultModifier.add(modifier);
        }
    });
    // execute merger
    for (RequestResponseModifier modifier : merger) {
        modifier.modifyResponse(request, response);
    }
    // execute default
    for (RequestResponseModifier modifier : defaultModifier) {
        modifier.modifyResponse(request, response);
    }
    // execute adder/remover
    for (RequestResponseModifier modifier : remover) {
        modifier.modifyResponse(request, response);
    }
}
Also used : RequestResponseModifier(org.n52.iceland.convert.RequestResponseModifier) LinkedList(java.util.LinkedList)

Aggregations

OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)27 EncodingException (org.n52.svalbard.encode.exception.EncodingException)14 Test (org.junit.Test)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)9 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)8 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)7 IOException (java.io.IOException)6 DateTime (org.joda.time.DateTime)6 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)6 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)5 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)5 LinkedList (java.util.LinkedList)4 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)4 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)4 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3