axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r529562 - in /webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa: EndpointReference.java MIHeader.java
Date Tue, 17 Apr 2007 11:05:57 GMT
Author: dug
Date: Tue Apr 17 04:05:56 2007
New Revision: 529562

URL: http://svn.apache.org/viewvc?view=rev&rev=529562
Log:
Do a better job of picking up the extensibility points in an EPR
Add a util method to query the current WSA version

Modified:
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
    webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java?view=diff&rev=529562&r1=529561&r2=529562
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
(original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/EndpointReference.java
Tue Apr 17 04:05:56 2007
@@ -5,6 +5,7 @@
 import java.util.List;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.Vector;
 import org.w3c.dom.Document;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.DocumentBuilder;
@@ -30,6 +31,8 @@
   protected String  portName = null;
   protected List    referenceProperties = new java.util.LinkedList();
   protected List    referenceParameters = new java.util.LinkedList();
+  protected Vector  metadata = null ;
+  protected Vector  extras = null ;
 
   EndpointReference( final EndpointReference epr){
     this.address = epr.address;
@@ -38,6 +41,13 @@
     this.portName = epr.portName;
     this.referenceProperties = new java.util.LinkedList(epr.referenceProperties);
     this.referenceParameters = new java.util.LinkedList(epr.referenceParameters);
+    this.metadata = new Vector();
+    for ( int i = 0 ; epr.extras != null && i < epr.metadata.size() ; i++ ) 
+      metadata.add(  ((Element)epr.metadata.get(i)).cloneNode( true ) );
+
+    this.extras = new Vector();
+    for ( int i = 0 ; epr.extras != null && i < epr.extras.size() ; i++ ) 
+      extras.add(  ((Element)epr.extras.get(i)).cloneNode( true ) );
   }
 
   protected EndpointReference() {}
@@ -76,6 +86,20 @@
         newObj.addReferenceParameter( new String(prop) );
       }
     }
+    if ( this.metadata != null ) {
+      for ( int i = 0 ; i < this.metadata.size() ; i++ ) {
+        Element e = (Element) this.metadata.get(i);
+        e = (Element) e.cloneNode( true );
+        newObj.addExtraElement( e );
+      }
+    }
+    if ( this.extras != null ) {
+      for ( int i = 0 ; i < this.extras.size() ; i++ )  {
+        Element e = (Element) this.extras.get(i);
+        e = (Element) e.cloneNode( true );
+        newObj.addExtraElement( e );
+      }
+    }
     return newObj ;
   }
 
