Configuring Sun Master Indexes

Defining Custom Field Validations for the Master Index

By default, validation.xml defines one validation rule named “validate-local-id”. This rule defines certain validations to perform against local ID and system fields before they are entered into the database. The local ID validator verifies that the system code is valid, the local ID format is correct, the local ID is the correct length, and that neither field is null.

You can define additional validations for your data by creating the Java class and appropriate methods. Create the custom class in the Source Package folder of the master index EJB project so you can include the custom validation rule in the master index application code package. The custom validation classes must implement com.sun.mdm.index.objects.validation.ObjectValidator. The exception thrown is com.sun.mdm.index.objects.validation.exception.ValidationException.

ProcedureTo Implement a Validation Rule

  1. Create the custom validation rules  in the Source Package folder of the EJB project.

  2. In the Projects window, expand the Configuration node in the project you want to modify, and then double-click validation.xml.

    The file opens in the NetBeans XML editor.

  3. Create a new rule element in the rules element.

  4. In the new rule element, create the following attributes:

    • name – A unique name for the validation rule.

    • object-name – The name of the master index Java class that defines the object to which the validation rule is applied, such as SystemObject or Parent_NameObject (where Parent_Name is the name of the parent object in the object definition)

    • class – The complete path of the Java class to call for the validation rule.

      For example:


      <ValidationConfig module-name="Validation" parser-class= 
       "com.sun.mdm.index.configurator.impl.validation.ValidationConfiguration"
         <rules>
            <rule name="validate-auxiliary-id" object-name="PersonObject"
             class="com.sun.mdm.index.user.AuxiliaryId"/>
            <rule name="validate-birth-date" object-name="PersonObject"
             class="com.sun.mdm.index.user.BirthDate"/>
         </rules>
      </ValidationConfig>
  5. Save and close the file.