if (!request.isSOAP()) {
//there will already be a SOAP mime type
response.setContentType("application/xml");
}
OWS20Exception ows2ex;
if(exception instanceof OWS20Exception) {
ows2ex = (OWS20Exception)exception;
} else if ( exception.getCause() != null && exception.getCause() instanceof OWS20Exception) {
ows2ex = (OWS20Exception)exception.getCause();
} else {
// try to infer if it's a standard exception
String code = exception.getCode();
OWSExceptionCode exCode = OWS20Exception.OWSExceptionCode.getByCode(code);
if(exCode != null) {
ows2ex = new OWS20Exception(exception.getMessage(), exception, exCode, exception.getLocator());
} else {
ows2ex = new OWS20Exception(exception.getMessage(), exception, OWSExceptionCode.NoApplicableCode, exception.getLocator());
}
}
//response.setCharacterEncoding( "UTF-8" );
OWSConfiguration configuration = new OWSConfiguration();
Encoder encoder = new Encoder(configuration, configuration.schema());
encoder.setIndenting(true);
encoder.setIndentSize(2);
encoder.setLineWidth(60);
encoder.setOmitXMLDeclaration(request.isSOAP());
// String schemaLocation = buildSchemaURL(baseURL(request.getHttpRequest()), "ows/2.0/owsAll.xsd");
String schemaLocation = "http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd";
encoder.setSchemaLocation(OWS.NAMESPACE, schemaLocation);
try {
// if(ows2ex != null) {
if(ows2ex.getHttpCode() != null) {
response.setStatus(ows2ex.getHttpCode());
}
if(force200httpcode) {
response.setStatus(200);
}