directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r909084 - in /websites/staging/directory/trunk/content: ./ api/user-guide/2.10-ldap-connection-template.html
Date Sat, 17 May 2014 13:16:32 GMT
Author: buildbot
Date: Sat May 17 13:16:32 2014
New Revision: 909084

Log:
Staging update by buildbot for directory

Modified:
    websites/staging/directory/trunk/content/   (props changed)
    websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html

Propchange: websites/staging/directory/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat May 17 13:16:32 2014
@@ -1 +1 @@
-1595467
+1595472

Modified: websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
==============================================================================
--- websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
(original)
+++ websites/staging/directory/trunk/content/api/user-guide/2.10-ldap-connection-template.html
Sat May 17 13:16:32 2014
@@ -205,6 +205,48 @@
 
 
 <h2 id="providing-crud-methods">Providing CRUD Methods</h2>
+<p>The standard CRUD methods are provided (<em>though in this case Add, Lookup,
Modify, Delete</em>) with a couple useful overloads.  Add, Delete, and Modify all provide
at least 2 approaches.  The first is creating your own XxxRequest objects and supplying that
the the method.  This can be done by using the ModelFactory methods provided by LdapConnectionTemplate.
 The second, more elegant solution, is to use the DN and RequestBuilder approach.  This approach
will generate the request for you from the internal ModelFactory and provide it to a callback
for you to fill in the details.  This has the added benefit of translating LdapException to
LdapRuntimeException, to remove the <strong><em>**need</em></strong>**
for try/catch blocks.  Now for some examples:</p>
+<p>Add provides the standard approaches of supplying your own AddRequest and using
RequestBuilder, as well as a third shortcut approach where you supply all the attributes instead
of a RequestBuilder:</p>
+<div class="codehilite"><pre><span class="c1">// using RequestBuilder</span>
+<span class="n">AddResponse</span> <span class="n">response</span>
<span class="o">=</span> <span class="n">ldapConnectionTemplate</span><span
class="o">.</span><span class="na">add</span><span class="o">(</span>
<span class="n">dn</span><span class="o">,</span>
+    <span class="k">new</span> <span class="n">RequestBuilder</span><span
class="o">&lt;</span><span class="n">AddRequest</span><span class="o">&gt;()</span>
<span class="o">{</span>
+        <span class="nd">@Override</span>
+        <span class="kd">public</span> <span class="kt">void</span>
<span class="nf">buildRequest</span><span class="o">(</span> <span
class="n">AddRequest</span> <span class="n">request</span> <span class="o">)</span>
<span class="kd">throws</span> <span class="n">LdapException</span>
<span class="o">{</span>
+            <span class="n">request</span><span class="o">.</span><span
class="na">getEntry</span><span class="o">()</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;objectClass&quot;</span><span
class="o">,</span> <span class="s">&quot;top&quot;</span><span
class="o">,</span> <span class="s">&quot;person&quot;</span><span
class="o">,</span> <span class="s">&quot;organizationalPerson&quot;</span><span
class="o">,</span> <span class="s">&quot;inetOrgPerson&quot;</span>
<span class="o">)</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;cn&quot;</span><span
class="o">,</span> <span class="s">&quot;Kermit The Frog&quot;</span>
<span class="o">)</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;givenName&quot;</span><span
class="o">,</span> <span class="s">&quot;Kermit&quot;</span>
<span class="o">)</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;sn&quot;</span><span
class="o">,</span> <span class="s">&quot;The Frog&quot;</span>
<span class="o">)</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;mail&quot;</span><span
class="o">,</span> <span class="s">&quot;kermitthefrog@muppets.org&quot;</span>
<span class="o">)</span>
+                <span class="o">.</span><span class="na">add</span><span
class="o">(</span> <span class="s">&quot;uid&quot;</span><span
class="o">,</span> <span class="s">&quot;kermitthefrog&quot;</span>
<span class="o">);</span>
+        <span class="o">}</span>
+    <span class="o">}</span> <span class="o">);</span>
+
+<span class="c1">// using Attributes list</span>
+<span class="n">AddResponse</span> <span class="n">response</span>
<span class="o">=</span> <span class="n">ldapConnectionTemplate</span><span
class="o">.</span><span class="na">add</span><span class="o">(</span>
<span class="n">dn</span><span class="o">,</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;objectClass&quot;</span><span
class="o">,</span> 
+        <span class="s">&quot;top&quot;</span><span class="o">,</span>
<span class="s">&quot;person&quot;</span><span class="o">,</span>
<span class="s">&quot;organizationalPerson&quot;</span><span class="o">,</span>
<span class="s">&quot;inetOrgPerson&quot;</span> <span class="o">),</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;cn&quot;</span><span
class="o">,</span> <span class="s">&quot;Kermit The Frog&quot;</span>
<span class="o">),</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;givenName&quot;</span><span
class="o">,</span> <span class="s">&quot;Kermit&quot;</span>
<span class="o">),</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;sn&quot;</span><span
class="o">,</span> <span class="s">&quot;The Frog&quot;</span>
<span class="o">),</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;mail&quot;</span><span
class="o">,</span> <span class="s">&quot;kermitthefrog@muppets.org&quot;</span>
<span class="o">),</span>
+    <span class="n">ldapConnectionTemplate</span><span class="o">.</span><span
class="na">newAttribute</span><span class="o">(</span> <span class="s">&quot;uid&quot;</span><span
class="o">,</span> <span class="s">&quot;kermitthefrog&quot;</span>
<span class="o">)</span> <span class="o">);</span>
+</pre></div>
+
+
+<p>Modify:</p>
+<div class="codehilite"><pre><span class="c1">// using RequestBuilder</span>
+<span class="n">ModifyResponse</span> <span class="n">response</span>
<span class="o">=</span> <span class="n">ldapConnectionTemplate</span><span
class="o">.</span><span class="na">modify</span><span class="o">(</span>
<span class="n">dn</span><span class="o">,</span>
+    <span class="k">new</span> <span class="n">RequestBuilder</span><span
class="o">&lt;</span><span class="n">ModifyRequest</span><span
class="o">&gt;()</span> <span class="o">{</span>
+        <span class="nd">@Override</span>
+        <span class="kd">public</span> <span class="kt">void</span>
<span class="nf">buildRequest</span><span class="o">(</span> <span
class="n">ModifyRequest</span> <span class="n">request</span> <span
class="o">)</span> <span class="kd">throws</span> <span class="n">LdapException</span>
<span class="o">{</span>
+            <span class="n">request</span><span class="o">.</span><span
class="na">replace</span><span class="o">(</span> <span class="s">&quot;sn&quot;</span><span
class="o">,</span> <span class="s">&quot;The Frog&quot;</span>
<span class="o">);</span>
+            <span class="n">request</span><span class="o">.</span><span
class="na">replace</span><span class="o">(</span> <span class="s">&quot;cn&quot;</span><span
class="o">,</span> <span class="s">&quot;Miss The Frog&quot;</span>
<span class="o">);</span>
+        <span class="o">}</span>
+    <span class="o">}</span> <span class="o">);</span>
+</pre></div>
+
+
 <h2 id="handling-search-result-iteration">Handling Search Result Iteration</h2>
 <h2 id="providing-simplified-password-policy-aware-authenticationpassword-modification-methods">Providing
Simplified, Password Policy Aware, Authentication/Password Modification Methods</h2>
 



Mime
View raw message