Validation  Locate

The BEA AquaLogic Service Registry Validation demo shows how to implement, deploy, and use a custom valueset validation service.

The valueset validation API provides methods to validate values used in keyedReferences of checked taxonomies. The checks might range from very simple (check value against list of available values like in InternalValidation service) to complex, which performs contextual checks.

There are two classes and one xml file to import taxonomy, that are used by the Validation demo.

ISBNValidation Valueset validation interface implementation. It checks keyValues from keyedReferences in all structures. The keyValue must be in ISBN format, otherwise E_invalidValue UDDI exception is thrown to deny the save operation.

isbn.xml Taxonomy description used to import checked categorization demo:ISBN into the BEA AquaLogic Service Registry.

ValidationDemo Demonstrates how to save a tModel with the keyedReference, that uses demo:ISBN categorization checked by ISBNValidation.

Prerequisites and Preparatory Steps: Code  Locate

We expect that you have already installed the BEA AquaLogic Service Registry and set the REGISTRY_HOME environment variable to the registry's installation location.

To run the BEA AquaLogic Service Registry's demos, your registry must be running. To start the BEA AquaLogic Service Registry, execute the serverstart script:

Windows:%REGISTRY_HOME%\bin\serverstart.bat
UNIX:$REGISTRY_HOME/bin/serverstart.sh

It is necessary to configure the demos. The configuration system has two levels: global and local. The properties defined at the global level may be overwritten at local level. The global properties are located in the file:

Windows: %REGISTRY_HOME%\demos\env.properties
UNIX: $REGISTRY_HOME/demos/env.properties

The values set during the installation of the BEA AquaLogic Service Registry work out of box, and their modification affects all demos. If you need to redefine the value of some property for a single demo (that is, at the local level), edit env.properties. This file is located in the same directory as the file run.sh ( run.bat). Local level properties for the Validation demo is loaded from the file:

Windows: %REGISTRY_HOME%\demos\advanced\validation\env.properties
UNIX: $REGISTRY_HOME/demos/advanced/validation/env.properties

Table 10. Properties Used in Demos

NameDefault ValueDescription
uddi.demos.user.john.namedemo_johnfirst user's name
uddi.demos.user.john.passworddemo_johnfirst user's password
uddi.demos.url.publishinghttp://localhost:8080/uddi/publishingthe publishing Web service port URL
uddi.demos.url.securityhttp://localhost:8080/uddi/securitythe security Web service port URL

Presentation and Functional Presentation  Locate

This section describes programming pattern used in ISBNValidation class. You can find its source code in the file

Windows: %REGISTRY_HOME%\demos\advanced\validation\src\demo\uddi\validation\ISBNValidation.java
UNIX: $REGISTRY_HOME/demos/advanced/validation/src/demo/uddi/validation/ISBNValidation.java

The BEA AquaLogic Service Registry simplifies the development of Valueset validation services. It intelligently performs some checks automatically based on the properties of the taxonomy (content of categoryBag), so you as developer may concentrate on logic of your validation service. For example it ensures, that categorization tModelKey is not used in identifierBag or that it is used only in UDDI structures, for which its compatibility was declared.

Let's start with description of validate_values method. It serves as starting point to the validation service. The Validate_values object contains at least one tModel, businessEntity, businessService, bindingTemplate or publisherAsertion, which contains reference to the taxonomy validated by this web service. If the validation service is shared between several taxonomies, UDDI structures, which use them, are grouped in single validate_values call.

When the method validate_values finds the structure type to be validated, it calls validate_values on the list of UDDI structures, which iterates over each element in the list and call validate method on single structure. If there is at least one error in dispositionReport, UDDI exception is thrown to deny the save operation.

public DispositionReport validate_values(Validate_values body) throws UDDIException {
    DispositionReport report = new DispositionReport();

    if (body.getBusinessEntityArrayList() != null)
        validate_values(body.getBusinessEntityArrayList(), report);

    else if (body.getBusinessServiceArrayList() != null)
        validate_values(body.getBusinessServiceArrayList(), report);

    else if (body.getTModelArrayList() != null)
        validate_values(body.getTModelArrayList(), report);

    else if (body.getPublisherAssertionArrayList() != null)
        validate_values(body.getPublisherAssertionArrayList(), report);

    else if (body.getBindingTemplateArrayList() != null)
        validate_values(body.getBindingTemplateArrayList(), report);

    ResultArrayList results = report.getResultArrayList();
    if (results == null || results.size() == 0)
        return DispositionReport.DISPOSITION_REPORT_SUCCESS;

    throw new UDDIException(report);
}

