mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
16.37.2011 509d7a1481a3ca32f1dc33512963a032ef10ae1d
Minor fixes to SchemaCompatOptions.
3 files modified
111 ■■■■ changed files
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringSyntaxImpl.java 3 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaCompatOptions.java 105 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSyntaxImpl.java 3 ●●●● patch | view | raw | blame | history
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/DirectoryStringSyntaxImpl.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
@@ -110,7 +111,7 @@
  {
    if (value.length() > 0
        || schema.getSchemaCompatOptions()
            .isZeroLengthDirectoryStringsAllowed())
            .allowZeroLengthDirectoryStrings())
    {
      return true;
    }
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaCompatOptions.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
@@ -42,7 +43,8 @@
   *          The options to be copied.
   * @return The copy of the provided schema compatibility options.
   */
  public static SchemaCompatOptions copyOf(final SchemaCompatOptions options)
  public static SchemaCompatOptions copyOf(
      final SchemaCompatOptions options)
  {
    return defaultOptions().assign(options);
  }
@@ -61,9 +63,9 @@
  private boolean isTelephoneNumberSyntaxStrict = false;
  private boolean allowNonStandardTelephoneNumbers = true;
  private boolean isZeroLengthDirectoryStringsAllowed = false;
  private boolean allowZeroLengthDirectoryStrings = false;
@@ -76,55 +78,58 @@
  /**
   * Indicates whether or not the Telephone Number syntax should ensure that all
   * values conform to the E.123 international telephone number format. By
   * default this compatibility option is set to {@code false}.
   * Returns {@code true} if the Telephone Number syntax should allow values
   * which do not conform to the E.123 international telephone number format.
   * <p>
   * By default this compatibility option is set to {@code true}.
   *
   * @return {@code true} if the Telephone Number syntax should ensure that all
   *         values conform to the E.123 international telephone number format,
   *         or {@code false} if not.
   * @return {@code true} if the Telephone Number syntax should allow values
   *         which do not conform to the E.123 international telephone number
   *         format.
   */
  public boolean isTelephoneNumberSyntaxStrict()
  public boolean allowNonStandardTelephoneNumbers()
  {
    return isTelephoneNumberSyntaxStrict;
    return allowNonStandardTelephoneNumbers;
  }
  /**
   * Indicates whether or not zero-length values will be allowed by the
   * Directory String syntax. This is technically forbidden by the LDAP
   * specification, but it was allowed in earlier versions of the server, and
   * the discussion of the directory string syntax in RFC 2252 does not
   * explicitly state that they are not allowed. By default this compatibility
   * option is set to {@code false}.
   * Specifies whether or not the Telephone Number syntax should allow values
   * which do not conform to the E.123 international telephone number format.
   * <p>
   * By default this compatibility option is set to {@code true}.
   *
   * @param allowNonStandardTelephoneNumbers
   *          {@code true} if the Telephone Number syntax should allow values
   *          which do not conform to the E.123 international telephone number
   *          format.
   * @return A reference to this {@code SchemaCompatOptions}.
   */
  public SchemaCompatOptions allowNonStandardTelephoneNumbers(
      final boolean allowNonStandardTelephoneNumbers)
  {
    this.allowNonStandardTelephoneNumbers = allowNonStandardTelephoneNumbers;
    return this;
  }
  /**
   * Returns {@code true} if zero-length values will be allowed by the Directory
   * String syntax. This is technically forbidden by the LDAP specification, but
   * it was allowed in earlier versions of the server, and the discussion of the
   * directory string syntax in RFC 2252 does not explicitly state that they are
   * not allowed.
   * <p>
   * By default this compatibility option is set to {@code false}.
   *
   * @return {@code true} if zero-length values will be allowed by the Directory
   *         String syntax, or {@code false} if not.
   */
  public boolean isZeroLengthDirectoryStringsAllowed()
  public boolean allowZeroLengthDirectoryStrings()
  {
    return isZeroLengthDirectoryStringsAllowed;
  }
  /**
   * Indicates whether or not the Telephone Number syntax should ensure that all
   * values conform to the E.123 international telephone number format. By
   * default this compatibility option is set to {@code false}.
   *
   * @param isStrict
   *          {@code true} if the Telephone Number syntax should ensure that all
   *          values conform to the E.123 international telephone number format,
   *          or {@code false} if not.
   * @return A reference to this {@code SchemaCompat}.
   */
  public SchemaCompatOptions setTelephoneNumberSyntaxStrict(
      final boolean isStrict)
  {
    this.isTelephoneNumberSyntaxStrict = isStrict;
    return this;
    return allowZeroLengthDirectoryStrings;
  }
@@ -134,18 +139,19 @@
   * Directory String syntax. This is technically forbidden by the LDAP
   * specification, but it was allowed in earlier versions of the server, and
   * the discussion of the directory string syntax in RFC 2252 does not
   * explicitly state that they are not allowed. By default this compatibility
   * option is set to {@code false}.
   * explicitly state that they are not allowed.
   * <p>
   * By default this compatibility option is set to {@code false}.
   *
   * @param isAllowed
   * @param allowZeroLengthDirectoryStrings
   *          {@code true} if zero-length values will be allowed by the
   *          Directory String syntax, or {@code false} if not.
   * @return A reference to this {@code SchemaCompat}.
   * @return A reference to this {@code SchemaCompatOptions}.
   */
  public SchemaCompatOptions setZeroLengthDirectoryStringsAllowed(
      final boolean isAllowed)
  public SchemaCompatOptions allowZeroLengthDirectoryStrings(
      final boolean allowZeroLengthDirectoryStrings)
  {
    this.isZeroLengthDirectoryStringsAllowed = isAllowed;
    this.allowZeroLengthDirectoryStrings = allowZeroLengthDirectoryStrings;
    return this;
  }
@@ -154,9 +160,10 @@
  // Assigns the provided options to this set of options.
  SchemaCompatOptions assign(final SchemaCompatOptions options)
  {
    return setTelephoneNumberSyntaxStrict(options.isTelephoneNumberSyntaxStrict)
        .setZeroLengthDirectoryStringsAllowed(
            options.isZeroLengthDirectoryStringsAllowed);
    return allowNonStandardTelephoneNumbers(
        options.allowNonStandardTelephoneNumbers)
        .allowZeroLengthDirectoryStrings(
            options.allowNonStandardTelephoneNumbers);
  }
}
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/TelephoneNumberSyntaxImpl.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
@@ -112,7 +113,7 @@
    final int length = valueStr.length();
    if (schema.getSchemaCompatOptions().isTelephoneNumberSyntaxStrict())
    if (!schema.getSchemaCompatOptions().allowNonStandardTelephoneNumbers())
    {
      // If the value does not start with a plus sign, then that's not
      // acceptable.