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

matthew_swift
11.49.2007 e860ced82e267ff14e3835f4af8ec8250f9d0c78
opendj-sdk/opends/resource/admin/admin.xsd
@@ -1275,6 +1275,16 @@
                      </xsd:documentation>
                    </xsd:annotation>
                  </xsd:element>
                  <xsd:element name="usage" type="xsd:string">
                    <xsd:annotation>
                      <xsd:documentation>
                        The usage string which should be displayed in
                        help relating to this string based property. For
                        example, a pattern which is used to match a
                        host/port string could have the usage HOST:PORT.
                      </xsd:documentation>
                    </xsd:annotation>
                  </xsd:element>
                  <xsd:element name="synopsis"
                    type="tns:rich-description-type">
                    <xsd:annotation>
opendj-sdk/opends/resource/admin/property-types/string.xsl
@@ -44,7 +44,8 @@
    <xsl:if test="adm:pattern/adm:regex">
      <xsl:value-of
        select="concat('      builder.setPattern(&quot;',
                       normalize-space(adm:pattern/adm:regex), '&quot;);&#xa;')" />
                       normalize-space(adm:pattern/adm:regex), '&quot;, &quot;',
                       normalize-space(adm:pattern/adm:usage), '&quot;);&#xa;')" />
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/DebugTargetConfiguration.xml
@@ -28,6 +28,7 @@
          <adm:regex>
            ^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*(#[A-Za-z][A-Za-z0-9_]*)?$
          </adm:regex>
          <adm:usage>JAVA_NAME</adm:usage>
          <adm:synopsis>
            A fully-qualified OpenDS Java package, class, or method name.
          </adm:synopsis>
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml
@@ -89,6 +89,7 @@
          <adm:regex>
            ^([0-7][0-7][0-7])$
          </adm:regex>
          <adm:usage>MODE</adm:usage>
          <adm:synopsis>
            An valid UNIX mode string. The mode string must contain three
            digits between zero and seven.
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml
@@ -89,6 +89,7 @@
          <adm:regex>
            ^([0-7][0-7][0-7])$
          </adm:regex>
          <adm:usage>MODE</adm:usage>
          <adm:synopsis>
            An valid UNIX mode string. The mode string must contain three
            digits between zero and seven.
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml
@@ -89,6 +89,7 @@
          <adm:regex>
            ^([0-7][0-7][0-7])$
          </adm:regex>
          <adm:usage>MODE</adm:usage>
          <adm:synopsis>
            An valid UNIX mode string. The mode string must contain three
            digits between zero and seven.
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FixedTimeLogRotationPolicyConfiguration.xml
@@ -35,6 +35,7 @@
          <adm:regex>
            ^(([0-1][0-9])|([2][0-3]))([0-5][0-9])$
          </adm:regex>
          <adm:usage>HHmm</adm:usage>
          <adm:synopsis>
            24 hour time of day in HHmm format.
          </adm:synopsis>
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/JEBackendConfiguration.xml
@@ -389,6 +389,7 @@
      <adm:string>
        <adm:pattern>
          <adm:regex>7[0-7][0-7]</adm:regex>
          <adm:usage>MODE</adm:usage>
          <adm:synopsis>
            Any octal value between 700 and 777 (the owner must always have
            read, write, and execute permissions on the directory).
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/MultimasterDomainConfiguration.xml
@@ -61,6 +61,7 @@
      <adm:string>
        <adm:pattern>
          <adm:regex>.+:[0-9]+</adm:regex>
          <adm:usage>HOST:PORT</adm:usage>
          <adm:synopsis>
            A hostname, followed by a ":" followed by a port number.
          </adm:synopsis>
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ReplicationServerConfiguration.xml
@@ -65,6 +65,7 @@
      <adm:string>
        <adm:pattern>
          <adm:regex>.+:[0-9]+</adm:regex>
          <adm:usage>HOST:PORT</adm:usage>
          <adm:synopsis>
            A hostname, followed by a ":" followed by a port number.
          </adm:synopsis>
opendj-sdk/opends/src/server/org/opends/server/admin/StringPropertyDefinition.java
@@ -45,15 +45,6 @@
 */
public final class StringPropertyDefinition extends PropertyDefinition<String> {
  // Flag indicating whether values of this property are
  // case-insensitive.
  private final boolean isCaseInsensitive;
  // Optional pattern which values of this property must match.
  private final Pattern pattern;
  /**
   * An interface for incrementally constructing string property
   * definitions.
@@ -68,6 +59,10 @@
    // Optional pattern which values of this property must match.
    private Pattern pattern = null;
    // Pattern usage which provides a user-friendly summary of the
    // pattern if present.
    private String patternUsage = null;
    // Private constructor
@@ -99,16 +94,23 @@
     * @param pattern
     *          The regular expression pattern string, or
     *          <code>null</code> if there is no pattern.
     * @param patternUsage
     *          A user-friendly usage string representing the pattern
     *          which can be used in error messages and help (e.g. for
     *          patterns which match a host/port combination, the
     *          usage string "HOST:PORT" would be appropriate).
     * @throws PatternSyntaxException
     *           If the provided regular expression pattern has an
     *           invalid syntax.
     */
    public final void setPattern(String pattern)
    public final void setPattern(String pattern, String patternUsage)
        throws PatternSyntaxException {
      if (pattern == null) {
        this.pattern = null;
        this.patternUsage = null;
      } else {
        this.pattern = Pattern.compile(pattern);
        this.patternUsage = patternUsage;
      }
    }
@@ -123,7 +125,7 @@
        EnumSet<PropertyOption> options,
        DefaultBehaviorProvider<String> defaultBehavior) {
      return new StringPropertyDefinition(d, propertyName, options,
          defaultBehavior, isCaseInsensitive, pattern);
          defaultBehavior, isCaseInsensitive, pattern, patternUsage);
    }
  }
