From 9898c1656694000aa090269e7b9889894cf2f063 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 07 May 2012 10:20:21 +0000
Subject: [PATCH] Fix OPENDJ-484: Implement equals and hashCode for SDK schema elements

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java |  186 +++++++++++++++++++++++-----------------------
 1 files changed, 93 insertions(+), 93 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
index 24e6a26..4308e87 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
@@ -96,7 +96,7 @@
     // attribute from the named entry.
     private static SearchRequest getReadSchemaForEntrySearchRequest(final DN dn) {
         return Requests.newSearchRequest(dn, SearchScope.BASE_OBJECT, Filter
-                .getObjectClassPresentFilter(), SUBSCHEMA_SUBENTRY_ATTRS);
+                .objectClassPresent(), SUBSCHEMA_SUBENTRY_ATTRS);
     }
 
     // Constructs a search request for retrieving the named subschema
@@ -1711,56 +1711,6 @@
     }
 
     /**
-     * Asynchronously reads the schema elements contained in the named subschema
-     * sub-entry and adds them to this schema builder.
-     * <p>
-     * If the requested schema is not returned by the Directory Server then the
-     * request will fail with an {@link EntryNotFoundException}.
-     *
-     * @param connection
-     *            A connection to the Directory Server whose schema is to be
-     *            read.
-     * @param name
-     *            The distinguished name of the subschema sub-entry.
-     * @param handler
-     *            A result handler which can be used to asynchronously process
-     *            the operation result when it is received, may be {@code null}.
-     * @param overwrite
-     *            {@code true} if existing schema elements with the same
-     *            conflicting OIDs should be overwritten.
-     * @return A future representing the updated schema builder.
-     * @throws UnsupportedOperationException
-     *             If the connection does not support search operations.
-     * @throws IllegalStateException
-     *             If the connection has already been closed, i.e. if
-     *             {@code connection.isClosed() == true}.
-     * @throws NullPointerException
-     *             If the {@code connection} or {@code name} was {@code null}.
-     */
-    public FutureResult<SchemaBuilder> addSchemaAsync(final Connection connection, final DN name,
-            final ResultHandler<? super SchemaBuilder> handler, final boolean overwrite) {
-        // The call to addSchema will perform copyOnWrite.
-        final SearchRequest request = getReadSchemaSearchRequest(name);
-
-        final FutureResultTransformer<SearchResultEntry, SchemaBuilder> future =
-                new FutureResultTransformer<SearchResultEntry, SchemaBuilder>(handler) {
-
-                    @Override
-                    protected SchemaBuilder transformResult(final SearchResultEntry result)
-                            throws ErrorResultException {
-                        addSchema(result, overwrite);
-                        return SchemaBuilder.this;
-                    }
-
-                };
-
-        final FutureResult<SearchResultEntry> innerFuture =
-                connection.searchSingleEntryAsync(request, future);
-        future.setFutureResult(innerFuture);
-        return future;
-    }
-
-    /**
      * Reads the schema elements contained in the named subschema sub-entry and
      * adds them to this schema builder.
      * <p>
@@ -1932,6 +1882,98 @@
     }
 
     /**
+     * Asynchronously reads the schema elements contained in the named subschema
+     * sub-entry and adds them to this schema builder.
+     * <p>
+     * If the requested schema is not returned by the Directory Server then the
+     * request will fail with an {@link EntryNotFoundException}.
+     *
+     * @param connection
+     *            A connection to the Directory Server whose schema is to be
+     *            read.
+     * @param name
+     *            The distinguished name of the subschema sub-entry.
+     * @param handler
+     *            A result handler which can be used to asynchronously process
+     *            the operation result when it is received, may be {@code null}.
+     * @param overwrite
+     *            {@code true} if existing schema elements with the same
+     *            conflicting OIDs should be overwritten.
+     * @return A future representing the updated schema builder.
+     * @throws UnsupportedOperationException
+     *             If the connection does not support search operations.
+     * @throws IllegalStateException
+     *             If the connection has already been closed, i.e. if
+     *             {@code connection.isClosed() == true}.
+     * @throws NullPointerException
+     *             If the {@code connection} or {@code name} was {@code null}.
+     */
+    public FutureResult<SchemaBuilder> addSchemaAsync(final Connection connection, final DN name,
+            final ResultHandler<? super SchemaBuilder> handler, final boolean overwrite) {
+        // The call to addSchema will perform copyOnWrite.
+        final SearchRequest request = getReadSchemaSearchRequest(name);
+
+        final FutureResultTransformer<SearchResultEntry, SchemaBuilder> future =
+                new FutureResultTransformer<SearchResultEntry, SchemaBuilder>(handler) {
+
+                    @Override
+                    protected SchemaBuilder transformResult(final SearchResultEntry result)
+                            throws ErrorResultException {
+                        addSchema(result, overwrite);
+                        return SchemaBuilder.this;
+                    }
+
+                };
+
+        final FutureResult<SearchResultEntry> innerFuture =
+                connection.searchSingleEntryAsync(request, future);
+        future.setFutureResult(innerFuture);
+        return future;
+    }
+
+    /**
+     * Reads the schema elements contained in the subschema sub-entry which
+     * applies to the named entry and adds them to this schema builder.
+     * <p>
+     * If the requested entry or its associated schema are not returned by the
+     * Directory Server then the request will fail with an
+     * {@link EntryNotFoundException}.
+     * <p>
+     * This implementation first reads the {@code subschemaSubentry} attribute
+     * of the entry in order to identify the schema and then invokes
+     * {@link #addSchemaForEntry(Connection, DN, boolean)} to read the schema.
+     *
+     * @param connection
+     *            A connection to the Directory Server whose schema is to be
+     *            read.
+     * @param name
+     *            The distinguished name of the entry whose schema is to be
+     *            located.
+     * @param overwrite
+     *            {@code true} if existing schema elements with the same
+     *            conflicting OIDs should be overwritten.
+     * @return A reference to this schema builder.
+     * @throws ErrorResultException
+     *             If the result code indicates that the request failed for some
+     *             reason.
+     * @throws UnsupportedOperationException
+     *             If the connection does not support search operations.
+     * @throws IllegalStateException
+     *             If the connection has already been closed, i.e. if
+     *             {@code connection.isClosed() == true}.
+     * @throws NullPointerException
+     *             If the {@code connection} or {@code name} was {@code null}.
+     */
+    public SchemaBuilder addSchemaForEntry(final Connection connection, final DN name,
+            final boolean overwrite) throws ErrorResultException {
+        // The call to addSchema will perform copyOnWrite.
+        final SearchRequest request = getReadSchemaForEntrySearchRequest(name);
+        final Entry entry = connection.searchSingleEntry(request);
+        final DN subschemaDN = getSubschemaSubentryDN(name, entry);
+        return addSchema(connection, subschemaDN, overwrite);
+    }
+
+    /**
      * Asynchronously reads the schema elements contained in the subschema
      * sub-entry which applies to the named entry and adds them to this schema
      * builder.
@@ -1992,48 +2034,6 @@
     }
 
     /**
-     * Reads the schema elements contained in the subschema sub-entry which
-     * applies to the named entry and adds them to this schema builder.
-     * <p>
-     * If the requested entry or its associated schema are not returned by the
-     * Directory Server then the request will fail with an
-     * {@link EntryNotFoundException}.
-     * <p>
-     * This implementation first reads the {@code subschemaSubentry} attribute
-     * of the entry in order to identify the schema and then invokes
-     * {@link #addSchemaForEntry(Connection, DN, boolean)} to read the schema.
-     *
-     * @param connection
-     *            A connection to the Directory Server whose schema is to be
-     *            read.
-     * @param name
-     *            The distinguished name of the entry whose schema is to be
-     *            located.
-     * @param overwrite
-     *            {@code true} if existing schema elements with the same
-     *            conflicting OIDs should be overwritten.
-     * @return A reference to this schema builder.
-     * @throws ErrorResultException
-     *             If the result code indicates that the request failed for some
-     *             reason.
-     * @throws UnsupportedOperationException
-     *             If the connection does not support search operations.
-     * @throws IllegalStateException
-     *             If the connection has already been closed, i.e. if
-     *             {@code connection.isClosed() == true}.
-     * @throws NullPointerException
-     *             If the {@code connection} or {@code name} was {@code null}.
-     */
-    public SchemaBuilder addSchemaForEntry(final Connection connection, final DN name,
-            final boolean overwrite) throws ErrorResultException {
-        // The call to addSchema will perform copyOnWrite.
-        final SearchRequest request = getReadSchemaForEntrySearchRequest(name);
-        final Entry entry = connection.searchSingleEntry(request);
-        final DN subschemaDN = getSubschemaSubentryDN(name, entry);
-        return addSchema(connection, subschemaDN, overwrite);
-    }
-
-    /**
      * Adds the provided substitution syntax definition to this schema builder.
      *
      * @param oid

--
Gitblit v1.10.0