cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r380119 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java status.xml
Date Thu, 23 Feb 2006 14:02:35 GMT
Author: jbq
Date: Thu Feb 23 06:02:34 2006
New Revision: 380119

URL: http://svn.apache.org/viewcvs?rev=380119&view=rev
Log:
Fix COCOON-1066 and COCOON-1705

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java?rev=380119&r1=380118&r2=380119&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java
Thu Feb 23 06:02:34 2006
@@ -84,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>
@@ -134,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";
@@ -169,6 +171,7 @@
     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 HashMap default_properties = new HashMap();
@@ -209,6 +212,7 @@
         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
@@ -442,6 +446,17 @@
         }
     }
 
+    protected void endDnAttribute() {
+        switch (current_state) {
+            case LDAPTransformer.STATE_INSIDE_DN_ATTRIBUTE :
+                getCurrentQuery().dn_attribute = current_value.toString();
+                current_state = getCurrentQuery().toDo;
+                break;
+            default :
+                throwIllegalStateException("Not expecting a end dn-attribute element");
+        }
+    }
+
     protected void endErrorElement() {
         switch (current_state) {
             case LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT :
@@ -693,6 +708,8 @@
             startParameterElement(LDAPTransformer.STATE_INSIDE_DOC_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_ROW_ELEMENT)) {
             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)) {
             startParameterElement(LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT, name);
         } else if (name.equals(LDAPTransformer.MAGIC_SAX_ERROR)) {
@@ -753,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)) {
@@ -793,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
@@ -874,8 +894,9 @@
         protected boolean showAttribute;
         protected String filter;
         protected String doc_element;
-        protected String exec_element;
+        protected String exec_element = "exec-element";
         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
@@ -897,6 +918,7 @@
             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);
@@ -949,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();
@@ -1001,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) {

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=380119&r1=380118&r2=380119&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Feb 23 06:02:34 2006
@@ -180,6 +180,13 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.9" date="TBD">
+    <action dev="JBQ" type="fix" fixes-bug="COCOON-1066" due-to="Antonio Fiol" due-to-email="antonio.fiol@gmail.com">
+      LDAPTransformer can optionally output the DN of every returned entry as an
+      attribute.  To enable, use &lt;ldap:dn-attribute&gt;dn&lt;/ldap:dn-attribute&gt;
+    </action>
+    <action dev="JBQ" type="fix" fixes-bug="COCOON-1705" due-to="Warrell Harries" due-to-email="toulouse@vodafone.net">
+      Fix handling of &lt;ldap:execute-replace&gt; causing NPE in LDAPTransformer
+    </action>
     <action dev="CZ" type="update">
       JCR block: To build the JCR block, the jcr-api-1.0.jar has to be downloaded by the
user
                  prior to building the block. Have a look at the readme in the jcr block
for



Mime
View raw message