use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.
the class SimpleBinding method writeResponse.
protected void writeResponse(HttpServletRequest request, HttpServletResponse response, OwsServiceResponse serviceResponse) throws HTTPException, IOException {
try {
MediaType contentType = chooseResponseContentType(serviceResponse, HTTPHeaders.getAcceptHeader(request), getDefaultContentType());
if (!serviceResponse.isSetContentType()) {
serviceResponse.setContentType(contentType);
}
httpUtils.writeObject(request, response, contentType, serviceResponse, this);
} finally {
serviceResponse.close();
}
}
use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.
the class SimpleBinding method handleEncodingException.
@Override
public Object handleEncodingException(HttpServletRequest request, HttpServletResponse response, EncodingException ex) throws HTTPException {
try {
OwsExceptionReport oer;
if (ex instanceof OwsEncodingException) {
oer = ((OwsEncodingException) ex).getCause();
} else if (ex.getCause() instanceof OwsExceptionReport) {
oer = (OwsExceptionReport) ex.getCause();
} else {
oer = new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
}
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());
}
return encoded;
} catch (OwsExceptionReport e) {
throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, e);
}
}
use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.
the class EXIBinding method doPostOperation.
@Override
public void doPostOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
OwsServiceRequest sosRequest = null;
try {
sosRequest = parseRequest(req);
OwsServiceResponse sosResponse = getServiceOperator(sosRequest).receiveRequest(sosRequest);
writeResponse(req, res, sosResponse);
} catch (OwsExceptionReport oer) {
oer.setVersion(sosRequest != null ? sosRequest.getVersion() : null);
writeOwsExceptionReport(req, res, oer);
}
}
use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.
the class PoxBinding method doPostOperation.
@Override
public void doPostOperation(HttpServletRequest req, HttpServletResponse res) throws HTTPException, IOException {
OwsServiceRequest request = null;
try {
request = parseRequest(req);
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);
}
}
use of org.n52.iceland.exception.HTTPException in project arctic-sea by 52North.
the class SoapBinding method doPostOperation.
@Override
public void doPostOperation(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws HTTPException, IOException {
final SoapChain chain = new SoapChain(httpRequest, httpResponse);
try {
parseSoapRequest(chain);
checkForContext(chain, getRequestContext(httpRequest));
createSoapResponse(chain);
if (!chain.getSoapRequest().hasSoapFault()) {
// parseBodyRequest(chain);
createBodyResponse(chain);
}
writeResponse(chain);
} catch (OwsExceptionReport t) {
writeOwsExceptionReport(chain, t);
}
}
Aggregations