This method than validates all keyedReferences and if the structure contains children (for example businessServices in businessEntity), it recursively validates the too. For demo:ISBN categorization the check of identifierBag is useless, because the BEA AquaLogic Service Registry would already detect it as error and stop the execution of save operation.

private void validate(TModel tModel, DispositionReport report) throws UDDIException {
    CategoryBag categoryBag = tModel.getCategoryBag();
    IdentifierBag identifierBag = tModel.getIdentifierBag();
    KeyedReferenceArrayList keyedReferences;

    if (categoryBag != null) {
        keyedReferences = categoryBag.getKeyedReferenceArrayList();
        if (keyedReferences != null) {
            validate(keyedReferences, report);
        }

        validateKeyedReferenceGroups(categoryBag.getKeyedReferenceGroupArrayList(), report);
    }

    if (identifierBag != null) {
        keyedReferences = identifierBag.getKeyedReferenceArrayList();
        if (keyedReferences != null) {
            validate(keyedReferences, report);
        }
    }
}

The method validate iterates over all keyedReferences and if they reference demo:ISBN taxonomy, than it checks the keyValue, if it is in valid ISBN format. If not, it adds error report to dispositionReport.

private void validate(KeyedReferenceArrayList keyedReferenceArrayList, DispositionReport report)
  throws UDDIException {
    for (Iterator iter = keyedReferenceArrayList.iterator(); iter.hasNext();) {
        KeyedReference keyedReference = (KeyedReference) iter.next();
        if (TMODEL_KEY.equalsIgnoreCase(keyedReference.getTModelKey())) {
            if (!checkISBN(keyedReference.getKeyValue())) {
                String message = "KeyValue is not valid ISBN number in " + keyedReference.toXML();
                report.addResult(createResult(UDDIErrorCodes.E_INVALID_VALUE, message));
            }
        }
    }
}

The implementation of ISBNValidation web service is not optimal. It scans all UDDI structures and containers of keyedReferences, even if the BEA AquaLogic Service Registry was configured to deny such usage. The optimal code would check only categoryBag in tModels.

Building and Running Demos  Locate

This section shows, how to build, deploy and run the BEA AquaLogic Service Registry Advanced Validation demo.

  1. Change your working directory to

    Windows: %REGISTRY_HOME%\demos\advanced\validation
    UNIX: $REGISTRY_HOME/demos/advanced/validation

  2. Build all classes using:

    Windows: run.bat make
    UNIX: ./run.sh make

    [Note]Note

    When compiling demos on Windows platforms, you may see the following text:

    A subdirectory or file ..\..\common\.\build\classes already exists.

    This is expected and does not indicate a problem.

  3. Deploy the validation class to the server:

    • If you installed BEA AquaLogic Service Registry as a standalone server:

      1. Copy the file ISBNValidation.class to REGISTRY_HOME/app/uddi/services/Wasp-inf/classes

        Windows: cd %REGISTRY_HOME%\demos\advanced\validation\build
          xcopy classes %REGISTRY_HOME%\app\uddi\services\Wasp-inf\classes /S
        UNIX: cd $REGISTRY_HOME/demos/advanced/validation/build
          cp -r classes $REGISTRY_HOME/app/uddi/services/WASP-INF
      2. Shutdown the BEA AquaLogic Service Registry, delete the REGISTRY_HOME/work directory, and restart the BEA AquaLogic Service Registry.

    • If you ported BEA AquaLogic Service Registry to WebLogic application server:

      1. Copy the ISBNValidation.class to app/uddi/services/Wasp-inf/classes/demo/uddi/validation directory inside the registry.war. We assume registry.war is the web application archive that has been created during porting to WebLogic application server. For more information on porting BEA AquaLogic Service Registry to WebLogic, please see WebLogic in the Installation Guide.

      2. Redeploy registry.war to WebLogic.

  4. Now use Advanced Taxonomy demo UploadTaxonomy to upload the file isbn.xml located in data subdirectory of Validation demo directory. For more information, how to do it, read Taxonomy demo documentation.

  5. The ValidationDemo can be executed via command run with

    Windows: run.bat ValidationDemo
    UNIX: ./run.sh ValidationDemo

    The output of this demo will resemble the following:

  6. To rebuild demos, execute run.bat clean ( ./run.sh clean) to delete the classes directory and run.bat make ( ./run.sh make) to rebuild the demo classes.