Пример #1
0
 /**
  * Creates a SOAPDetail element from SOS exception document.
  *
  * @param detail SOAPDetail
  * @param exception SOS Exception document
  * @throws SOAPException if an error occurs.
  */
 private void createSOAPFaultDetail(Detail detail, CodedException exception) throws SOAPException {
   SOAPElement exRep = detail.addChildElement(OWSConstants.QN_EXCEPTION);
   exRep.addNamespaceDeclaration(OWSConstants.NS_OWS_PREFIX, OWSConstants.NS_OWS);
   String code = exception.getCode().toString();
   String locator = exception.getLocator();
   StringBuilder exceptionText = new StringBuilder();
   exceptionText.append(exception.getMessage());
   exceptionText.append(LINE_SEPARATOR_CHAR);
   if (exception.getCause() != null) {
     exceptionText.append(LINE_SEPARATOR_CHAR).append("[EXCEPTION]: ").append(LINE_SEPARATOR_CHAR);
     if (exception.getCause().getLocalizedMessage() != null
         && !exception.getCause().getLocalizedMessage().isEmpty()) {
       exceptionText.append(exception.getCause().getLocalizedMessage());
       exceptionText.append(LINE_SEPARATOR_CHAR);
     }
     if (exception.getCause().getMessage() != null
         && !exception.getCause().getMessage().isEmpty()) {
       exceptionText.append(exception.getCause().getMessage());
       exceptionText.append(LINE_SEPARATOR_CHAR);
     }
   }
   exRep.addAttribute(new QName(OWSConstants.EN_EXCEPTION_CODE), code);
   if (locator != null && !locator.isEmpty()) {
     exRep.addAttribute(new QName(OWSConstants.EN_LOCATOR), locator);
   }
   if (exceptionText.length() != 0) {
     SOAPElement execText = exRep.addChildElement(OWSConstants.QN_EXCEPTION_TEXT);
     execText.setTextContent(exceptionText.toString());
   }
 }