@@ -140,22 +142,72 @@
   *          The property name.
   * @return Returns the new string property definition builder.
   */
  public static Builder createBuilder(
      AbstractManagedObjectDefinition<?, ?> d, String propertyName) {
  public static Builder createBuilder(AbstractManagedObjectDefinition<?, ?> d,
      String propertyName) {
    return new Builder(d, propertyName);
  }
  // Flag indicating whether values of this property are
  // case-insensitive.
  private final boolean isCaseInsensitive;
  // Optional pattern which values of this property must match.
  private final Pattern pattern;
  // Pattern usage which provides a user-friendly summary of the
  // pattern if present.
  private final String patternUsage;
  // Private constructor.
  private StringPropertyDefinition(
      AbstractManagedObjectDefinition<?, ?> d, String propertyName,
      EnumSet<PropertyOption> options,
  private StringPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d,
      String propertyName, EnumSet<PropertyOption> options,
      DefaultBehaviorProvider<String> defaultBehavior,
      boolean isCaseInsensitive, Pattern pattern) {
      boolean isCaseInsensitive, Pattern pattern, String patternUsage) {
    super(d, String.class, propertyName, options, defaultBehavior);
    this.isCaseInsensitive = isCaseInsensitive;
    this.pattern = pattern;
    this.patternUsage = patternUsage;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) {
    return v.visitString(this, p);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) {
    return v.visitString(this, value, p);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String decodeValue(String value)
      throws IllegalPropertyValueStringException {
    ensureNotNull(value);
    try {
      validateValue(value);
    } catch (IllegalPropertyValueException e) {
      throw new IllegalPropertyValueStringException(this, value);
    }
    return value;
  }
@@ -208,8 +260,8 @@
    String property = "property." + getName()
        + ".syntax.string.pattern.synopsis";
    try {
      return resource.getMessage(getManagedObjectDefinition(),
          property, locale);
      return resource
          .getMessage(getManagedObjectDefinition(), property, locale);
    } catch (MissingResourceException e) {
      return null;
    }
@@ -218,6 +270,21 @@
  /**
   * Gets a user-friendly usage string representing the pattern which
   * can be used in error messages and help (e.g. for patterns which
   * match a host/port combination, the usage string "HOST:PORT" would
   * be appropriate).
   *
   * @return Returns the user-friendly pattern usage string, or
   *         <code>null</code> if there is no pattern.
   */
  public String getPatternUsage() {
    return patternUsage;
  }
  /**
   * Query whether values of this property are case-insensitive.
   *
   * @return Returns <code>true</code> if values are
@@ -250,8 +317,7 @@
   * {@inheritDoc}
   */
  @Override
  public void validateValue(String value)
      throws IllegalPropertyValueException {
  public void validateValue(String value) throws IllegalPropertyValueException {
    ensureNotNull(value);
    if (pattern != null) {
@@ -261,43 +327,4 @@
      }
    }
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public String decodeValue(String value)
      throws IllegalPropertyValueStringException {
    ensureNotNull(value);
    try {
      validateValue(value);
    } catch (IllegalPropertyValueException e) {
      throw new IllegalPropertyValueStringException(this, value);
    }
    return value;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) {
    return v.visitString(this, p);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) {
    return v.visitString(this, value, p);
  }
}
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/admin/StringPropertyDefinitionTest.java
@@ -102,7 +102,7 @@
    StringPropertyDefinition.Builder builder = StringPropertyDefinition
        .createBuilder(RootCfgDefn.getInstance(), "test-property");
    builder.setCaseInsensitive(isCaseInsensitive);
    builder.setPattern(pattern);
    builder.setPattern(pattern, "STRING");
    return builder.getInstance();
  }
}