cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r380132 [2/2] - in /cocoon/blocks/naming/trunk/java/org/apache/cocoon: components/naming/EntryManager.java components/naming/LDAPEntryManager.java transformation/LDAPTransformer.java
Date Thu, 23 Feb 2006 14:46:38 GMT
Modified: cocoon/blocks/naming/trunk/java/org/apache/cocoon/transformation/LDAPTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/naming/trunk/java/org/apache/cocoon/transformation/LDAPTransformer.java?rev=380132&r1=380131&r2=380132&view=diff
==============================================================================
--- cocoon/blocks/naming/trunk/java/org/apache/cocoon/transformation/LDAPTransformer.java (original)
+++ cocoon/blocks/naming/trunk/java/org/apache/cocoon/transformation/LDAPTransformer.java Thu Feb 23 06:46:27 2006
@@ -41,6 +41,10 @@
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
@@ -80,6 +84,7 @@
  * &lt;!ELEMENT searchbase (#PCDATA)&gt;+<br>
  * &lt;!ELEMENT doc-element (#PCDATA)&gt;+ (default: "doc-element")<br>
  * &lt;!ELEMENT row-element (#PCDATA)&gt;+ (default: "row-element")<br>
+ * &lt;!ELEMENT dn-attribute (#PCDATA)&gt;+ (default: "" meaning no DN attribute)<br>
  * &lt;!ELEMENT error-element (#PCDATA)&gt;+ (default: "ldap-error") (in case of error returned error tag)<br>
  * &lt;!ELEMENT sax_error (TRUE  | FALSE)&gt+; (default: FALSE) (throws SAX-Exception instead of error tag)<br>
  * &lt;!ELEMENT attribute (#PCDATA)&gt;<br>
@@ -130,6 +135,7 @@
     public static final String MAGIC_PORT_ELEMENT = "port";
     public static final String MAGIC_ROOT_DN_ELEMENT = "rootdn";
     public static final String MAGIC_ROW_ELEMENT = "row-element";
+    public static final String MAGIC_DN_ATTRIBUTE = "dn-attribute";
     public static final String MAGIC_SAX_ERROR = "sax-error";
     public static final String MAGIC_SCOPE_ELEMENT = "scope";
     public static final String MAGIC_SEARCHBASE_ELEMENT = "searchbase";
@@ -165,9 +171,10 @@
     public static final int STATE_INSIDE_SAX_ERROR_ELEMENT = 23;
     public static final int STATE_INSIDE_EXECUTE_REPLACE = 24;
     public static final int STATE_INSIDE_EXECUTE_ADD = 25;
+    public static final int STATE_INSIDE_DN_ATTRIBUTE = 26;
 
     /** Default parameters that might apply to all queries */
-    protected Properties default_properties = new Properties();
+    protected HashMap default_properties = new HashMap();
 
     /** The name of the value element we're currently receiving */
     protected String current_name;
@@ -188,120 +195,60 @@
     protected XMLConsumer xml_consumer;
     protected LexicalHandler lexical_handler;
 
-    /** BEGIN SitemapComponent methods */
+    /** SitemapComponent methods */
 
     public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters)
         throws ProcessingException, SAXException, IOException {
         current_state = STATE_OUTSIDE;
 
-        // Check the initializer
-        String parameter = parameters.getParameter(MAGIC_INITIALIZER_ELEMENT, null);
+        setDefaultProperty(parameters, MAGIC_INITIALIZER_ELEMENT);    // Check the initializer
+        setDefaultProperty(parameters, MAGIC_VERSION_ELEMENT);        // Check the version
+        setDefaultProperty(parameters, MAGIC_AUTHENTICATION_ELEMENT); // Check the authentication
+        setDefaultProperty(parameters, MAGIC_SCOPE_ELEMENT);          // Check the scope
+        setDefaultProperty(parameters, MAGIC_SERVERURL_ELEMENT);      // Check the serverurl
+        setDefaultProperty(parameters, MAGIC_ROOT_DN_ELEMENT);        // Check the ldap-root_dn
+        setDefaultProperty(parameters, MAGIC_PASSWORD_ELEMENT);       // Check the ldap-pwd
+        setDefaultProperty(parameters, MAGIC_PORT_ELEMENT);           // Check the port
+        setDefaultProperty(parameters, MAGIC_SEARCHBASE_ELEMENT);     // Check the searchbase
+        setDefaultProperty(parameters, MAGIC_DOC_ELEMENT);            // Check the doc-element
+        setDefaultProperty(parameters, MAGIC_ROW_ELEMENT);            // Check the row-element
+        setDefaultProperty(parameters, MAGIC_DN_ATTRIBUTE);           // Check the dn-attribute
+        setDefaultProperty(parameters, MAGIC_ERROR_ELEMENT);          // Check the error-element
+        setDefaultProperty(parameters, MAGIC_SAX_ERROR);              // Check the sax-error
+        setDefaultProperty(parameters, MAGIC_DEREF_LINK_ELEMENT);     // Check the deref-link-element
+        setDefaultProperty(parameters, MAGIC_COUNT_LIMIT_ELEMENT);    // Check the count-limit-element
+        setDefaultProperty(parameters, MAGIC_TIME_LIMIT_ELEMENT);     // Check the time-limit-element
+        setDefaultProperty(parameters, MAGIC_DEBUG_ELEMENT);          // Check the debug-element
+        setDefaultProperty(parameters, MAGIC_ENCODING_ELEMENT);       // Check the encoding
+        setDefaultProperty(parameters, MAGIC_FILTER_ELEMENT);         // Check the filter-element
+    }
+
+    /** My very own methods */
+
+    /* Helper to set default properties */
+    protected void setDefaultProperty(Parameters parameters, String propertyName) {
+        String parameter = parameters.getParameter(propertyName, null);
         if (parameter != null) {
-            default_properties.setProperty(MAGIC_INITIALIZER_ELEMENT, parameter);
+            default_properties.put(propertyName, parameter);
         }
-        // Check the version
-        parameter = parameters.getParameter(MAGIC_VERSION_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_VERSION_ELEMENT, parameter);
-        }
-        // Check the authentication
-        parameter = parameters.getParameter(MAGIC_AUTHENTICATION_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_AUTHENTICATION_ELEMENT, parameter);
-        }
-        // Check the scope
-        parameter = parameters.getParameter(MAGIC_SCOPE_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_SCOPE_ELEMENT, parameter);
-        }
-        // Check the serverurl
-        parameter = parameters.getParameter(MAGIC_SERVERURL_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_SERVERURL_ELEMENT, parameter);
-        }
-        // Check the ldap-root_dn
-        parameter = parameters.getParameter(MAGIC_ROOT_DN_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_ROOT_DN_ELEMENT, parameter);
-        }
-        // Check the ldap-pwd
-        parameter = parameters.getParameter(MAGIC_PASSWORD_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_PASSWORD_ELEMENT, parameter);
-        }
-        // Check the port
-        parameter = parameters.getParameter(MAGIC_PORT_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_PORT_ELEMENT, parameter);
-        }
-        // Check the searchbase
-        parameter = parameters.getParameter(MAGIC_SEARCHBASE_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_SEARCHBASE_ELEMENT, parameter);
-        }
-        // Check the doc-element
-        parameter = parameters.getParameter(MAGIC_DOC_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_DOC_ELEMENT, parameter);
-        }
-        // Check the row-element
-        parameter = parameters.getParameter(MAGIC_ROW_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_ROW_ELEMENT, parameter);
-        }
-        // Check the error-element
-        parameter = parameters.getParameter(MAGIC_ERROR_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_ERROR_ELEMENT, parameter);
-        }
-        // Check the sax-error
-        parameter = parameters.getParameter(MAGIC_SAX_ERROR, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_SAX_ERROR, parameter);
-        }
-        // Check the deref-link-element
-        parameter = parameters.getParameter(MAGIC_DEREF_LINK_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_DEREF_LINK_ELEMENT, parameter.toUpperCase());
-        }
-        // Check the count-limit-element
-        parameter = parameters.getParameter(MAGIC_COUNT_LIMIT_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_COUNT_LIMIT_ELEMENT, parameter);
-        }
-        // Check the time-limit-element
-        parameter = parameters.getParameter(MAGIC_TIME_LIMIT_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_TIME_LIMIT_ELEMENT, parameter);
-        }
-        // Check the debug-element
-        parameter = parameters.getParameter(MAGIC_DEBUG_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_DEBUG_ELEMENT, parameter);
-        }
-        // Check the encoding
-        parameter = parameters.getParameter(MAGIC_ENCODING_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_ENCODING_ELEMENT, parameter);
-        }
-        // Check the filter-element
-        parameter = parameters.getParameter(MAGIC_FILTER_ELEMENT, null);
-        if (parameter != null) {
-            default_properties.setProperty(MAGIC_FILTER_ELEMENT, parameter);
-        }
-
     }
