001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 */ 016package org.opends.server.admin.std.meta; 017 018 019 020import java.util.Collection; 021import java.util.SortedSet; 022import org.forgerock.opendj.ldap.DN; 023import org.opends.server.admin.AdministratorAction; 024import org.opends.server.admin.BooleanPropertyDefinition; 025import org.opends.server.admin.ClassPropertyDefinition; 026import org.opends.server.admin.client.AuthorizationException; 027import org.opends.server.admin.client.CommunicationException; 028import org.opends.server.admin.client.ConcurrentModificationException; 029import org.opends.server.admin.client.ManagedObject; 030import org.opends.server.admin.client.MissingMandatoryPropertiesException; 031import org.opends.server.admin.client.OperationRejectedException; 032import org.opends.server.admin.DefaultBehaviorProvider; 033import org.opends.server.admin.DefinedDefaultBehaviorProvider; 034import org.opends.server.admin.ManagedObjectAlreadyExistsException; 035import org.opends.server.admin.ManagedObjectDefinition; 036import org.opends.server.admin.PropertyOption; 037import org.opends.server.admin.PropertyProvider; 038import org.opends.server.admin.server.ConfigurationChangeListener; 039import org.opends.server.admin.server.ServerManagedObject; 040import org.opends.server.admin.std.client.CoreSchemaCfgClient; 041import org.opends.server.admin.std.server.CoreSchemaCfg; 042import org.opends.server.admin.std.server.SchemaProviderCfg; 043import org.opends.server.admin.StringPropertyDefinition; 044 045 046 047/** 048 * An interface for querying the Core Schema managed object definition 049 * meta information. 050 * <p> 051 * Core Schema define the core schema elements to load. 052 */ 053public final class CoreSchemaCfgDefn extends ManagedObjectDefinition<CoreSchemaCfgClient, CoreSchemaCfg> { 054 055 // The singleton configuration definition instance. 056 private static final CoreSchemaCfgDefn INSTANCE = new CoreSchemaCfgDefn(); 057 058 059 060 // The "allow-zero-length-values-directory-string" property definition. 061 private static final BooleanPropertyDefinition PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING; 062 063 064 065 // The "disabled-matching-rule" property definition. 066 private static final StringPropertyDefinition PD_DISABLED_MATCHING_RULE; 067 068 069 070 // The "disabled-syntax" property definition. 071 private static final StringPropertyDefinition PD_DISABLED_SYNTAX; 072 073 074 075 // The "java-class" property definition. 076 private static final ClassPropertyDefinition PD_JAVA_CLASS; 077 078 079 080 // The "strict-format-country-string" property definition. 081 private static final BooleanPropertyDefinition PD_STRICT_FORMAT_COUNTRY_STRING; 082 083 084 085 // The "strip-syntax-min-upper-bound-attribute-type-description" property definition. 086 private static final BooleanPropertyDefinition PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION; 087 088 089 090 // Build the "allow-zero-length-values-directory-string" property definition. 091 static { 092 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "allow-zero-length-values-directory-string"); 093 builder.setOption(PropertyOption.ADVANCED); 094 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "allow-zero-length-values-directory-string")); 095 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 096 builder.setDefaultBehaviorProvider(provider); 097 PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING = builder.getInstance(); 098 INSTANCE.registerPropertyDefinition(PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING); 099 } 100 101 102 103 // Build the "disabled-matching-rule" property definition. 104 static { 105 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "disabled-matching-rule"); 106 builder.setOption(PropertyOption.MULTI_VALUED); 107 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "disabled-matching-rule")); 108 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("NONE"); 109 builder.setDefaultBehaviorProvider(provider); 110 builder.setPattern("^([0-9.]+\\d|NONE)$", "OID"); 111 PD_DISABLED_MATCHING_RULE = builder.getInstance(); 112 INSTANCE.registerPropertyDefinition(PD_DISABLED_MATCHING_RULE); 113 } 114 115 116 117 // Build the "disabled-syntax" property definition. 118 static { 119 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "disabled-syntax"); 120 builder.setOption(PropertyOption.MULTI_VALUED); 121 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "disabled-syntax")); 122 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("NONE"); 123 builder.setDefaultBehaviorProvider(provider); 124 builder.setPattern("^([0-9.]+\\d|NONE)$", "OID"); 125 PD_DISABLED_SYNTAX = builder.getInstance(); 126 INSTANCE.registerPropertyDefinition(PD_DISABLED_SYNTAX); 127 } 128 129 130 131 // Build the "java-class" property definition. 132 static { 133 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 134 builder.setOption(PropertyOption.MANDATORY); 135 builder.setOption(PropertyOption.ADVANCED); 136 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 137 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.schema.CoreSchemaProvider"); 138 builder.setDefaultBehaviorProvider(provider); 139 builder.addInstanceOf("org.opends.server.schema.SchemaProvider"); 140 PD_JAVA_CLASS = builder.getInstance(); 141 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 142 } 143 144 145 146 // Build the "strict-format-country-string" property definition. 147 static { 148 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strict-format-country-string"); 149 builder.setOption(PropertyOption.ADVANCED); 150 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strict-format-country-string")); 151 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("true"); 152 builder.setDefaultBehaviorProvider(provider); 153 PD_STRICT_FORMAT_COUNTRY_STRING = builder.getInstance(); 154 INSTANCE.registerPropertyDefinition(PD_STRICT_FORMAT_COUNTRY_STRING); 155 } 156 157 158 159 // Build the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 160 static { 161 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "strip-syntax-min-upper-bound-attribute-type-description"); 162 builder.setOption(PropertyOption.ADVANCED); 163 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "strip-syntax-min-upper-bound-attribute-type-description")); 164 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false"); 165 builder.setDefaultBehaviorProvider(provider); 166 PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION = builder.getInstance(); 167 INSTANCE.registerPropertyDefinition(PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION); 168 } 169 170 171 172 /** 173 * Get the Core Schema configuration definition singleton. 174 * 175 * @return Returns the Core Schema configuration definition 176 * singleton. 177 */ 178 public static CoreSchemaCfgDefn getInstance() { 179 return INSTANCE; 180 } 181 182 183 184 /** 185 * Private constructor. 186 */ 187 private CoreSchemaCfgDefn() { 188 super("core-schema", SchemaProviderCfgDefn.getInstance()); 189 } 190 191 192 193 /** 194 * {@inheritDoc} 195 */ 196 public CoreSchemaCfgClient createClientConfiguration( 197 ManagedObject<? extends CoreSchemaCfgClient> impl) { 198 return new CoreSchemaCfgClientImpl(impl); 199 } 200 201 202 203 /** 204 * {@inheritDoc} 205 */ 206 public CoreSchemaCfg createServerConfiguration( 207 ServerManagedObject<? extends CoreSchemaCfg> impl) { 208 return new CoreSchemaCfgServerImpl(impl); 209 } 210 211 212 213 /** 214 * {@inheritDoc} 215 */ 216 public Class<CoreSchemaCfg> getServerConfigurationClass() { 217 return CoreSchemaCfg.class; 218 } 219 220 221 222 /** 223 * Get the "allow-zero-length-values-directory-string" property definition. 224 * <p> 225 * Indicates whether zero-length (that is, an empty string) values 226 * are allowed for directory string. 227 * <p> 228 * This is technically not allowed by the revised LDAPv3 229 * specification, but some environments may require it for backward 230 * compatibility with servers that do allow it. 231 * 232 * @return Returns the "allow-zero-length-values-directory-string" property definition. 233 */ 234 public BooleanPropertyDefinition getAllowZeroLengthValuesDirectoryStringPropertyDefinition() { 235 return PD_ALLOW_ZERO_LENGTH_VALUES_DIRECTORY_STRING; 236 } 237 238 239 240 /** 241 * Get the "disabled-matching-rule" property definition. 242 * <p> 243 * The set of disabled matching rules. 244 * <p> 245 * Matching rules must be specified using the syntax: OID, or use 246 * the default value 'NONE' to specify no value. 247 * 248 * @return Returns the "disabled-matching-rule" property definition. 249 */ 250 public StringPropertyDefinition getDisabledMatchingRulePropertyDefinition() { 251 return PD_DISABLED_MATCHING_RULE; 252 } 253 254 255 256 /** 257 * Get the "disabled-syntax" property definition. 258 * <p> 259 * The set of disabled syntaxes. 260 * <p> 261 * Syntaxes must be specified using the syntax: OID, or use the 262 * default value 'NONE' to specify no value. 263 * 264 * @return Returns the "disabled-syntax" property definition. 265 */ 266 public StringPropertyDefinition getDisabledSyntaxPropertyDefinition() { 267 return PD_DISABLED_SYNTAX; 268 } 269 270 271 272 /** 273 * Get the "enabled" property definition. 274 * <p> 275 * Indicates whether the Core Schema is enabled for use. 276 * 277 * @return Returns the "enabled" property definition. 278 */ 279 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 280 return SchemaProviderCfgDefn.getInstance().getEnabledPropertyDefinition(); 281 } 282 283 284 285 /** 286 * Get the "java-class" property definition. 287 * <p> 288 * Specifies the fully-qualified name of the Java class that 289 * provides the Core Schema implementation. 290 * 291 * @return Returns the "java-class" property definition. 292 */ 293 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 294 return PD_JAVA_CLASS; 295 } 296 297 298 299 /** 300 * Get the "strict-format-country-string" property definition. 301 * <p> 302 * Indicates whether or not country code values are required to 303 * strictly comply with the standard definition for this syntax. 304 * <p> 305 * When set to false, country codes will not be validated and, as a 306 * result any string containing 2 characters will be acceptable. 307 * 308 * @return Returns the "strict-format-country-string" property definition. 309 */ 310 public BooleanPropertyDefinition getStrictFormatCountryStringPropertyDefinition() { 311 return PD_STRICT_FORMAT_COUNTRY_STRING; 312 } 313 314 315 316 /** 317 * Get the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 318 * <p> 319 * Indicates whether the suggested minimum upper bound appended to 320 * an attribute's syntax OID in it's schema definition Attribute Type 321 * Description is stripped off. 322 * <p> 323 * When retrieving the server's schema, some APIs (JNDI) fail in 324 * their syntax lookup methods, because they do not parse this value 325 * correctly. This configuration option allows the server to be 326 * configured to provide schema definitions these APIs can parse 327 * correctly. 328 * 329 * @return Returns the "strip-syntax-min-upper-bound-attribute-type-description" property definition. 330 */ 331 public BooleanPropertyDefinition getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition() { 332 return PD_STRIP_SYNTAX_MIN_UPPER_BOUND_ATTRIBUTE_TYPE_DESCRIPTION; 333 } 334 335 336 337 /** 338 * Managed object client implementation. 339 */ 340 private static class CoreSchemaCfgClientImpl implements 341 CoreSchemaCfgClient { 342 343 // Private implementation. 344 private ManagedObject<? extends CoreSchemaCfgClient> impl; 345 346 347 348 // Private constructor. 349 private CoreSchemaCfgClientImpl( 350 ManagedObject<? extends CoreSchemaCfgClient> impl) { 351 this.impl = impl; 352 } 353 354 355 356 /** 357 * {@inheritDoc} 358 */ 359 public boolean isAllowZeroLengthValuesDirectoryString() { 360 return impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition()); 361 } 362 363 364 365 /** 366 * {@inheritDoc} 367 */ 368 public void setAllowZeroLengthValuesDirectoryString(Boolean value) { 369 impl.setPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition(), value); 370 } 371 372 373 374 /** 375 * {@inheritDoc} 376 */ 377 public SortedSet<String> getDisabledMatchingRule() { 378 return impl.getPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition()); 379 } 380 381 382 383 /** 384 * {@inheritDoc} 385 */ 386 public void setDisabledMatchingRule(Collection<String> values) { 387 impl.setPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition(), values); 388 } 389 390 391 392 /** 393 * {@inheritDoc} 394 */ 395 public SortedSet<String> getDisabledSyntax() { 396 return impl.getPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition()); 397 } 398 399 400 401 /** 402 * {@inheritDoc} 403 */ 404 public void setDisabledSyntax(Collection<String> values) { 405 impl.setPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition(), values); 406 } 407 408 409 410 /** 411 * {@inheritDoc} 412 */ 413 public Boolean isEnabled() { 414 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 415 } 416 417 418 419 /** 420 * {@inheritDoc} 421 */ 422 public void setEnabled(boolean value) { 423 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 424 } 425 426 427 428 /** 429 * {@inheritDoc} 430 */ 431 public String getJavaClass() { 432 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 433 } 434 435 436 437 /** 438 * {@inheritDoc} 439 */ 440 public void setJavaClass(String value) { 441 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 442 } 443 444 445 446 /** 447 * {@inheritDoc} 448 */ 449 public boolean isStrictFormatCountryString() { 450 return impl.getPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition()); 451 } 452 453 454 455 /** 456 * {@inheritDoc} 457 */ 458 public void setStrictFormatCountryString(Boolean value) { 459 impl.setPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition(), value); 460 } 461 462 463 464 /** 465 * {@inheritDoc} 466 */ 467 public boolean isStripSyntaxMinUpperBoundAttributeTypeDescription() { 468 return impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition()); 469 } 470 471 472 473 /** 474 * {@inheritDoc} 475 */ 476 public void setStripSyntaxMinUpperBoundAttributeTypeDescription(Boolean value) { 477 impl.setPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition(), value); 478 } 479 480 481 482 /** 483 * {@inheritDoc} 484 */ 485 public ManagedObjectDefinition<? extends CoreSchemaCfgClient, ? extends CoreSchemaCfg> definition() { 486 return INSTANCE; 487 } 488 489 490 491 /** 492 * {@inheritDoc} 493 */ 494 public PropertyProvider properties() { 495 return impl; 496 } 497 498 499 500 /** 501 * {@inheritDoc} 502 */ 503 public void commit() throws ManagedObjectAlreadyExistsException, 504 MissingMandatoryPropertiesException, ConcurrentModificationException, 505 OperationRejectedException, AuthorizationException, 506 CommunicationException { 507 impl.commit(); 508 } 509 510 511 512 /** {@inheritDoc} */ 513 public String toString() { 514 return impl.toString(); 515 } 516 } 517 518 519 520 /** 521 * Managed object server implementation. 522 */ 523 private static class CoreSchemaCfgServerImpl implements 524 CoreSchemaCfg { 525 526 // Private implementation. 527 private ServerManagedObject<? extends CoreSchemaCfg> impl; 528 529 // The value of the "allow-zero-length-values-directory-string" property. 530 private final boolean pAllowZeroLengthValuesDirectoryString; 531 532 // The value of the "disabled-matching-rule" property. 533 private final SortedSet<String> pDisabledMatchingRule; 534 535 // The value of the "disabled-syntax" property. 536 private final SortedSet<String> pDisabledSyntax; 537 538 // The value of the "enabled" property. 539 private final boolean pEnabled; 540 541 // The value of the "java-class" property. 542 private final String pJavaClass; 543 544 // The value of the "strict-format-country-string" property. 545 private final boolean pStrictFormatCountryString; 546 547 // The value of the "strip-syntax-min-upper-bound-attribute-type-description" property. 548 private final boolean pStripSyntaxMinUpperBoundAttributeTypeDescription; 549 550 551 552 // Private constructor. 553 private CoreSchemaCfgServerImpl(ServerManagedObject<? extends CoreSchemaCfg> impl) { 554 this.impl = impl; 555 this.pAllowZeroLengthValuesDirectoryString = impl.getPropertyValue(INSTANCE.getAllowZeroLengthValuesDirectoryStringPropertyDefinition()); 556 this.pDisabledMatchingRule = impl.getPropertyValues(INSTANCE.getDisabledMatchingRulePropertyDefinition()); 557 this.pDisabledSyntax = impl.getPropertyValues(INSTANCE.getDisabledSyntaxPropertyDefinition()); 558 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 559 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 560 this.pStrictFormatCountryString = impl.getPropertyValue(INSTANCE.getStrictFormatCountryStringPropertyDefinition()); 561 this.pStripSyntaxMinUpperBoundAttributeTypeDescription = impl.getPropertyValue(INSTANCE.getStripSyntaxMinUpperBoundAttributeTypeDescriptionPropertyDefinition()); 562 } 563 564 565 566 /** 567 * {@inheritDoc} 568 */ 569 public void addCoreSchemaChangeListener( 570 ConfigurationChangeListener<CoreSchemaCfg> listener) { 571 impl.registerChangeListener(listener); 572 } 573 574 575 576 /** 577 * {@inheritDoc} 578 */ 579 public void removeCoreSchemaChangeListener( 580 ConfigurationChangeListener<CoreSchemaCfg> listener) { 581 impl.deregisterChangeListener(listener); 582 } 583 /** 584 * {@inheritDoc} 585 */ 586 public void addChangeListener( 587 ConfigurationChangeListener<SchemaProviderCfg> listener) { 588 impl.registerChangeListener(listener); 589 } 590 591 592 593 /** 594 * {@inheritDoc} 595 */ 596 public void removeChangeListener( 597 ConfigurationChangeListener<SchemaProviderCfg> listener) { 598 impl.deregisterChangeListener(listener); 599 } 600 601 602 603 /** 604 * {@inheritDoc} 605 */ 606 public boolean isAllowZeroLengthValuesDirectoryString() { 607 return pAllowZeroLengthValuesDirectoryString; 608 } 609 610 611 612 /** 613 * {@inheritDoc} 614 */ 615 public SortedSet<String> getDisabledMatchingRule() { 616 return pDisabledMatchingRule; 617 } 618 619 620 621 /** 622 * {@inheritDoc} 623 */ 624 public SortedSet<String> getDisabledSyntax() { 625 return pDisabledSyntax; 626 } 627 628 629 630 /** 631 * {@inheritDoc} 632 */ 633 public boolean isEnabled() { 634 return pEnabled; 635 } 636 637 638 639 /** 640 * {@inheritDoc} 641 */ 642 public String getJavaClass() { 643 return pJavaClass; 644 } 645 646 647 648 /** 649 * {@inheritDoc} 650 */ 651 public boolean isStrictFormatCountryString() { 652 return pStrictFormatCountryString; 653 } 654 655 656 657 /** 658 * {@inheritDoc} 659 */ 660 public boolean isStripSyntaxMinUpperBoundAttributeTypeDescription() { 661 return pStripSyntaxMinUpperBoundAttributeTypeDescription; 662 } 663 664 665 666 /** 667 * {@inheritDoc} 668 */ 669 public Class<? extends CoreSchemaCfg> configurationClass() { 670 return CoreSchemaCfg.class; 671 } 672 673 674 675 /** 676 * {@inheritDoc} 677 */ 678 public DN dn() { 679 return impl.getDN(); 680 } 681 682 683 684 /** {@inheritDoc} */ 685 public String toString() { 686 return impl.toString(); 687 } 688 } 689}