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);
}
}
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));
}
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);
}
}
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;
}
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);
}
}
Aggregations