-
-    /** END SitemapComponent methods */
-
-    /** BEGIN my very own methods */
+    
+    /* Helper class to store a new Query in the stack */
+    protected void storeQuery(int nextState) {
+        current_state = nextState;
+        current_query_index = queries.size();
+        LDAPQuery query = new LDAPQuery(this);
+        queries.addElement(query);
+        getCurrentQuery().toDo = nextState;
+        getCurrentQuery().query_index = current_query_index;
+    }
 
     /**
      * This will be the meat of LDAPTransformer, where the query is run.
      */
     protected void executeQuery(int index) throws SAXException {
         this.contentHandler.startPrefixMapping("", LDAPTransformer.my_uri);
-        LDAPQuery query = (LDAPQuery) queries.elementAt(index);
+        LDAPQuery query = (LDAPQuery)queries.elementAt(index);
         try {
             query.execute();
         } catch (NamingException e) {
@@ -311,7 +258,6 @@
             getLogger().error(e.toString());
             throw new SAXException(e);
         }
-
         this.contentHandler.endPrefixMapping("");
     }
 
@@ -319,198 +265,70 @@
         throw new IllegalStateException(my_name + ": " + message);
     }
 
-    protected void startExecuteQuery(Attributes attributes) {
-        LDAPQuery query;
+    protected void startExecuteElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_OUTSIDE :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
-                getCurrentQuery().query_index = current_query_index;
-                break;
             case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
-                getCurrentQuery().query_index = current_query_index;
+                storeQuery(LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY);
                 break;
             default :
                 throwIllegalStateException("Not expecting a start execute-query element");
         }
     }
 
