Пример #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());
   }
 }
Пример #2
0
 /**
  * Creates a SOAPFault element from SOS exception
  *
  * @param soapFault SOAPFault element
  * @param owsExceptionReport SOS exception
  * @return SOAP action URI.
  * @throws SOAPException if an error occurs.
  */
 protected String createSOAPFaultFromExceptionResponse(
     SOAPFault soapFault, OwsExceptionReport owsExceptionReport) throws SOAPException {
   // FIXME: check and fix support for ExceptionReport with multiple
   // exceptions!
   if (!owsExceptionReport.getExceptions().isEmpty()) {
     CodedException firstException = owsExceptionReport.getExceptions().iterator().next();
     if (soapFault.getNamespaceURI().equalsIgnoreCase(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
       QName qname = new QName(soapFault.getNamespaceURI(), "Client", soapFault.getPrefix());
       soapFault.setFaultCode(qname);
     } else {
       soapFault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
       if (firstException.getCode() != null) {
         soapFault.appendFaultSubcode(
             new QName(
                 OWSConstants.NS_OWS,
                 firstException.getCode().toString(),
                 OWSConstants.NS_OWS_PREFIX));
       } else {
         soapFault.appendFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
       }
     }
     soapFault.addFaultReasonText(
         SoapHelper.getSoapFaultReasonText(firstException.getCode()), Locale.ENGLISH);
     Detail detail = soapFault.addDetail();
     for (CodedException exception : owsExceptionReport.getExceptions()) {
       createSOAPFaultDetail(detail, exception);
     }
     return getExceptionActionURI(firstException.getCode());
   } else {
     SoapFault fault = new SoapFault();
     fault.setFaultCode(SOAPConstants.SOAP_RECEIVER_FAULT);
     fault.setFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
     fault.setFaultReason(DEFAULT_FAULT_REASON);
     fault.setLocale(Locale.ENGLISH);
     fault.setDetailText(MISSING_EXCEPTION_DETAIL_TEXT);
     createSOAPFault(soapFault, fault);
     return SosSoapConstants.RESP_ACTION_SOS;
   }
 }