Search in sources :

Example 16 with ExceptionType

use of net.opengis.ows.x11.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;
}
Also used : ExceptionType(net.opengis.ows.x11.ExceptionType) PrintStream(java.io.PrintStream) ExceptionDocument(net.opengis.ows.x11.ExceptionDocument) LocalizedString(org.n52.janmayen.i18n.LocalizedString) MultilingualString(org.n52.janmayen.i18n.MultilingualString) OwsLanguageString(org.n52.shetland.ogc.ows.OwsLanguageString) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SeekBookError (org.talend.services.test.library._1_0.SeekBookError)5 ExceptionFrame (org.talend.types.test.generalobjects.errorhandling._1.ExceptionFrame)5 ExceptionType (org.talend.types.test.generalobjects.errorhandling._1.ExceptionType)5 ExceptionType (org.oasis_open.docs.ws_tx.wsba._2006._06.ExceptionType)4 ArrayList (java.util.ArrayList)3 ExceptionType (net.opengis.ows.x11.ExceptionType)3 Task (com.arjuna.services.framework.task.Task)2 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)2 Action (javax.xml.ws.Action)2 MessageContext (javax.xml.ws.handler.MessageContext)2 ExceptionType (net.opengis.ows.v_1_0_0.ExceptionType)2 MAP (org.jboss.ws.api.addressing.MAP)2 MAPEndpoint (org.jboss.ws.api.addressing.MAPEndpoint)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 ExceptionReport (net.opengis.ows.v_1_0_0.ExceptionReport)1 ExceptionType (net.opengis.ows.v_1_1_0.ExceptionType)1 ExceptionDocument (net.opengis.ows.x11.ExceptionDocument)1 ExceptionReportDocument (net.opengis.ows.x11.ExceptionReportDocument)1