-    protected void endExecuteQuery() throws SAXException {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                executeQuery(current_query_index);
-                queries.remove(current_query_index);
-                --current_query_index;
-                if (current_query_index > -1) {
-                    current_state = getCurrentQuery().toDo;
-                } else {
-                    queries.removeAllElements();
-                    current_state = LDAPTransformer.STATE_OUTSIDE;
-                }
-                break;
-            default :
-                throwIllegalStateException("Not expecting a end execute-query element");
-        }
-    }
-
-    protected void startExecuteIncrement(Attributes attributes) {
-        LDAPQuery query;
+    protected void startExecuteElement(int state, String name) {
         switch (current_state) {
             case LDAPTransformer.STATE_OUTSIDE :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
-                getCurrentQuery().query_index = current_query_index;
-                break;
             case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
-                getCurrentQuery().query_index = current_query_index;
+                storeQuery(state);
                 break;
             default :
-                throwIllegalStateException("Not expecting a start execute-increment element");
+                throwIllegalStateException("Not expecting a start " + name + " element");
         }
     }
 
-    protected void endExecuteIncrement() throws SAXException {
-        switch (current_state) {
-            case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT :
-                executeQuery(current_query_index);
-                queries.remove(current_query_index);
-                --current_query_index;
-                if (current_query_index > 1) {
-                    current_state = getCurrentQuery().toDo;
-                } else {
-                    queries.removeAllElements();
-                    current_state = LDAPTransformer.STATE_OUTSIDE;
-                }
-                break;
-            default :
-                throwIllegalStateException("Not expecting a end execute-increment element");
-        }
-    }
-
-    protected void startExecuteReplace(Attributes attributes) {
-        LDAPQuery query;
-        switch (current_state) {
-            case LDAPTransformer.STATE_OUTSIDE :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE;
-                getCurrentQuery().query_index = current_query_index;
-                break;
-            case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE;
-                getCurrentQuery().query_index = current_query_index;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start execute-replace element");
-        }
-    }
-
-    protected void endExecuteReplace() throws SAXException {
-        switch (current_state) {
-            case LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE :
-                executeQuery(current_query_index);
-                queries.remove(current_query_index);
-                --current_query_index;
-                if (current_query_index > 1) {
-                    current_state = getCurrentQuery().toDo;
-                } else {
-                    queries.removeAllElements();
-                    current_state = LDAPTransformer.STATE_OUTSIDE;
-                }
-                break;
-            default :
-                throwIllegalStateException("Not expecting a end execute-replace element");
-        }
-    }
-
-    protected void startExecuteAdd(Attributes attributes) {
-        LDAPQuery query;
-        switch (current_state) {
-            case LDAPTransformer.STATE_OUTSIDE :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_ADD;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_ADD;
-                getCurrentQuery().query_index = current_query_index;
-                break;
-            case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_ADD;
-                current_query_index = queries.size();
-                query = new LDAPQuery(this);
-                queries.addElement(query);
-                getCurrentQuery().toDo = LDAPTransformer.STATE_INSIDE_EXECUTE_ADD;
-                getCurrentQuery().query_index = current_query_index;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start execute-add element");
+    protected void endExecuteElement(int state, String name) throws SAXException {
+        if (current_state == state) {
+            executeQuery(current_query_index);
+            queries.remove(current_query_index);
+            --current_query_index;
+            if (current_query_index > -1) {
+                current_state = getCurrentQuery().toDo;
+            } else {
+                queries.removeAllElements();
+                current_state = LDAPTransformer.STATE_OUTSIDE;
+            }
+        } else {
+            throwIllegalStateException("Not expecting a end " + name + " element");
         }
     }
 
-    protected void endExecuteAdd() throws SAXException {
+    protected void startQueryParameterElement(int state, String name) {
         switch (current_state) {
-            case LDAPTransformer.STATE_INSIDE_EXECUTE_ADD :
-                executeQuery(current_query_index);
-                queries.remove(current_query_index);
-                --current_query_index;
-                if (current_query_index > 1) {
-                    current_state = getCurrentQuery().toDo;
-                } else {
-                    queries.removeAllElements();
-                    current_state = LDAPTransformer.STATE_OUTSIDE;
-                }
+            case STATE_INSIDE_EXECUTE_QUERY :
+            case STATE_INSIDE_EXECUTE_INCREMENT :
+            case STATE_INSIDE_EXECUTE_REPLACE :
+            case STATE_INSIDE_EXECUTE_ADD :
+                current_value.setLength(0);
+                current_state = state;
+                getCurrentQuery().current_state = state;
                 break;
             default :
-                throwIllegalStateException("Not expecting a end execute-add element");
+                throwIllegalStateException("Not expecting a start " + name + " element");
         }
     }
 
-    protected void startInitializerElement(Attributes attributes) {
+    protected void startParameterElement(int state, String name) {
         switch (current_state) {
             case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                break;
             case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                break;
             case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                break;
             case STATE_INSIDE_EXECUTE_ADD :
                 current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
+                current_state = state;
                 break;
             default :
-                throwIllegalStateException("Not expecting a start initializer element");
+                throwIllegalStateException("Not expecting a start " + name + " serverurl element");
         }
     }
 
@@ -525,33 +343,6 @@
         }
     }
 
-    protected void startScopeElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start scope element");
-        }
-    }
-
     protected void endScopeElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT :
@@ -563,33 +354,6 @@
         }
     }
 
-    protected void startAuthenticationElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start authentication element");
-        }
-    }
-
     protected void endAuthenticationElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT :
@@ -601,29 +365,6 @@
         }
     }
 
-    protected void startServerurlElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start serverurl element");
-        }
-    }
-
     protected void endServerurlElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT :
@@ -635,29 +376,6 @@
         }
     }
 
-    protected void startPortElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start port element");
-        }
-    }
-
     protected void endPortElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_PORT_ELEMENT :
@@ -672,19 +390,11 @@
     protected void startShowAttributeElement(Attributes attributes) {
         switch (current_state) {
             case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT;
-                break;
             case STATE_INSIDE_EXECUTE_INCREMENT :
+          //case STATE_INSIDE_EXECUTE_REPLACE:
                 current_value.setLength(0);
                 current_state = LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT;
                 break;
-/*
-            case STATE_INSIDE_EXECUTE_REPLACE:
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT;
-                break;
-*/
             default :
                 throwIllegalStateException("Not expecting a start show-attribute element");
         }
@@ -693,7 +403,7 @@
     protected void endShowAttributeElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT :
-                if (current_value.toString().toUpperCase().equals("FALSE")) {
+                if (!BooleanUtils.toBoolean(current_value.toString())) {
                     getCurrentQuery().showAttribute = false;
                 }
                 current_state = getCurrentQuery().toDo;
@@ -703,29 +413,6 @@
         }
     }
 
-    protected void startSearchbaseElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start searchbase element");
-        }
-    }
-
     protected void endSearchbaseElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT :
@@ -737,29 +424,6 @@
         }
     }
 
-    protected void startDocElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start doc-element element");
-        }
-    }
-
     protected void endDocElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_DOC_ELEMENT :
@@ -771,29 +435,6 @@
         }
     }
 
-    protected void startRowElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start row-element element");
-        }
-    }
-
     protected void endRowElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_ROW_ELEMENT :
@@ -805,26 +446,14 @@
         }
     }
 
-    protected void startErrorElement(Attributes attributes) {
+    protected void endDnAttribute() {
         switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
+            case LDAPTransformer.STATE_INSIDE_DN_ATTRIBUTE :
+                getCurrentQuery().dn_attribute = current_value.toString();
+                current_state = getCurrentQuery().toDo;
                 break;
             default :
-                throwIllegalStateException("Not expecting a start error-element element");
+                throwIllegalStateException("Not expecting a end dn-attribute element");
         }
     }
 
@@ -839,29 +468,6 @@
         }
     }
 
-    protected void startSaxError(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start sax-error element");
-        }
-    }
-
     protected void endSaxError() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT :
@@ -875,29 +481,6 @@
         }
     }
 
-    protected void startRootDnElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start root-dn element");
-        }
-    }
-
     protected void endRootDnElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT :
@@ -909,29 +492,6 @@
         }
     }
 
-    protected void startPasswordElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start password element");
-        }
-    }
-
     protected void endPasswordElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT :
