Browse Source

Merge fixes to DSMLGW post-axis-version-change

David Boreham 20 years ago
parent
commit
855625aa55

+ 4 - 3
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/OperationAdd.java

@@ -34,10 +34,11 @@ public class OperationAdd extends GenericOperation {
                     String attrName = nl.item(i).getAttributes().getNamedItem("name").getNodeValue();
                     String attrValue;
                     
-                    if (attr.getNodeType() == Node.ELEMENT_NODE)
-                        attrValue=attr.getFirstChild().getNodeValue();
+                    if (nl.item(i).getFirstChild().getNodeType() == Node.ELEMENT_NODE)
+                        attrValue = ParseValue.parseValueFromNode( nl.item(i).getFirstChild()  );
                     else
-                        attrValue=attr.getNextSibling().getFirstChild().getNodeValue();
+                        attrValue = ParseValue.parseValueFromNode(  nl.item(i).getFirstChild().getNextSibling() );
+                        
                     
                     LDAPAttribute ldapAttr = new LDAPAttribute( attrName, attrValue);
     

+ 6 - 3
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/OperationModify.java

@@ -25,7 +25,7 @@ public class OperationModify extends GenericOperation {
     
     public javax.xml.soap.SOAPElement getResponse(gatewayContext ctx) {
         
-        ldapConn = ctx.getLdapConnection();
+     
         root = ctx.getRootNode();
         
         
@@ -59,7 +59,7 @@ public class OperationModify extends GenericOperation {
                         for (int j=0; j< Values.getLength(); j++) {
                             if (Values.item(j).getNodeType() == Node.ELEMENT_NODE &&
                             Values.item(j).getLocalName().equals("value")) {
-                                attr.addValue(Values.item(j).getFirstChild().getNodeValue());
+                                attr.addValue( ParseValue.parseValueFromNode(Values.item(j)) );
                                 
                             }
                             
@@ -96,7 +96,7 @@ public class OperationModify extends GenericOperation {
         
         javax.xml.soap.SOAPElement output = null;
         
-        
+           ldapConn = ctx.getLdapConnection();
         
         try {
             if (ctx.getConstraints() != null)
@@ -108,6 +108,9 @@ public class OperationModify extends GenericOperation {
         } catch (LDAPException E) {
             resultCode = E.getLDAPResultCode();
             errorMessage = E.getLDAPErrorMessage() ;
+	        if (! ldapConn.isConnected()) {
+	        	errorMessage = "GATEWAY NOT CONNECTED";
+	        }
         }
         javax.xml.soap.SOAPBodyElement sbe = null;
         try {

+ 2 - 1
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/OperationSearch.java

@@ -45,7 +45,7 @@ class OperationSearch extends GenericOperation {
     
     public javax.xml.soap.SOAPElement getResponse(gatewayContext ctx) {
         
-        ldapConn = ctx.getLdapConnection();
+      
         root = ctx.getRootNode();
         
         
@@ -206,6 +206,7 @@ class OperationSearch extends GenericOperation {
                 
             }
             
+            ldapConn = ctx.getLdapConnection();
             
             if (ctx.getConstraints() != null)
                 results = ldapConn.search(dn, scope, filterString,  attributeList, false, ctx.getConstraints() );

+ 44 - 0
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/ParseValue.java

@@ -0,0 +1,44 @@
+/* --- BEGIN COPYRIGHT BLOCK ---
+ * Copyright (C) 2005 Red Hat, Inc.
+ * All rights reserved.
+ * --- END COPYRIGHT BLOCK --- */
+package com.netscape.dsml.gateway;
+
+/**
+ *
+ * @author  elliot
+ */
+public class ParseValue {
+    
+    /** Creates a new instance of ParseValue */
+    public ParseValue() {
+    }
+    
+    public static String parseValueFromNode(org.w3c.dom.Node n) {
+        String ret = null;
+        // <xsd:union memberTypes="xsd:string xsd:base64Binary xsd:anyURI"/>
+        
+        org.w3c.dom.Node type = n.getAttributes().getNamedItem("xsi:type");
+        if (type != null && type.getNodeValue().equalsIgnoreCase("xsd:base64Binary") ) {
+            // This value is encoded in base64. decode it.
+            sun.misc.BASE64Decoder bd = new sun.misc.BASE64Decoder();
+            try {
+                ret = new String( bd.decodeBuffer( n.getFirstChild().getNodeValue() ) ) ; 
+            } 
+            catch (org.w3c.dom.DOMException de) {
+            }
+            catch (Exception e) {
+                // couldn't decode auth info
+            }
+            
+        } else {
+            // anyURI is unsupported.
+            ret = new String(n.getFirstChild().getNodeValue());
+            
+        }
+        return ret;
+        
+    }
+    
+    
+}

+ 15 - 1
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/gatewayContext.java

@@ -35,6 +35,20 @@ public class gatewayContext {
      * @return Value of property ldapConnection.
      */
     public LDAPConnection getLdapConnection() {
+        
+        if (this.ldapConnection  == null || this.ldapConnection.isConnected() == false ) {
+            
+            IConnectionManager ldap_pool = null;
+            try {
+                ProxyConnMgrFactory pmc = new ProxyConnMgrFactory();
+                ldap_pool = pmc.getInstance();
+            }
+            catch (Exception e) {
+                
+            }
+            this.ldapConnection = ldap_pool.getConnection();
+        }
+        
         return this.ldapConnection;
     }
     
@@ -43,7 +57,7 @@ public class gatewayContext {
      * @param ldapConnection New value of property ldapConnection.
      */
     public void setLdapConnection(LDAPConnection ldapConnection) {
-        this.ldapConnection = ldapConnection;
+        // this.ldapConnection = ldapConnection;
     }
     
     /**

+ 0 - 1
ldap/clients/dsmlgw/src/com/netscape/dsml/gateway/gatewayHandler.java

@@ -55,7 +55,6 @@ public class gatewayHandler  extends BasicHandler {
     
     public void cleanup() {
         super.cleanup();
-        destroy();
     }
 
 	 

+ 5 - 0
ldap/clients/dsmlgw/src/com/netscape/dsml/test/dsmlClient.java

@@ -66,6 +66,11 @@ public class dsmlClient {
                     if (node.getNodeName().equals("resultCode")) {
                         int result = Integer.parseInt(node.getAttributes().getNamedItem("code").getNodeValue());
                         System.exit(result);
+                    } else if (node.getNodeName().equals("errorResponse ")) {
+                        int result = Integer.parseInt(node.getAttributes().getNamedItem("code").getNodeValue());
+                        System.exit(result);
+                    } else if (node.getNodeName().equals("faultcode")) {
+                          System.exit(253);
                     }
                 }