use of org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType in project arctic-sea by 52North.
the class OwsExceptionReportDecoder method decode.
private OwsExceptionReport decode(ExceptionReport report) {
String version = report.getVersion();
ExceptionType[] exceptionTypes = report.getExceptionArray();
List<CodedException> exceptions = Streams.stream(exceptionTypes).map(this::decode).collect(toList());
return new CompositeOwsException(exceptions).setVersion(version);
}
use of org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType in project arctic-sea by 52North.
the class OwsEncoderv110 method encodeOwsException.
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
private ExceptionDocument encodeOwsException(CodedException owsException) {
ExceptionDocument exceptionDoc = ExceptionDocument.Factory.newInstance(getXmlOptions());
ExceptionType exceptionType = exceptionDoc.addNewException();
String exceptionCode;
if (owsException.getCode() == null) {
exceptionCode = OwsExceptionCode.NoApplicableCode.toString();
} else {
exceptionCode = owsException.getCode().toString();
}
exceptionType.setExceptionCode(exceptionCode);
if (owsException.getLocator() != null) {
exceptionType.setLocator(owsException.getLocator());
}
final StringBuilder exceptionText = new StringBuilder();
if (owsException.getMessage() != null) {
exceptionText.append(owsException.getMessage());
exceptionText.append("\n");
}
if (owsException.getCause() != null) {
exceptionText.append("[EXEPTION]: \n");
final String localizedMessage = owsException.getCause().getLocalizedMessage();
final String message = owsException.getCause().getMessage();
if (localizedMessage != null && message != null) {
if (!message.equals(localizedMessage)) {
exceptionText.append(message).append('\n');
}
exceptionText.append(localizedMessage).append('\n');
} else if (localizedMessage != null) {
exceptionText.append(localizedMessage).append('\n');
} else if (message != null) {
exceptionText.append(message).append('\n');
}
if (includeStackTraceInExceptionReport) {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
owsException.getCause().printStackTrace(new PrintStream(os));
exceptionText.append(os.toString());
}
}
exceptionType.addExceptionText(exceptionText.toString());
return exceptionDoc;
}
Aggregations