@@ -946,9 +506,6 @@
     protected void startAttributeElement(Attributes attributes) {
         switch (current_state) {
             case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT;
-                current_value.setLength(0);
-                break;
             case STATE_INSIDE_EXECUTE_INCREMENT :
                 current_state = LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT;
                 current_value.setLength(0);
@@ -1022,29 +579,6 @@
         }
     }
 
-    protected void startVersionElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
-                current_value.setLength(0);
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start version element");
-        }
-    }
-
     protected void endVersionElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT :
@@ -1059,20 +593,8 @@
     protected void startFilterElement(Attributes attributes) {
         switch (current_state) {
             case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                current_value.setLength(0);
-                break;
             case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                current_value.setLength(0);
-                break;
             case STATE_INSIDE_EXECUTE_REPLACE :
-                current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
-                current_value.setLength(0);
-                break;
             case STATE_INSIDE_EXECUTE_ADD :
                 current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
                 getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
@@ -1094,35 +616,10 @@
         }
     }
 
-    protected void startDerefLinkElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_state = LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_state = LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
-                current_value.setLength(0);
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start deref-link element");
-        }
-    }
-
     protected void endDerefLinkElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT :
-                if (current_value.toString().toUpperCase().equals("TRUE")) {
-                    getCurrentQuery().deref_link = true;
-                }
+                getCurrentQuery().deref_link = BooleanUtils.toBoolean(current_value.toString());
                 current_state = getCurrentQuery().toDo;
                 break;
             default :
@@ -1130,29 +627,6 @@
         }
     }
 
-    protected void startCountLimitElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_state = LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_state = LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start count-limit element");
-        }
-    }
-
     protected void endCountLimitElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT :
@@ -1164,29 +638,6 @@
         }
     }
 
-    protected void startTimeLimitElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_state = LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_state = LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_state = LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_state = LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
-                current_value.setLength(0);
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start time-limit element");
-        }
-    }
-
     protected void endTimeLimitElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT :
@@ -1198,35 +649,10 @@
         }
     }
 
-    protected void startDebugElement(Attributes attributes) {
-        switch (current_state) {
-            case STATE_INSIDE_EXECUTE_QUERY :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_INCREMENT :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_REPLACE :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
-                break;
-            case STATE_INSIDE_EXECUTE_ADD :
-                current_value.setLength(0);
-                current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
-                break;
-            default :
-                throwIllegalStateException("Not expecting a start debug element");
-        }
-    }
-
     protected void endDebugElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT :
-                if (current_value.toString().toUpperCase().equals("TRUE")) {
-                    getCurrentQuery().debug = true;
-                }
+                getCurrentQuery().debug = BooleanUtils.toBoolean(current_value.toString());
                 current_state = getCurrentQuery().toDo;
                 break;
             default :
@@ -1235,11 +661,11 @@
     }
 
     protected LDAPQuery getCurrentQuery() {
-        return (LDAPQuery) queries.elementAt(current_query_index);
+        return (LDAPQuery)queries.elementAt(current_query_index);
     }
 
     protected LDAPQuery getQuery(int i) {
-        return (LDAPQuery) queries.elementAt(i);
+        return (LDAPQuery)queries.elementAt(i);
     }
 
     /** END my very own methods */
@@ -1263,53 +689,55 @@
         getLogger().debug("RECEIVED START ELEMENT " + name + "(" + uri + ")");
 
         if (name.equals(LDAPTransformer.MAGIC_EXECUTE_QUERY)) {
-            startExecuteQuery(attributes);
+            startExecuteElement();
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_INCREMENT)) {
-            startExecuteIncrement(attributes);
+            startExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_INITIALIZER_ELEMENT)) {
-            startInitializerElement(attributes);
+            startQueryParameterElement(LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT)) {
-            startAuthenticationElement(attributes);
+            startQueryParameterElement(LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_SCOPE_ELEMENT)) {
-            startScopeElement(attributes);
+            startQueryParameterElement(LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_VERSION_ELEMENT)) {
-            startVersionElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_SERVERURL_ELEMENT)) {
-            startServerurlElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_PORT_ELEMENT)) {
-            startPortElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_PORT_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_DOC_ELEMENT)) {
-            startDocElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_DOC_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_ROW_ELEMENT)) {
-            startRowElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_ROW_ELEMENT, name);
+        } else if (name.equals(LDAPTransformer.MAGIC_DN_ATTRIBUTE)) {
+            startParameterElement(LDAPTransformer.STATE_INSIDE_DN_ATTRIBUTE, name);
         } else if (name.equals(LDAPTransformer.MAGIC_ERROR_ELEMENT)) {
-            startErrorElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_SAX_ERROR)) {
-            startSaxError(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_ROOT_DN_ELEMENT)) {
-            startRootDnElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_PASSWORD_ELEMENT)) {
-            startPasswordElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT)) {
             startAttributeElement(attributes);
         } else if (name.equals(LDAPTransformer.MAGIC_SHOW_ATTRIBUTE_ELEMENT)) {
             startShowAttributeElement(attributes);
         } else if (name.equals(LDAPTransformer.MAGIC_SEARCHBASE_ELEMENT)) {
-            startSearchbaseElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_FILTER_ELEMENT)) {
             startFilterElement(attributes);
         } else if (name.equals(LDAPTransformer.MAGIC_DEREF_LINK_ELEMENT)) {
-            startDerefLinkElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_COUNT_LIMIT_ELEMENT)) {
-            startCountLimitElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_TIME_LIMIT_ELEMENT)) {
-            startTimeLimitElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_DEBUG_ELEMENT)) {
-            startDebugElement(attributes);
+            startParameterElement(LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_REPLACE)) {
-            startExecuteReplace(attributes);
+            startExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE, LDAPTransformer.MAGIC_EXECUTE_REPLACE);
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_ADD)) {
-            startExecuteAdd(attributes);
+            startExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_ADD, LDAPTransformer.MAGIC_EXECUTE_ADD);
         }
     }
 
@@ -1318,12 +746,14 @@
             super.endElement(uri, name, raw);
             return;
         }
