From c33c04eaf7c85a05e2263e25179b14dad687f4a9 Mon Sep 17 00:00:00 2001
From: Mark Craig <mark.craig@forgerock.com>
Date: Fri, 04 May 2012 07:16:22 +0000
Subject: [PATCH] Fix imports issue pointed out by Matthias
---
opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml | 123 +++++++++++++++++++---------------------
1 files changed, 58 insertions(+), 65 deletions(-)
diff --git a/opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml b/opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml
index bd9c86d..375c213 100644
--- a/opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml
+++ b/opendj3/src/main/docbkx/dev-guide/chap-get-sdk.xml
@@ -248,75 +248,68 @@
described, if you have a directory server running import sample data,
and test your configuration with a sample client application.</para>
- <programlisting language="java">// Test.java:
-// Kick the SDK tires, reading Babs Jensen's entry and displaying LDIF.
-// If your LDAP server is not listening on localhost:1389, or if your
-// data are different change the appropriate lines below.
+ <programlisting language="java">import org.forgerock.opendj.ldap.Connection;
+import org.forgerock.opendj.ldap.LDAPConnectionFactory;
+import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.responses.SearchResultEntry;
+import org.forgerock.opendj.ldap.responses.SearchResultReference;
+import org.forgerock.opendj.ldif.ConnectionEntryReader;
+import org.forgerock.opendj.ldif.LDIFEntryWriter;
-import org.forgerock.opendj.sdk.*;
-import org.forgerock.opendj.sdk.ldif.*;
-import org.forgerock.opendj.sdk.responses.*;
+//Test.java:
+//Kick the SDK tires, reading Babs Jensen's entry and displaying LDIF.
+//If your LDAP server is not listening on localhost:1389, or if your
+//data are different change the appropriate lines below.
-class Test
-{
- public static void main(String [] args)
- {
-
- // Create an LDIF writer which will write the search results to stdout.
-
- final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
- Connection connection = null;
-
- try
- {
- // Connect and bind to the server.
- // CHANGE THIS IF SERVER IS NOT AT localhost:1389.
- final LDAPConnectionFactory factory =
- new LDAPConnectionFactory("localhost", 1389);
-
- connection = factory.getConnection();
- // CHANGE THIS IF ANONYMOUS SEARCHES ARE NOT ALLOWED.
- //connection.bind(userName, password);
-
- // Read the entries and output them as LDIF.
- // CHANGE THIS IF NO uid=bjensen,ou=people,dc=example,dc=com EXISTS.
- final ConnectionEntryReader reader =
- connection.search(
- "dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(uid=bjensen)", "*");
- while (reader.hasNext())
- {
- if (reader.isEntry())
- {
- // Got an entry.
- final SearchResultEntry entry = reader.readEntry();
- writer.writeComment(
- "Search result entry: " + entry.getName().toString());
- writer.writeEntry(entry);
+class Test {
+ public static void main(String[] args) {
+
+ // Create an LDIF writer which will write the search results to stdout.
+
+ final LDIFEntryWriter writer = new LDIFEntryWriter(System.out);
+ Connection connection = null;
+
+ try {
+ // Connect and bind to the server.
+ // CHANGE THIS IF SERVER IS NOT AT localhost:1389.
+ final LDAPConnectionFactory factory =
+ new LDAPConnectionFactory("localhost", 1389);
+
+ connection = factory.getConnection();
+ // CHANGE THIS IF ANONYMOUS SEARCHES ARE NOT ALLOWED.
+ // connection.bind(userName, password);
+
+ // Read the entries and output them as LDIF.
+ // CHANGE THIS IF NO uid=bjensen,ou=people,dc=example,dc=com EXISTS.
+ final ConnectionEntryReader reader =
+ connection.search("dc=example,dc=com",
+ SearchScope.WHOLE_SUBTREE, "(uid=bjensen)", "*");
+ while (reader.hasNext()) {
+ if (reader.isEntry()) {
+ // Got an entry.
+ final SearchResultEntry entry = reader.readEntry();
+ writer.writeComment("Search result entry: "
+ + entry.getName().toString());
+ writer.writeEntry(entry);
+ } else {
+ // Got a continuation reference.
+ final SearchResultReference ref = reader.readReference();
+ writer.writeComment("Search result reference: "
+ + ref.getURIs().toString());
+ }
+ }
+ writer.flush();
+ } catch (final Exception e) {
+ // Handle exceptions...
+ System.err.println(e.getMessage());
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
}
- else
- {
- // Got a continuation reference.
- final SearchResultReference ref = reader.readReference();
- writer.writeComment(
- "Search result reference: " + ref.getURIs().toString());
- }
- }
- writer.flush();
}
- catch (final Exception e)
- {
- // Handle exceptions...
- System.err.println(e.getMessage());
- }
- finally
- {
- if (connection != null)
- {
- connection.close();
- }
- }
- }
-}</programlisting>
+}
+</programlisting>
<para>If all goes well, <filename>Test.java</filename> compiles without
errors. The test program displays Babs Jensen's entry in LDIF.</para>
--
Gitblit v1.10.0