juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject cvs commit: ws-juddi/src/java/org/apache/juddi/registry RegistryServlet.java
Date Tue, 01 Mar 2005 03:49:58 GMT
sviens      2005/02/28 19:49:58

  Modified:    src/java/org/apache/juddi/transport/axis AxisProcessor.java
               src/java/org/apache/juddi/registry RegistryServlet.java
  Log:
  Corrected SOAPFault issue reported by Anne Thomas Manes and outlined in issue# 58 (http://issues.apache.org/jira/browse/JUDDI-58).
  
  Revision  Changes    Path
  1.8       +118 -99   ws-juddi/src/java/org/apache/juddi/transport/axis/AxisProcessor.java
  
  Index: AxisProcessor.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/transport/axis/AxisProcessor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AxisProcessor.java	3 Jun 2004 02:57:26 -0000	1.7
  +++ AxisProcessor.java	1 Mar 2005 03:49:57 -0000	1.8
  @@ -15,6 +15,13 @@
    */
   package org.apache.juddi.transport.axis;
   
  +import java.util.Vector;
  +
  +import javax.xml.soap.Detail;
  +import javax.xml.soap.SOAPBody;
  +import javax.xml.soap.SOAPElement;
  +import javax.xml.soap.SOAPFault;
  +
   import org.apache.axis.AxisFault;
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
  @@ -25,10 +32,11 @@
   import org.apache.juddi.IRegistry;
   import org.apache.juddi.datatype.RegistryObject;
   import org.apache.juddi.datatype.response.DispositionReport;
  +import org.apache.juddi.datatype.response.ErrInfo;
  +import org.apache.juddi.datatype.response.Result;
   import org.apache.juddi.error.BusyException;
   import org.apache.juddi.error.RegistryException;
   import org.apache.juddi.error.UnsupportedException;
  -import org.apache.juddi.handler.DispositionReportHandler;
   import org.apache.juddi.handler.HandlerMaker;
   import org.apache.juddi.handler.IHandler;
   import org.apache.juddi.monitor.Monitor;
  @@ -67,6 +75,11 @@
       if (monitor != null)
         monitor.inspectMessageContext(messageContext);
   
  +    // the soap request and response objects.
  +
  +    SOAPEnvelope soapReqEnv = null;
  +    SOAPEnvelope soapResEnv = null;
  +
       // grab a reference to the SOAP request from
       // the Message Context
   
  @@ -86,11 +99,16 @@
   
       try
       {
  +      // pull the soap request and response objects from 
  +      // raw request and response message objects.
  +
  +      soapReqEnv = soapRequest.getSOAPEnvelope();
  +      soapResEnv = soapResponse.getSOAPEnvelope();
  +
         // pull the uddi request xml element from
         // the body of the soapRequest
   
  -      SOAPEnvelope env = soapRequest.getSOAPEnvelope();
  -      SOAPBodyElement requestBody = env.getFirstBody();
  +      SOAPBodyElement requestBody = soapReqEnv.getFirstBody();
         request = requestBody.getAsDOM();
   
         // make the monitor inspect the SOAP Body
  @@ -194,58 +212,112 @@
         // discarding the temp element) and appending
         // this child to the soap response body.
   
  -      response = (Element)element.getFirstChild();
  -    }
  -    catch(RegistryException rex)
  -    {
  -      log.error(rex.getMessage(),rex);
  -
  -      String fCode = rex.getFaultCode();
  -      String fString = rex.getFaultString();
  -      String fActor = rex.getFaultActor();
  -
  -      DispositionReport dispRpt = rex.getDispositionReport();
  -      if (dispRpt != null)
  -      {
  -        dispRpt.setGeneric(generic);
  -        dispRpt.setOperator(Config.getOperator());
  -      }
  -
  -      if (monitor != null)
  -        monitor.addMonitorFault(fString);
  -
  -      response = createFault(fCode,fString,fActor,dispRpt);
  -    }
  -    catch(AxisFault axf)
  -    {
  -      log.error(axf.getMessage(),axf);
  -
  -      String fCode = String.valueOf(axf.getFaultCode());
  -      String fString = axf.getFaultString();
  -      String fActor = axf.getFaultActor();
  -
  -      if (monitor != null)
  -        monitor.addMonitorFault(fString);
  -
  -      response = createFault(fCode,fString,fActor,null);
  +      response = (Element)element.getFirstChild();      
  +      SOAPBodyElement soapRespBody = new SOAPBodyElement(response);
  +      SOAPEnvelope soapRespEnv = soapResponse.getSOAPEnvelope();
  +      soapRespEnv.addBodyElement(soapRespBody);       
       }
       catch(Exception ex)
       {
         log.error(ex.getMessage(),ex);
   
  -      String fCode = null;
  -      String fString = ex.getMessage();
  -      String fActor = null;
  -
  -      if (monitor != null)
  -        monitor.addMonitorFault(fString);
  -
  -      response = createFault(fCode,fString,fActor,null);
  +      String faultCode = null;
  +      String faultString = null;
  +      String faultActor = null;      
  +      String errno = null;
  +      String errCode = null;
  +      String errMsg = null;
  +      
  +      // If a RegistryException was thrown dig out the
  +      // dispositionReport if one exists and set the SOAP
  +      // Fault & DispositionReport values with what we find.
  +      
  +      if (ex instanceof RegistryException)
  +      {
  +        RegistryException rex = (RegistryException)ex;
  +        
  +        faultCode = rex.getFaultCode();  // SOAP Fault faultCode
  +        faultString = rex.getFaultString();  // SOAP Fault faultString
  +        faultActor = rex.getFaultActor();  // SOAP Fault faultActor
  +        
  +        if (monitor != null)
  +            monitor.addMonitorFault(faultString);
  +        
  +        DispositionReport dispRpt = rex.getDispositionReport();
  +        if (dispRpt != null)
  +        {
  +          Result result = null;
  +          ErrInfo errInfo = null;
  +        
  +          Vector results = dispRpt.getResultVector();
  +          if ((results != null) && (!results.isEmpty()))
  +            result = (Result)results.elementAt(0);
  +        
  +          if (result != null)
  +          {
  +            errno = String.valueOf(result.getErrno());  // UDDI DispositionReport errno
  +            errInfo = result.getErrInfo();
  +          
  +            if (errInfo != null)
  +            {
  +              errCode = errInfo.getErrCode();  // UDDI DispositionReport errCode
  +              errMsg = errInfo.getErrMsg();  // UDDI DispositionReport errMsg
  +            }
  +          }
  +        }
  +      }
  +      else
  +      {
  +        // All other exceptions (other than RegistryException
  +        // and subclasses) are either a result of a jUDDI 
  +        // configuration problem or something that we *should* 
  +        // be catching and converting to a RegistryException 
  +        // but are not (yet!).
  +          
  +        faultCode = "Server";
  +        faultString = ex.getMessage();
  +        faultActor = null;
  +          
  +        errno = String.valueOf(Result.E_FATAL_ERROR);
  +        errCode = Result.E_FATAL_ERROR_CODE;
  +        errMsg = "An internal UDDI server error has " +
  +                 "occurred. Please report this error " +
  +                 "to the UDDI server administrator.";
  +      }
  +      
  +      // All other exceptions (other than RegistryException
  +      // and subclasses) are either a jUDDI configuration 
  +      // problem or something that we *should* be catching and
  +      // converting to a RegistryException but are not (yet!).
  +        
  +      try {
  +        SOAPBody soapResBody = soapResEnv.getBody();
  +        SOAPFault soapFault = soapResBody.addFault();
  +        soapFault.setFaultCode(faultCode);
  +        soapFault.setFaultString(faultString);
  +        soapFault.setFaultActor(faultActor);
  +        
  +        Detail faultDetail = soapFault.addDetail();
  +        
  +        SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport","",IRegistry.UDDI_V2_NAMESPACE);
       
  +        dispRpt.setAttribute("generic",IRegistry.UDDI_V2_GENERIC);
  +        dispRpt.setAttribute("operator",Config.getOperator());
  +        
  +        SOAPElement result = dispRpt.addChildElement("result");
  +        result.setAttribute("errno",errno);
  +        
  +        SOAPElement errInfo = result.addChildElement("errInfo");
  +        errInfo.setAttribute("errCode",errCode);
  +        errInfo.setValue(errMsg);
  +      } 
  +      catch (Exception e) { 
  +        e.printStackTrace(); 
  +      }
       }
       finally
       {
         // write the monitored information to the currently
  -      // configured 'Monitor' implemneted registry (the
  +      // configured 'Monitor' implemented registry (the
         // default Monitor implementation writes the monitored
         // information to a database table via JDBC).
   
  @@ -253,63 +325,10 @@
           monitor.log();
       }
   
  -    try {
  -      SOAPBodyElement soapRespBody = new SOAPBodyElement(response);
  -      SOAPEnvelope soapRespEnv = soapResponse.getSOAPEnvelope();
  -      soapRespEnv.addBodyElement(soapRespBody);
  -    }
  -    catch(AxisFault af) {
  -      af.printStackTrace();
  -    }
  -
       // write the SOAP response XML out to the log (on debug)
       try { log.debug(soapResponse.getSOAPPartAsString()); }
       catch(AxisFault af) {
         af.printStackTrace();
       }
  -
  -  }
  -
  -  private static Element createFault(String fCode,String fString,String fActor,DispositionReport
dispRpt)
  -  {
  -    // create a new 'Fault' XML element.
  -
  -    Document document = XMLUtils.createDocument();
  -    Element fault = document.createElement("Fault");
  -
  -    if (fCode != null)
  -    {
  -      Element fCodeElement = document.createElement("faultcode");
  -      fCodeElement.appendChild(document.createTextNode(fCode));
  -      fault.appendChild(fCodeElement);
  -    }
  -
  -    if (fString == null)
  -      fString = "";
  -
  -    Element fStringElement = document.createElement("faultstring");
  -    fStringElement.appendChild(document.createTextNode(fString));
  -    fault.appendChild(fStringElement);
  -
  -    if (fActor != null)
  -    {
  -      Element fActorElement = document.createElement("faultactor");
  -      fActorElement.appendChild(document.createTextNode(fActor));
  -      fault.appendChild(fActorElement);
  -    }
  -
  -    // check for a DispositionReport in the exception and if one exists,
  -    // grab it, marshal it into xml and stuff it into a SOAP fault
  -    // detail element.
  -
  -    if (dispRpt != null)
  -    {
  -      Element fDetailElement = document.createElement("detail");
  -      IHandler handler = maker.lookup(DispositionReportHandler.TAG_NAME);
  -      handler.marshal(dispRpt,fDetailElement);
  -      fault.appendChild(fDetailElement);
  -    }
  -
  -    return fault;
     }
   }
  
  
  
  1.10      +91 -63    ws-juddi/src/java/org/apache/juddi/registry/RegistryServlet.java
  
  Index: RegistryServlet.java
  ===================================================================
  RCS file: /home/cvs/ws-juddi/src/java/org/apache/juddi/registry/RegistryServlet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RegistryServlet.java	10 Feb 2005 04:16:50 -0000	1.9
  +++ RegistryServlet.java	1 Mar 2005 03:49:57 -0000	1.10
  @@ -18,6 +18,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.util.Properties;
  +import java.util.Vector;
   
   import javax.servlet.ServletConfig;
   import javax.servlet.ServletException;
  @@ -30,7 +31,7 @@
   import javax.xml.soap.Detail;
   import javax.xml.soap.MessageFactory;
   import javax.xml.soap.SOAPBody;
  -import javax.xml.soap.SOAPEnvelope;
  +import javax.xml.soap.SOAPElement;
   import javax.xml.soap.SOAPException;
   import javax.xml.soap.SOAPFault;
   import javax.xml.soap.SOAPMessage;
  @@ -40,6 +41,8 @@
   import org.apache.juddi.IRegistry;
   import org.apache.juddi.datatype.RegistryObject;
   import org.apache.juddi.datatype.response.DispositionReport;
  +import org.apache.juddi.datatype.response.ErrInfo;
  +import org.apache.juddi.datatype.response.Result;
   import org.apache.juddi.error.BusyException;
   import org.apache.juddi.error.RegistryException;
   import org.apache.juddi.error.UnsupportedException;
  @@ -287,77 +290,102 @@
         // only child here (this has the effect of
         // discarding the temp element) and append 
         // this child to the soap response body
  -        
  +      
         document.appendChild(element.getFirstChild());
         soapRes.getSOAPBody().addDocument(document);
       } 
  -    catch (RegistryException ex) {             
  -      log.error(ex);
  +    catch(Exception ex)
  +    {
  +      log.error(ex.getMessage(),ex);
  +
  +      String faultCode = null;
  +      String faultString = null;
  +      String faultActor = null;      
  +      String errno = null;
  +      String errCode = null;
  +      String errMsg = null;
  +      
  +      // If a RegistryException was thrown dig out the
  +      // dispositionReport if one exists and set the SOAP
  +      // Fault & DispositionReport values with what we find.
         
  -      try {        
  -        SOAPBody body = soapRes.getSOAPBody();
  -        SOAPFault soapFault = body.addFault();
  -        soapFault.setFaultActor((ex.getFaultActor() == null) ? "" : ex.getFaultActor());
  -        soapFault.setFaultString((ex.getFaultString() == null) ? "" : ex.getFaultString());
  -        soapFault.setFaultCode((ex.getFaultCode() == null) ? "" : ex.getFaultCode());
  -          
  -        // Store DispositionReport in the SOAP fault node.
  -        DispositionReport dispRpt = ex.getDispositionReport();
  +      if (ex instanceof RegistryException)
  +      {
  +        RegistryException rex = (RegistryException)ex;
  +        
  +        faultCode = rex.getFaultCode();  // SOAP Fault faultCode
  +        faultString = rex.getFaultString();  // SOAP Fault faultString
  +        faultActor = rex.getFaultActor();  // SOAP Fault faultActor
  +        
  +        DispositionReport dispRpt = rex.getDispositionReport();
           if (dispRpt != null)
  -        {          
  -          dispRpt.setGeneric(generic);
  -          dispRpt.setOperator(Config.getOperator());
  -
  -          // Create a new 'temp' XML element to use as a container 
  -          // in which to marshal the DispositionReport into.
  -             
  -          DocumentBuilder docBuilder = getDocumentBuilder();
  -          Document document = docBuilder.newDocument();
  -          Element dispRptElement = document.createElement("temp");
  -
  -          // Lookup the DispositionReportHandler and marshal 
  -          // the juddi object into the appropriate xml format (we 
  -          // only support UDDI v2.0 at this time).  Attach the
  -          // results to the body of the SOAP fault.
  -              
  -          IHandler dispRptHandler = maker.lookup(DispositionReport.class.getName());
  -          dispRptHandler.marshal(dispRpt,dispRptElement);   
  -            
  -          // Create the SOAPFault Detail element and insert 
  -          // the DispositionReport.
  -            
  -          Detail soapDetail = soapFault.addDetail();
  -          soapDetail.appendChild(dispRptElement.getFirstChild());
  +        {
  +          Result result = null;
  +          ErrInfo errInfo = null;
  +        
  +          Vector results = dispRpt.getResultVector();
  +          if ((results != null) && (!results.isEmpty()))
  +            result = (Result)results.elementAt(0);
  +        
  +          if (result != null)
  +          {
  +            errno = String.valueOf(result.getErrno());  // UDDI DispositionReport errno
  +            errInfo = result.getErrInfo();
  +          
  +            if (errInfo != null)
  +            {
  +              errCode = errInfo.getErrCode();  // UDDI DispositionReport errCode
  +              errMsg = errInfo.getErrMsg();  // UDDI DispositionReport errMsg
  +            }
  +          }
           }
         }
  -      catch(SOAPException sex) {
  -        log.error(sex);
  -      }
  -    } 
  -    catch (SOAPException ex) {             
  -      log.error(ex);
  -
  -      try {
  -        SOAPEnvelope envelope = soapRes.getSOAPPart().getEnvelope();
  -        SOAPBody body = envelope.getBody(); 
  -        SOAPFault soapFault = body.addFault();
  -        soapFault.setFaultString(ex.getMessage());        
  -      }
  -      catch(SOAPException sex) {
  -        log.error(sex);
  +      else
  +      {
  +        // All other exceptions (other than RegistryException
  +        // and subclasses) are either a result of a jUDDI 
  +        // configuration problem or something that we *should* 
  +        // be catching and converting to a RegistryException 
  +        // but are not (yet!).
  +          
  +        faultCode = "Server";
  +        faultString = ex.getMessage();
  +        faultActor = null;
  +          
  +        errno = String.valueOf(Result.E_FATAL_ERROR);
  +        errCode = Result.E_FATAL_ERROR_CODE;
  +        errMsg = "An internal UDDI server error has " +
  +                 "occurred. Please report this error " +
  +                 "to the UDDI server administrator.";
         }
  -    } 
  -    catch(Exception ex) {
  -      log.error(ex);
  -
  +      
  +      // All other exceptions (other than RegistryException
  +      // and subclasses) are either a jUDDI configuration 
  +      // problem or something that we *should* be catching and
  +      // converting to a RegistryException but are not (yet!).
  +        
         try {
  -        SOAPEnvelope envelope = soapRes.getSOAPPart().getEnvelope();
  -        SOAPBody body = envelope.getBody(); 
  -        SOAPFault soapFault = body.addFault();
  -        soapFault.setFaultString(ex.getMessage());        
  -      }
  -      catch(SOAPException sex) {
  -        log.error(sex);
  +        SOAPBody soapResBody = soapRes.getSOAPBody();     
  +        SOAPFault soapFault = soapResBody.addFault();
  +        soapFault.setFaultCode(faultCode);
  +        soapFault.setFaultString(faultString);
  +        soapFault.setFaultActor(faultActor);
  +        
  +        Detail faultDetail = soapFault.addDetail();
  +        
  +        SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport","",IRegistry.UDDI_V2_NAMESPACE);
       
  +        dispRpt.setAttribute("generic",IRegistry.UDDI_V2_GENERIC);
  +        dispRpt.setAttribute("operator",Config.getOperator());
  +        
  +        SOAPElement result = dispRpt.addChildElement("result");
  +        result.setAttribute("errno",errno);
  +        
  +        SOAPElement errInfo = result.addChildElement("errInfo");
  +        errInfo.setAttribute("errCode",errCode);
  +        errInfo.setValue(errMsg);
  +      } 
  +      catch (Exception e) { 
  +        e.printStackTrace(); 
         }
       }
       finally {
  
  
  

Mime
View raw message