Validation  Locate

The Oracle 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 Oracle 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 Oracle Service Registry and set the REGISTRY_HOME environment variable to the registry's installation location.

To run the Oracle Service Registry's demos, your registry must be running.

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 Oracle 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:8888/registry/uddi/publishingthe publishing Web service port URL
uddi.demos.url.securityhttp://localhost:8888/registry/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 Oracle 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 Oracle 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 Oracle 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 Oracle Service Registry Advanced Validation demo.

  1. Be sure that the demos are properly configured and the Oracle Service Registry is up and running.

  2. Change your working directory to

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

  3. 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.

  4. 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
  5. 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.

  6. When the demo:ISBN taxonomy has been uploaded and ISBNValidation.class copied, you must shutdown the Oracle Service Registry, delete the REGISTRY_HOME/work directory, and restart the Oracle Service Registry.

  7. 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:

  8. 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.