-        getLogger().debug("RECEIVED END ELEMENT " + name + "(" + uri + ")");
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("RECEIVED END ELEMENT " + name + "(" + uri + ")");
+        }
 
         if (name.equals(LDAPTransformer.MAGIC_EXECUTE_QUERY)) {
-            endExecuteQuery();
+            endExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY, LDAPTransformer.MAGIC_EXECUTE_QUERY);
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_INCREMENT)) {
-            endExecuteIncrement();
+            endExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT, LDAPTransformer.MAGIC_EXECUTE_INCREMENT);
         } else if (name.equals(LDAPTransformer.MAGIC_INITIALIZER_ELEMENT)) {
             endInitializerElement();
         } else if (name.equals(LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT)) {
@@ -1340,6 +770,8 @@
             endDocElement();
         } else if (name.equals(LDAPTransformer.MAGIC_ROW_ELEMENT)) {
             endRowElement();
+        } else if (name.equals(LDAPTransformer.MAGIC_DN_ATTRIBUTE)) {
+            endDnAttribute();
         } else if (name.equals(LDAPTransformer.MAGIC_ERROR_ELEMENT)) {
             endErrorElement();
         } else if (name.equals(LDAPTransformer.MAGIC_SAX_ERROR)) {
@@ -1365,9 +797,9 @@
         } else if (name.equals(LDAPTransformer.MAGIC_DEBUG_ELEMENT)) {
             endDebugElement();
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_REPLACE)) {
-            endExecuteReplace();
+            endExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_REPLACE, LDAPTransformer.MAGIC_EXECUTE_REPLACE);
         } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_ADD)) {
-            endExecuteAdd();
+            endExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_ADD, LDAPTransformer.MAGIC_EXECUTE_ADD);
         }
     }
 
@@ -1380,6 +812,7 @@
             && current_state != LDAPTransformer.STATE_INSIDE_PORT_ELEMENT
             && current_state != LDAPTransformer.STATE_INSIDE_DOC_ELEMENT
             && current_state != LDAPTransformer.STATE_INSIDE_ROW_ELEMENT
+            && current_state != LDAPTransformer.STATE_INSIDE_DN_ATTRIBUTE
             && current_state != LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT
             && current_state != LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT
             && current_state != LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT
@@ -1394,7 +827,9 @@
             && current_state != LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT) {
             super.characters(ary, start, length);
         }
-        getLogger().debug("RECEIVED CHARACTERS: " + new String(ary, start, length));
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("RECEIVED CHARACTERS: " + new String(ary, start, length));
+        }
         current_value.append(ary, start, length);
     }
 
@@ -1414,22 +849,14 @@
     }
 
     protected static String getStringValue(Object object) {
-        if (object instanceof byte[]) {
-            return new String((byte[]) object);
-        } else if (object instanceof char[]) {
-            return new String((char[]) object);
-        } else if (object != null) {
-            return object.toString();
-        } else {
-            return "";
-        }
+        return ObjectUtils.toString(object);
     }
 
     public final Logger getTheLogger() {
         return getLogger();
     }
 
