From 68c0e8edba5e13a10df3d0200f6a37ab5d4b2016 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 26 Nov 2013 16:23:21 +0000
Subject: [PATCH] Minor cleanup: rename SchemaValidationPolicy.Policy to SchemaValidationPolicy.Action.

---
 opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java      |   55 ++++++++++++---------------
 opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java |   20 +++++-----
 opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java     |   10 ++--
 opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java            |    6 +-
 4 files changed, 43 insertions(+), 48 deletions(-)

diff --git a/opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java b/opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java
index a00a6d9..493f782 100644
--- a/opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java
+++ b/opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaValidationPolicy.java
@@ -53,9 +53,10 @@
     }
 
     /**
-     * The schema validation policy.
+     * An enumeration of the possible actions which can be performed when a
+     * schema validation failure is encountered.
      */
-    public static enum Policy {
+    public static enum Action {
         /**
          * Schema validation will not be performed.
          */
@@ -73,7 +74,7 @@
          */
         REJECT;
 
-        private Policy() {
+        private Action() {
             // Nothing to do.
         }
 
@@ -151,23 +152,17 @@
      * @return The new schema validation policy.
      */
     public static SchemaValidationPolicy ignoreAll() {
-        return new SchemaValidationPolicy().checkAttributesAndObjectClasses(Policy.IGNORE)
-                .checkAttributeValues(Policy.IGNORE).checkDITContentRules(Policy.IGNORE)
-                .checkNameForms(Policy.IGNORE).requireSingleStructuralObjectClass(Policy.IGNORE);
+        return new SchemaValidationPolicy().checkAttributesAndObjectClasses(Action.IGNORE)
+                .checkAttributeValues(Action.IGNORE).checkDITContentRules(Action.IGNORE)
+                .checkNameForms(Action.IGNORE).requireSingleStructuralObjectClass(Action.IGNORE);
     }
 
-    private Policy checkNameForms = Policy.REJECT;
-
-    private Policy checkDITStructureRules = Policy.IGNORE;
-
-    private Policy checkDITContentRules = Policy.REJECT;
-
-    private Policy requireSingleStructuralObjectClass = Policy.REJECT;
-
-    private Policy checkAttributesAndObjectClasses = Policy.REJECT;
-
-    private Policy checkAttributeValues = Policy.REJECT;
-
+    private Action checkNameForms = Action.REJECT;
+    private Action checkDITStructureRules = Action.IGNORE;
+    private Action checkDITContentRules = Action.REJECT;
+    private Action requireSingleStructuralObjectClass = Action.REJECT;
+    private Action checkAttributesAndObjectClasses = Action.REJECT;
+    private Action checkAttributeValues = Action.REJECT;
     private EntryResolver checkDITStructureRulesEntryResolver = null;
 
     // Prevent direct instantiation.
@@ -187,7 +182,7 @@
      * @return The policy for verifying that the user attributes in an entry
      *         conform to its object classes.
      */
-    public Policy checkAttributesAndObjectClasses() {
+    public Action checkAttributesAndObjectClasses() {
         return checkAttributesAndObjectClasses;
     }
 
@@ -205,7 +200,7 @@
      *            conform to its object classes.
      * @return A reference to this {@code SchemaValidationPolicy}.
      */
-    public SchemaValidationPolicy checkAttributesAndObjectClasses(final Policy policy) {
+    public SchemaValidationPolicy checkAttributesAndObjectClasses(final Action policy) {
         this.checkAttributesAndObjectClasses = policy;
         return this;
     }
@@ -232,7 +227,7 @@
      * @return The policy for verifying that the user attributes in an entry
      *         conform to their associated attribute type descriptions.
      */
-    public Policy checkAttributeValues() {
+    public Action checkAttributeValues() {
         return checkAttributeValues;
     }
 
@@ -260,7 +255,7 @@
      *            conform to their associated attribute type descriptions.
      * @return A reference to this {@code SchemaValidationPolicy}.
      */
-    public SchemaValidationPolicy checkAttributeValues(final Policy policy) {
+    public SchemaValidationPolicy checkAttributeValues(final Action policy) {
         this.checkAttributeValues = policy;
         return this;
     }
@@ -274,7 +269,7 @@
      * @return The policy for validating entries against content rules defined
      *         in the schema.
      */
-    public Policy checkDITContentRules() {
+    public Action checkDITContentRules() {
         return checkDITContentRules;
     }
 
@@ -289,7 +284,7 @@
      *            defined in the schema.
      * @return A reference to this {@code SchemaValidationPolicy}.
      */
-    public SchemaValidationPolicy checkDITContentRules(final Policy policy) {
+    public SchemaValidationPolicy checkDITContentRules(final Action policy) {
         this.checkDITContentRules = policy;
         return this;
     }
@@ -303,7 +298,7 @@
      * @return The policy for validating entries against structure rules defined
      *         in the schema.
      */
-    public Policy checkDITStructureRules() {
+    public Action checkDITStructureRules() {
         return checkDITStructureRules;
     }
 
@@ -325,7 +320,7 @@
      *             {@code checkDITStructureRules} is either {@code WARN} or
      *             {@code REJECT}.
      */
-    public SchemaValidationPolicy checkDITStructureRules(final Policy policy,
+    public SchemaValidationPolicy checkDITStructureRules(final Action policy,
             final EntryResolver resolver) {
         if (checkDITStructureRules.needsChecking() && resolver == null) {
             throw new IllegalArgumentException(
@@ -359,7 +354,7 @@
      * @return The policy for validating entries against name forms defined in
      *         the schema.
      */
-    public Policy checkNameForms() {
+    public Action checkNameForms() {
         return checkNameForms;
     }
 
@@ -374,7 +369,7 @@
      *            in the schema.
      * @return A reference to this {@code SchemaValidationPolicy}.
      */
-    public SchemaValidationPolicy checkNameForms(final Policy policy) {
+    public SchemaValidationPolicy checkNameForms(final Action policy) {
         this.checkNameForms = policy;
         return this;
     }
@@ -389,7 +384,7 @@
      * @return The policy for checking that entries have one and only one
      *         structural object class.
      */
-    public Policy requireSingleStructuralObjectClass() {
+    public Action requireSingleStructuralObjectClass() {
         return requireSingleStructuralObjectClass;
     }
 
@@ -405,7 +400,7 @@
      *            structural object class.
      * @return A reference to this {@code SchemaValidationPolicy}.
      */
-    public SchemaValidationPolicy requireSingleStructuralObjectClass(final Policy policy) {
+    public SchemaValidationPolicy requireSingleStructuralObjectClass(final Action policy) {
         this.requireSingleStructuralObjectClass = policy;
         return this;
     }
diff --git a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
index de52d57..159eba8 100644
--- a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
+++ b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
@@ -38,7 +38,7 @@
 import org.forgerock.opendj.ldap.ErrorResultException;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.EntryResolver;
-import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Policy;
+import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Action;
 import org.forgerock.opendj.ldif.LDIFEntryReader;
 import org.testng.annotations.Test;
 
@@ -269,7 +269,7 @@
         // @formatter:on
 
         assertDoesNotConformToSchema(e, schema, defaultPolicy().checkDITStructureRules(
-                Policy.REJECT, newResolver(null)));
+                Action.REJECT, newResolver(null)));
 
         // @formatter:off
         final Entry p = newEntry(schema,
@@ -280,7 +280,7 @@
             "ou: parent");
         // @formatter:on
 
-        assertConformsToSchema(e, schema, defaultPolicy().checkDITStructureRules(Policy.REJECT,
+        assertConformsToSchema(e, schema, defaultPolicy().checkDITStructureRules(Action.REJECT,
                 newResolver(p)));
 
         // @formatter:off
@@ -292,7 +292,7 @@
         // @formatter:on
 
         assertDoesNotConformToSchema(e, schema, defaultPolicy().checkDITStructureRules(
-                Policy.REJECT, newResolver(null)));
+                Action.REJECT, newResolver(null)));
 
         // @formatter:off
         e = newEntry(schema,
@@ -303,7 +303,7 @@
         // @formatter:on
 
         assertDoesNotConformToSchema(e, schema, defaultPolicy().checkDITStructureRules(
-                Policy.REJECT, newResolver(p)));
+                Action.REJECT, newResolver(p)));
     }
 
     /**
@@ -522,7 +522,7 @@
         e.removeAttribute("objectClass", "organization");
         e.removeAttribute("o", "test");
 
-        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Policy.REJECT));
+        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Action.REJECT));
     }
 
     /**
@@ -563,10 +563,10 @@
             "dc: foo");
         // @formatter:on
 
-        assertDoesNotConformToSchema(e, ignoreAll().checkAttributeValues(Policy.REJECT));
+        assertDoesNotConformToSchema(e, ignoreAll().checkAttributeValues(Action.REJECT));
 
         e.removeAttribute("dc", "foo");
-        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Policy.REJECT));
+        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Action.REJECT));
     }
 
     /**
@@ -588,10 +588,10 @@
             "creatorsName: cn=Another Manager");
         // @formatter:on
 
-        assertDoesNotConformToSchema(e, ignoreAll().checkAttributeValues(Policy.REJECT));
+        assertDoesNotConformToSchema(e, ignoreAll().checkAttributeValues(Action.REJECT));
 
         e.removeAttribute("creatorsName", "cn=Another Manager");
-        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Policy.REJECT));
+        assertConformsToSchema(e, ignoreAll().checkAttributeValues(Action.REJECT));
     }
 
     /**
diff --git a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java
index d090723..3c9fe98 100644
--- a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java
+++ b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFChangeRecordReaderTestCase.java
@@ -62,7 +62,7 @@
 import org.forgerock.opendj.ldap.schema.Schema;
 import org.forgerock.opendj.ldap.schema.SchemaBuilder;
 import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy;
-import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Policy;
+import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Action;
 import org.testng.annotations.Test;
 
 /**
@@ -946,7 +946,7 @@
         reader.setRejectedLDIFListener(listener)
              .setSchemaValidationPolicy(
                  SchemaValidationPolicy.ignoreAll()
-                     .checkAttributesAndObjectClasses(Policy.REJECT));
+                     .checkAttributesAndObjectClasses(Action.REJECT));
         // @formatter:on
 
         assertThat(reader.hasNext()).isFalse();
@@ -982,7 +982,7 @@
         reader.setRejectedLDIFListener(listener)
              .setSchemaValidationPolicy(
                  SchemaValidationPolicy.ignoreAll()
-                     .checkAttributesAndObjectClasses(Policy.WARN));
+                     .checkAttributesAndObjectClasses(Action.WARN));
         // @formatter:on
 
         assertThat(reader.hasNext()).isTrue();
@@ -1876,7 +1876,7 @@
     /**
      * Change Record throw an exception because the added attribute is not valid
      * ('badAttribute') relative to the default schema. Here, we use a
-     * Policy.warn instead of a Policy.REJECT (default)
+     * Action.warn instead of a Action.REJECT (default)
      *
      * @throws Exception
      */
@@ -1896,7 +1896,7 @@
         final LDIFChangeRecordReader reader = new LDIFChangeRecordReader(strChangeRecord);
         reader.setSchema(Schema.getDefaultSchema());
         reader.setSchemaValidationPolicy(SchemaValidationPolicy.defaultPolicy()
-                .checkAttributesAndObjectClasses(Policy.WARN));
+                .checkAttributesAndObjectClasses(Action.WARN));
 
         try {
             reader.readChangeRecord();
diff --git a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java
index e5a8fd2..54a3653 100644
--- a/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java
+++ b/opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/LDIFEntryReaderTestCase.java
@@ -49,7 +49,7 @@
 import org.forgerock.opendj.ldap.schema.Schema;
 import org.forgerock.opendj.ldap.schema.SchemaBuilder;
 import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy;
-import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Policy;
+import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy.Action;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import static org.fest.assertions.Assertions.assertThat;
@@ -630,7 +630,7 @@
         reader.setRejectedLDIFListener(listener)
              .setSchemaValidationPolicy(
                  SchemaValidationPolicy.ignoreAll()
-                     .checkAttributesAndObjectClasses(Policy.REJECT));
+                     .checkAttributesAndObjectClasses(Action.REJECT));
         // @formatter:on
 
         assertThat(reader.hasNext()).isFalse();
@@ -659,7 +659,7 @@
                 new LDIFEntryReader("dn: dc=example,dc=com", "changetype: add", "objectClass: top",
                         "objectClass: domainComponent", "dc: example", "xxx: unknown attribute");
         reader.setRejectedLDIFListener(listener).setSchemaValidationPolicy(
-                SchemaValidationPolicy.ignoreAll().checkAttributesAndObjectClasses(Policy.WARN));
+                SchemaValidationPolicy.ignoreAll().checkAttributesAndObjectClasses(Action.WARN));
 
         assertThat(reader.hasNext()).isTrue();
 

--
Gitblit v1.10.0