From 2acc9b3468534251048f561600f42d24d0e07bbf Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 24 Jun 2011 23:01:52 +0000
Subject: [PATCH] Fix for OPENDJ-205: Add support for rejecting and skipping records to the LDIF readers

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java |   63 ++++++++++++++++---------------
 1 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
index 8f7e96e..4fa8f11 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
@@ -3141,7 +3141,8 @@
         // content rule.
         if (checkDITContentRule)
         {
-          if (objectClass.getObjectClassType() == ObjectClassType.AUXILIARY)
+          if (objectClass.getObjectClassType() == ObjectClassType.AUXILIARY
+              && !ditContentRule.getAuxiliaryClasses().contains(objectClass))
           {
             if (errorMessages != null)
             {
@@ -3161,11 +3162,11 @@
         // present.
         if (checkObjectClasses)
         {
-          for (final AttributeType t : objectClass.getRequiredAttributes())
+          for (final AttributeType t : objectClass.getDeclaredRequiredAttributes())
           {
             final Attribute a = Attributes.emptyAttribute(AttributeDescription
                 .create(t));
-            if (entry.containsAttribute(a, null))
+            if (!entry.containsAttribute(a, null))
             {
               if (errorMessages != null)
               {
@@ -3191,7 +3192,7 @@
         {
           final Attribute a = Attributes.emptyAttribute(AttributeDescription
               .create(t));
-          if (entry.containsAttribute(a, null))
+          if (!entry.containsAttribute(a, null))
           {
             if (errorMessages != null)
             {
@@ -3284,37 +3285,37 @@
               }
             }
           }
+        }
 
-          // Check attributes contain an appropriate number of values.
-          if (checkAttributeValues)
+        // Check all attributes contain an appropriate number of values.
+        if (checkAttributeValues)
+        {
+          final int sz = attribute.size();
+
+          if (sz == 0)
           {
-            final int sz = attribute.size();
-
-            if (sz == 0)
+            if (errorMessages != null)
             {
-              if (errorMessages != null)
-              {
-                final LocalizableMessage message = ERR_ENTRY_SCHEMA_AT_EMPTY_ATTRIBUTE
-                    .get(entry.getName().toString(), t.getNameOrOID());
-                errorMessages.add(message);
-              }
-              if (policy.checkAttributeValues().isReject())
-              {
-                return false;
-              }
+              final LocalizableMessage message = ERR_ENTRY_SCHEMA_AT_EMPTY_ATTRIBUTE
+              .get(entry.getName().toString(), t.getNameOrOID());
+              errorMessages.add(message);
             }
-            else if (sz > 1 && t.isSingleValue())
+            if (policy.checkAttributeValues().isReject())
             {
-              if (errorMessages != null)
-              {
-                final LocalizableMessage message = ERR_ENTRY_SCHEMA_AT_SINGLE_VALUED_ATTRIBUTE
-                    .get(entry.getName().toString(), t.getNameOrOID());
-                errorMessages.add(message);
-              }
-              if (policy.checkAttributeValues().isReject())
-              {
-                return false;
-              }
+              return false;
+            }
+          }
+          else if (sz > 1 && t.isSingleValue())
+          {
+            if (errorMessages != null)
+            {
+              final LocalizableMessage message = ERR_ENTRY_SCHEMA_AT_SINGLE_VALUED_ATTRIBUTE
+              .get(entry.getName().toString(), t.getNameOrOID());
+              errorMessages.add(message);
+            }
+            if (policy.checkAttributeValues().isReject())
+            {
+              return false;
             }
           }
         }
@@ -3388,7 +3389,7 @@
       for (final AVA ava : rdn)
       {
         final AttributeType t = ava.getAttributeType();
-        if (nameForm.isRequiredOrOptional(t))
+        if (!nameForm.isRequiredOrOptional(t))
         {
           if (nameFormWarnings != null)
           {

--
Gitblit v1.10.0