-    class LDAPQuery {
+    static class LDAPQuery {
 
         /** What index are you in daddy's queries list */
         protected int query_index;
@@ -1441,16 +868,16 @@
         protected LDAPTransformer transformer;
 
         /** LDAP configuration information */
-        protected String initializer = "com.sun.jndi.ldap.LdapCtxFactory";
-        protected String serverurl = "localhost";
-        protected int port = 389;
-        protected String root_dn = "";
-        protected String password = "";
-        protected String version = "2";
-        protected String scope = "ONELEVEL_SCOPE";
-        protected String authentication = "simple";
-        private final String LDAP_ENCODING = "ISO-8859-1"; 
-        protected String encoding = LDAP_ENCODING;
+        protected String initializer;
+        protected String serverurl;
+        protected int port;
+        protected String root_dn;
+        protected String password;
+        protected String version;
+        protected String scope;
+        protected String authentication;
+        private final static String LDAP_ENCODING = "ISO-8859-1"; 
+        protected String encoding;
 
         /** LDAP environment information */
         protected Properties env = new Properties();
@@ -1458,94 +885,62 @@
 
         /** LDAP Query */
         protected int toDo;
-        protected String searchbase = "";
+        protected String searchbase;
         protected List attrModeVal = new LinkedList();
         protected List attrListe = new LinkedList();
         protected List attrVale = new LinkedList();
-        protected String REPLACE_MODE_DEFAULT = "";
-        protected String REPLACE_MODE_APPEND = "";
-        protected boolean showAttribute = true;
-        protected String filter = "";
-        protected String doc_element = "doc-element";
+        protected String REPLACE_MODE_DEFAULT = StringUtils.defaultString(LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_DEFAULT);
+        protected String REPLACE_MODE_APPEND = StringUtils.defaultString(LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A);
+        protected boolean showAttribute;
+        protected String filter;
+        protected String doc_element;
         protected String exec_element = "exec-element";
-        protected String row_element = "row-element";
-        protected String error_element = "ldap-error";
-        protected boolean sax_error = false;
-        protected boolean deref_link = false;
-        // Dereference: true -> dereference the link during search
-        protected long count_limit = 0; // Maximum number of entries to return: 0 -> no limit
-        protected int time_limit = 0;
-        // Number of milliseconds to wait before return: 0 -> infinite
-        protected boolean debug = false;
+        protected String row_element;
+        protected String dn_attribute;
+        protected String error_element;
+        protected boolean sax_error;
+        protected boolean deref_link; // Dereference: true -> dereference the link during search
+        protected long count_limit;   // Maximum number of entries to return: 0 -> no limit
+        protected int time_limit;     // Number of milliseconds to wait before return: 0 -> infinite
+        protected boolean debug; 
 
         protected LDAPQuery(LDAPTransformer transformer) {
             this.transformer = transformer;
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_INITIALIZER_ELEMENT)) {
-                initializer = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_INITIALIZER_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SERVERURL_ELEMENT)) {
-                serverurl = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SERVERURL_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_PORT_ELEMENT)) {
-                port = Integer.parseInt(transformer.default_properties.getProperty(LDAPTransformer.MAGIC_PORT_ELEMENT));
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ROOT_DN_ELEMENT)) {
-                root_dn = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ROOT_DN_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_PASSWORD_ELEMENT)) {
-                password = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_PASSWORD_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_VERSION_ELEMENT)) {
-                version = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_VERSION_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SCOPE_ELEMENT)) {
-                scope = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SCOPE_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT)) {
-                authentication = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SEARCHBASE_ELEMENT)) {
-                searchbase = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SEARCHBASE_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SHOW_ATTRIBUTE_ELEMENT)) {
-                showAttribute = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SHOW_ATTRIBUTE_ELEMENT).equals("FALSE") ? false : true;
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DOC_ELEMENT)) {
-                doc_element = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DOC_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ROW_ELEMENT)) {
-                row_element = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ROW_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ERROR_ELEMENT)) {
-                error_element = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ERROR_ELEMENT);
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SAX_ERROR)) {
-                sax_error = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_SAX_ERROR).equals("TRUE") ? true : false;
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DEREF_LINK_ELEMENT)) {
-                deref_link = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DEREF_LINK_ELEMENT).equals("TRUE") ? true : false;
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_COUNT_LIMIT_ELEMENT)) {
-                count_limit = Long.parseLong(transformer.default_properties.getProperty(LDAPTransformer.MAGIC_COUNT_LIMIT_ELEMENT));
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_TIME_LIMIT_ELEMENT)) {
-                time_limit = Integer.parseInt(transformer.default_properties.getProperty(LDAPTransformer.MAGIC_TIME_LIMIT_ELEMENT));
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DEBUG_ELEMENT)) {
-                debug = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_DEBUG_ELEMENT).equals("TRUE") ? true : false;
-            }
-            if (null != transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ENCODING_ELEMENT)) {
-                encoding = transformer.default_properties.getProperty(LDAPTransformer.MAGIC_ENCODING_ELEMENT);
-            }
-            if (null != LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A) {
-                REPLACE_MODE_APPEND = LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A;
-            }
-            if (null != LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_DEFAULT) {
-                REPLACE_MODE_DEFAULT = LDAPTransformer.MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_DEFAULT;
-            }
-            if (null != transformer.default_properties.getProperty(MAGIC_FILTER_ELEMENT)) {
-                filter = transformer.default_properties.getProperty(MAGIC_FILTER_ELEMENT);
-            }
+            initializer = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_INITIALIZER_ELEMENT, "com.sun.jndi.ldap.LdapCtxFactory");
+            serverurl = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_SERVERURL_ELEMENT, "localhost");
+            port = MapUtils.getIntValue(transformer.default_properties, LDAPTransformer.MAGIC_PORT_ELEMENT, 389);
+            root_dn = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_ROOT_DN_ELEMENT, "");
+            password = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_PASSWORD_ELEMENT, "");
+            version = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_VERSION_ELEMENT, "2");
+            scope = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_SCOPE_ELEMENT, "ONELEVEL_SCOPE");
+            authentication = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT, "simple");
+            searchbase = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_SEARCHBASE_ELEMENT, "");
+            showAttribute = MapUtils.getBooleanValue(transformer.default_properties, LDAPTransformer.MAGIC_SHOW_ATTRIBUTE_ELEMENT, true);
+            doc_element = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_DOC_ELEMENT, "doc-element");
+            row_element = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_ROW_ELEMENT, "row-element");
+            dn_attribute = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_DN_ATTRIBUTE, "");
+            error_element = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_ERROR_ELEMENT, "ldap-error");
+            sax_error = MapUtils.getBooleanValue(transformer.default_properties, LDAPTransformer.MAGIC_SAX_ERROR);
+            deref_link = MapUtils.getBooleanValue(transformer.default_properties, LDAPTransformer.MAGIC_DEREF_LINK_ELEMENT);
+            count_limit = MapUtils.getLongValue(transformer.default_properties, LDAPTransformer.MAGIC_DEREF_LINK_ELEMENT);
+            time_limit = MapUtils.getIntValue(transformer.default_properties, LDAPTransformer.MAGIC_TIME_LIMIT_ELEMENT);
+            debug = MapUtils.getBooleanValue(transformer.default_properties, LDAPTransformer.MAGIC_DEBUG_ELEMENT);
+            encoding = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_ENCODING_ELEMENT, LDAP_ENCODING);
+            filter = MapUtils.getString(transformer.default_properties, LDAPTransformer.MAGIC_FILTER_ELEMENT, "");
+        }
+
+        /** shared constraints initialization */
+        protected void initConstraints(SearchControls constraints) {
+            if (scope.equals("OBJECT_SCOPE")) {
+                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
+            } else if (scope.equals("SUBTREE_SCOPE")) {
+                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
+            } else {
+                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+            }
+            constraints.setTimeLimit(time_limit);
+            constraints.setDerefLinkFlag(deref_link);
+            constraints.setCountLimit(count_limit);
         }
 
         protected void execute() throws Exception, NamingException {
@@ -1563,16 +958,7 @@
                 switch (toDo) {
                     case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
                         try {
-                            if (scope.equals("OBJECT_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
-                            } else if (scope.equals("SUBTREE_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
-                            } else {
-                                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
-                            }
-                            constraints.setTimeLimit(time_limit);
-                            constraints.setDerefLinkFlag(deref_link);
-                            constraints.setCountLimit(count_limit);
+                            initConstraints(constraints);
                             if (attrList.length > 0) {
                                 constraints.setReturningAttributes(attrList);
                             }
@@ -1585,10 +971,18 @@
                                 NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
 
                                 while (ldapresults != null && ldapresults.hasMore()) {
+                                    SearchResult si = (SearchResult) ldapresults.next();
                                     if (!row_element.equals("")) {
+                                        if(!"".equals(dn_attribute)) {
+                                            String dn;
+                                            if(!"".equals(searchbase))
+                                                dn = si.getName() + ',' + searchbase;
+                                            else
+                                                dn = si.getName();
+                                            attr.addAttribute(null, dn_attribute, dn_attribute, "CDATA", dn);
+                                        }
                                         transformer.start(row_element, attr);
                                     }
-                                    SearchResult si = (SearchResult) ldapresults.next();
                                     javax.naming.directory.Attributes attrs = si.getAttributes();
                                     if (attrs != null) {
                                         NamingEnumeration ae = attrs.getAll();
@@ -1604,10 +998,12 @@
                                                 if (query_index > 0) {
                                                     switch (transformer.getQuery(query_index - 1).current_state) {
                                                         case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
-                                                            if (!transformer.getQuery(query_index - 1).filter.equals("")) {
-                                                                transformer.getQuery(query_index - 1).filter.concat(", ");
+                                                            StringBuffer temp =  new StringBuffer(transformer.getQuery(query_index - 1).filter);
+                                                            if (temp.length() > 0) {
+                                                                temp.append(", ");
                                                             }
-                                                            transformer.getQuery(query_index - 1).filter.concat(attrID).concat("=").concat(attrVal);
+                                                            temp.append(attrID).append("=").append(attrVal);
+                                                            transformer.getQuery(query_index - 1).filter = temp.toString();
                                                             break;
                                                         default :
                                                             transformer.start(attrID, attr);
@@ -1635,6 +1031,9 @@
                                     transformer.start(doc_element, attr);
                                 }
                                 if (!row_element.equals("")) {
+                                    if(!"".equals(dn_attribute)) {
+                                        attr.addAttribute(null, dn_attribute, dn_attribute, "CDATA", searchbase);
+                                    }
                                     transformer.start(row_element, attr);
                                 }
                                 if (attrs != null) {
@@ -1652,10 +1051,12 @@
                                             if (query_index > 0) {
                                                 switch (transformer.getQuery(query_index - 1).current_state) {
                                                     case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
-                                                        if (!transformer.getQuery(query_index - 1).filter.equals("")) {
-                                                            transformer.getQuery(query_index - 1).filter.concat(", ");
+                                                        StringBuffer temp = new StringBuffer(transformer.getQuery(query_index - 1).filter);
+                                                        if (temp.length() > 0) {
+                                                            temp.append(", ");
                                                         }
-                                                        transformer.getQuery(query_index - 1).filter.concat(attrID).concat("=").concat(attrVal);
+                                                        temp.append(attrID).append("=").append(attrVal);
+                                                        transformer.getQuery(query_index - 1).filter = temp.toString();
                                                         break;
                                                     default :
                                                         transformer.start(attrID, attr);
@@ -1689,16 +1090,7 @@
                         break;
                     case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT :
                         try {
-                            if (scope.equals("OBJECT_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
-                            } else if (scope.equals("SUBTREE_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
-                            } else {
-                                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
-                            }
-                            constraints.setTimeLimit(time_limit);
-                            constraints.setDerefLinkFlag(deref_link);
-                            constraints.setCountLimit(count_limit);
+                            initConstraints(constraints);
                             if (attrList.length != 1) {
                                 transformer.start(error_element, attr);
                                 transformer.data("Increment must reference exactly 1 attribute.");
@@ -1774,16 +1166,7 @@
                                 attrModeMap.put(attrList[i], attrMode[i]);
                             }
 
-                            if (scope.equals("OBJECT_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
-                            } else if (scope.equals("SUBTREE_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
-                            } else {
-                                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
-                            }
-                            constraints.setTimeLimit(time_limit);
-                            constraints.setDerefLinkFlag(deref_link);
-                            constraints.setCountLimit(count_limit);
+                            initConstraints(constraints);
                             if (attrList.length < 1) {
                                 transformer.start(error_element, attr);
                                 transformer.data("Modify must reference 1 or more attribute.");
@@ -1792,7 +1175,6 @@
                                 if (!filter.equals("")) {
                                     constraints.setReturningAttributes(attrList);
                                     NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
-                                    String attrID = "";
                                     SearchResult si = null;
                                     /* start indicate element of executing query */
                                     if (!exec_element.equals("")) {
@@ -1810,7 +1192,7 @@
                                             while (ae.hasMoreElements()) {
                                                 Attribute at = (Attribute) ae.next();
                                                 Enumeration vals = at.getAll();
-                                                attrID = at.getID();
+                                                String attrID = at.getID();
                                                 ModificationItem[] mods = new ModificationItem[1];
                                                 replaceMode = (String) attrModeMap.get(attrID);
 
@@ -1818,7 +1200,7 @@
                                                 String newAttrValue = "";
                                                 /* Check the replacing method */
                                                 if (replaceMode.equals(REPLACE_MODE_DEFAULT)) {
-                                                    newAttrValue = (String) attrMap.get(attrID);
+                                                    newAttrValue = (String)attrMap.get(attrID);
                                                 } else if (replaceMode.equals(REPLACE_MODE_APPEND)) {
                                                     newAttrValue = attrValue + (String) attrMap.get(attrID);
                                                 }
@@ -1829,15 +1211,12 @@
 
                                                 // Perform the requested modifications on the named object
                                                 ctx.modifyAttributes(
-                                                    new StringBuffer(si.toString().substring(0, si.toString().indexOf(":")))
-                                                        .append(",")
-                                                        .append(searchbase)
-                                                        .toString(),
-                                                    mods);
+                                                        si.toString().substring(0, si.toString().indexOf(":")) + "," + searchbase,
+                                                        mods);
 
                                                 /* confirm of success */
                                                 transformer.start(attrID, attr);
-                                                transformer.data(new String("replaced"));
+                                                transformer.data("replaced");
                                                 transformer.end(attrID);
                                             }
                                         }
@@ -1853,7 +1232,6 @@
                                 } else {
                                     //filter is not present
                                     javax.naming.directory.Attributes attrs = ctx.getAttributes(searchbase, attrList);
-                                    String attrID = "";
                                     /* start indicate element of executing query */
                                     if (!exec_element.equals("")) {
                                         transformer.start(exec_element, attr);
@@ -1861,13 +1239,12 @@
                                     if (!row_element.equals("")) {
                                         transformer.start(row_element, attr);
                                     }
-
                                     if (attrs != null) {
                                         NamingEnumeration ae = attrs.getAll();
                                         while (ae.hasMoreElements()) {
                                             Attribute at = (Attribute) ae.next();
                                             Enumeration vals = at.getAll();
-                                            attrID = at.getID();
+                                            String attrID = at.getID();
                                             ModificationItem[] mods = new ModificationItem[1];
                                             replaceMode = (String) attrModeMap.get(attrID);
 
@@ -1890,7 +1267,7 @@
 
                                             /* confirm of success */
                                             transformer.start(attrID, attr);
-                                            transformer.data(new String("replaced"));
+                                            transformer.data("replaced");
                                             transformer.end(attrID);
                                         }
                                     }
@@ -1939,16 +1316,7 @@
                             for (int i = 0; i < attrVal.length; i++)
                                 attrMap.put(attrList[i], attrVal[i]);
 
-                            if (scope.equals("OBJECT_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
-                            } else if (scope.equals("SUBTREE_SCOPE")) {
-                                constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
-                            } else {
-                                constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE);
-                            }
-                            constraints.setTimeLimit(time_limit);
-                            constraints.setDerefLinkFlag(deref_link);
-                            constraints.setCountLimit(count_limit);
+                            initConstraints(constraints);
                             if (attrList.length < 1) {
                                 transformer.start(error_element, attr);
                                 transformer.data("Modify must reference 1 or more attribute.");
@@ -1957,7 +1325,6 @@
                                 if (!filter.equals("")) {
                                     constraints.setReturningAttributes(attrList);
                                     NamingEnumeration ldapresults = ctx.search(searchbase, filter, constraints);
-                                    String attrID = "";
                                     SearchResult si = null;
                                     /* start indicate element of executing query */
                                     if (!exec_element.equals("")) {
@@ -1975,7 +1342,7 @@
                                             NamingEnumeration ae = attrs.getAll();
                                             while (ae.hasMoreElements()) {
                                                 Attribute at = (Attribute) ae.next();
-                                                attrID = at.getID();
+                                                String attrID = at.getID();
                                                 // Specify the changes to make
                                                 ModificationItem[] mods = new ModificationItem[1];
 
@@ -1992,14 +1359,14 @@
 
                                                 /* confirm of success */
                                                 transformer.start(attrID, attr);
-                                                transformer.data(new String("replaced"));
+                                                transformer.data("replaced");
                                                 transformer.end(attrID);
                                                 /* Remove the attribute from map after replacing */
                                                 attrMap.remove(attrID);
                                             }
                                         }
                                         /* Add the attributes */
-                                        if (attrMap.size() > 0) {
+                                        if (!attrMap.isEmpty()) {
                                             ModificationItem[] mods = new ModificationItem[1];
                                             for (int i = 0; i < attrList.length; i++) {
                                                 if (attrMap.containsKey(attrList[i])) {
@@ -2016,7 +1383,7 @@
 
                                                     /* confirm of success */
                                                     transformer.start(attrList[i], attr);
-                                                    transformer.data(new String("add"));
+                                                    transformer.data("add");
                                                     transformer.end(attrList[i]);
                                                 }
                                             }
@@ -2024,7 +1391,6 @@
                                         if (!row_element.equals("")) {
                                             transformer.end(row_element);
                                         }
-
                                     }
                                     if (!exec_element.equals("")) {
                                         transformer.end(exec_element);
@@ -2032,7 +1398,6 @@
                                 } else {
                                     //filter is not present
                                     javax.naming.directory.Attributes attrs = ctx.getAttributes(searchbase, attrList);
-                                    String attrID = "";
                                     /* start indicate element of executing query */
                                     if (!exec_element.equals("")) {
                                         transformer.start(exec_element, attr);
@@ -2045,7 +1410,7 @@
                                         NamingEnumeration ae = attrs.getAll();
                                         while (ae.hasMoreElements()) {
                                             Attribute at = (Attribute) ae.next();
-                                            attrID = at.getID();
+                                            String attrID = at.getID();
                                             // Specify the changes to make
                                             ModificationItem[] mods = new ModificationItem[1];
 
@@ -2057,15 +1422,14 @@
 
                                             /* confirm of success */
                                             transformer.start(attrID, attr);
-                                            transformer.data(new String("replaced"));
+                                            transformer.data("replaced");
                                             transformer.end(attrID);
                                             /* Remove the attribute from map after replacing */
                                             attrMap.remove(attrID);
-
                                         }
                                     }
                                     /* Add the attributes */
-                                    if (attrMap.size() > 0) {
+                                    if (!attrMap.isEmpty()) {
                                         ModificationItem[] mods = new ModificationItem[1];
                                         for (int i = 0; i < attrList.length; i++) {
                                             if (attrMap.containsKey(attrList[i])) {
@@ -2076,16 +1440,14 @@
                                                 ctx.modifyAttributes(searchbase, mods);
                                                 /* confirm of success */
                                                 transformer.start(attrList[i], attr);
-                                                transformer.data(new String("add"));
+                                                transformer.data("add");
                                                 transformer.end(attrList[i]);
                                             }
                                         }
                                     }
-
                                     if (!row_element.equals("")) {
                                         transformer.end(row_element);
                                     }
-
                                     /* end indicate element of executing query */
                                     if (!exec_element.equals("")) {
                                         transformer.end(exec_element);
@@ -2109,7 +1471,6 @@
                             }
                         }
                         break;
-
                     default :
                 } //end switch
             } catch (NamingException e) {
@@ -2181,27 +1542,30 @@
         }
 
         protected void debugPrint() {
-            transformer.getTheLogger().debug("[LDAPTransformer] query_index: " + query_index);
-            transformer.getTheLogger().debug("[LDAPTransformer] current_state: " + current_state);
-            transformer.getTheLogger().debug("[LDAPTransformer] serverurl: " + serverurl);
-            transformer.getTheLogger().debug("[LDAPTransformer] port: " + port);
-            transformer.getTheLogger().debug("[LDAPTransformer] root_dn: " + root_dn);
-            transformer.getTheLogger().debug("[LDAPTransformer] password: " + password);
-            transformer.getTheLogger().debug("[LDAPTransformer] version: " + version);
-            transformer.getTheLogger().debug("[LDAPTransformer] scope: " + scope);
-            transformer.getTheLogger().debug("[LDAPTransformer] authentication: " + authentication);
-            transformer.getTheLogger().debug("[LDAPTransformer] toDo: " + toDo);
-            transformer.getTheLogger().debug("[LDAPTransformer] searchbase: " + searchbase);
-            transformer.getTheLogger().debug("[LDAPTransformer] showAttribute: " + showAttribute);
-            transformer.getTheLogger().debug("[LDAPTransformer] attribute: " + attrListe.toString());
-            transformer.getTheLogger().debug("[LDAPTransformer] filter: " + filter);
-            transformer.getTheLogger().debug("[LDAPTransformer] doc_element: " + doc_element);
-            transformer.getTheLogger().debug("[LDAPTransformer] row_element: " + row_element);
-            transformer.getTheLogger().debug("[LDAPTransformer] error_element: " + error_element);
-            transformer.getTheLogger().debug("[LDAPTransformer] sax-error: " + sax_error);
-            transformer.getTheLogger().debug("[LDAPTransformer] deref_link: " + deref_link);
-            transformer.getTheLogger().debug("[LDAPTransformer] count_limit: " + count_limit);

[... 29 lines stripped ...]


Mime
View raw message