@@ -147,35 +171,61 @@
    */
   public static EndpointReference fromDOM(Element el) throws Exception {
      EndpointReference er = new AxisEndpointReference();
+     String NS1 = WSAConstants.NS_WSA1 ;
+     String NS2 = WSAConstants.NS_WSA2 ;
+
      String NSs[] = new String[] { WSAConstants.NS_WSA1, WSAConstants.NS_WSA2 };
 
-     for ( int j = 0 ; j < NSs.length ; j++ ) {
-       String ns = NSs[j] ;
+     NodeList list = el.getChildNodes();
+     for ( int j = 0 ; list != null && j < list.getLength() ; j++ ) {
+       Node node = list.item( j );
+       if ( node.getNodeType() != Node.ELEMENT_NODE ) continue ;
+       Element e = (Element) node ;
+       String  ns = e.getNamespaceURI();
+       String  ln = e.getLocalName();
 
-       NodeList nl = el.getElementsByTagNameNS(ns, "Address");
-       if ( nl.item(0)!=null ) {
-         er.setAddress(Util.getText((Element)nl.item(0)));
+       if ( "Address".equals(ln) && (NS1.equals(ns) || NS2.equals(ns)) ) {
+         er.setAddress( Util.getText( e ) );
          er.setWSAVersion( ns );
        }
-
-       nl = el.getElementsByTagNameNS(ns, "PortType");
-       if (nl.item(0)!=null)
-         er.setPortType(Util.getText((Element)nl.item(0)));
-
-       nl = el.getElementsByTagNameNS(ns, "ServiceName");
-       if (nl.item(0)!=null) {
-         Element child = (Element)nl.item(0);
-         er.setServiceName(Util.getText(child));
-         er.setPortName(child.getAttributeNS(ns, "PortName"));
+       else if ( "PortType".equals(ln) && (NS1.equals(ns) || NS2.equals(ns)) ) {
+         er.setPortType( Util.getText( e ) );
+       }
+       else if ("ServiceName".equals(ln) && (NS1.equals(ns) || NS2.equals(ns))){
+         er.setServiceName( Util.getText( e ) );
+         er.setPortName(e.getAttributeNS(ns, "PortName"));
+       }
+       else if ( "ReferenceProperties".equals(ln) &&
+                 (NS1.equals(ns) || NS2.equals(ns)) ) {
+         NodeList l1 = e.getChildNodes();
+         for ( int k = 0 ; k < l1.getLength() ; k++ ) {
+           Node n1 = l1.item( k );
+           if ( n1.getNodeType() != Node.ELEMENT_NODE ) continue ;
+           er.addReferenceProperty( (Element) n1 );
+         }
+       }
+       else if ( "ReferenceParameters".equals(ln) &&
+                 (NS1.equals(ns) || NS2.equals(ns)) ) {
+         NodeList l1 = e.getChildNodes();
+         for ( int k = 0 ; k < l1.getLength() ; k++ ) {
+           Node n1 = l1.item( k );
+           if ( n1.getNodeType() != Node.ELEMENT_NODE ) continue ;
+           er.addReferenceParameter( (Element) n1 );
+         }
+       }
+       else if ( "Metadata".equals(ln) && NS2.equals(ns) ) {
+         NodeList l = e.getChildNodes();
+         for ( int i = 0 ; i < l.getLength() ; i++ ) {
+           Node n = l.item( i );
+           if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
+           if ( er.metadata == null ) er.metadata = new Vector();
+           er.metadata.add( n.cloneNode(true) );
+         }
+       }
+       else {
+         if ( er.extras == null ) er.extras = new Vector();
+         er.extras.add( e.cloneNode(true) );
        }
-
-       nl = el.getElementsByTagNameNS(ns, "ReferenceProperties");
-       if (nl.item(0)!=null) 
-         er.addReferenceProperties( (Element) nl.item(0) );
-
-       nl = el.getElementsByTagNameNS(ns, "ReferenceParameters");
-       if (nl.item(0)!=null) 
-         er.addReferenceParameters( (Element) nl.item(0) );
      }
      if ( er.getAddress() == null ) {
        String tmp = "Missing Address in EPR: " + XMLUtils.ElementToString(el);
@@ -184,6 +234,16 @@
      return er ;
   }
 
+  public void addExtraElement(Element e) {
+    if ( this.extras == null ) this.extras = new Vector();
+    this.extras.add( e.cloneNode(true) );
+  }
+
+  public void addMetadataElement(Element e) {
+    if ( this.metadata == null ) this.metadata = new Vector();
+    this.metadata.add( e.cloneNode(true) );
+  }
+
   /**
    * Passing in a wsa:ReferenceParameter element this will add all children
    * add references parameters to the EPR
@@ -280,6 +340,14 @@
      portType = pt;
   }
 
+  public Vector getExtra() {
+    return extras ;
+  }
+
+  public Vector getMetadata() {
+    return metadata ;
+  }
+
   public Element toDOM() throws javax.xml.parsers.ParserConfigurationException {
      return toDOM(null, null);
   }
@@ -365,6 +433,31 @@
       }
       rootChild.appendChild(refProp);
     }  
+
+    if (metadata != null) {
+      Element md = null ;
+
+      if (namespace.equals(WSAConstants.NS_WSA2)) {
+        md = ehrDoc.createElementNS(namespace, "Metadata");
+        md.setPrefix("wsa");
+        rootChild.appendChild( md );
+      }
+      else
+        md = rootChild ;
+
+      for ( int i = 0 ; i < metadata.size() ; i++ ) {
+        Element e = (Element) metadata.get(i);
+        md.appendChild( ehrDoc.importNode( e, true ) );
+      }
+    }
+
+    if ( extras != null ) {
+      for ( int i = 0 ; i < extras.size() ; i++ ) {
+        Element e = (Element) extras.get(i);
+        rootChild.appendChild( ehrDoc.importNode( e, true ) );
+      }
+    }
+
     return rootChild;
   }
 

Modified: webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java?view=diff&rev=529562&r1=529561&r2=529562
==============================================================================
--- webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java (original)
+++ webservices/axis/trunk/proposals/dug/java/src/org/apache/axis/wsa/MIHeader.java Tue Apr
17 04:05:56 2007
@@ -90,7 +90,7 @@
    * 
    * @exception AxisFault
    */
-  public MIHeader(javax.xml.rpc.Call call) throws AxisFault {
+  public MIHeader(javax.xml.rpc.Call call) {
     processedOnGet = true ;
     removeOnGet = false ;
     call.setProperty( WSAConstants.REQ_MIH, this );
@@ -111,6 +111,18 @@
 
   public String getWSAVersion() {
     return namespace ;
+  }
+
+  public static String getCurrentWSAVersion() throws Exception {
+    MIHeader mih = null ;
+    MessageContext msgContext = MessageContext.getCurrentContext();
+    if ( msgContext == null ) return EndpointReference.getGlobalWSAVersion() ;
+    if ( msgContext.getPastPivot() ) 
+       mih = fromResponse();
+    else
+       mih = fromRequest();
+    if ( mih == null ) return EndpointReference.getGlobalWSAVersion() ;
+    return mih.getWSAVersion();
   }
 
   public static MIHeader fromCurrentMessage() throws Exception {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message