Group  Locate

The Oracle Service Registry Group demos are used to demonstrate the Oracle Service Registry application programming interface's capabilities and to demonstrate how to use this API.

You will learn how to create or update, get, find and delete groups.

The Oracle Service Registry security group demo set contains the following demos to assist you in learning the Oracle Service Registry client API:

Save Demonstrates how to construct and fill the Save_group object, get a Group stub for the UDDI registry, and perform the save_group call.

Delete Demonstrates how to construct and fill the Delete_group object, get a Group stub for the UDDI registry, and perform the delete_group call.

Get Demonstrates how to construct and fill the Get_group object, get a Group stub for the UDDI registry, and perform the get_group call.

Find Demonstrates how to construct and fill the Find_group object, get a Group stub for the UDDI registry, and perform the find_group call.

WhereIAm Demonstrates how to construct and fill the Where_amI object, get a Group stub for the UDDI registry, and perform the where_amI call.

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 the 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 the box, and their modification affects all demos. If you need to redefine a property's value 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 Group demo are loaded from the file:

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

Table 13. Properties Used in Demos

NameDefault ValueDescription
uddi.demos.url.grouphttp://localhost:8888/registry/uddi/groupthe group 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 the programming pattern used in all demos using the WhereIAm demo as an example. You can find this demo's source code in the file:

Windows: %REGISTRY_HOME%\demos\security\group\src\demo\uddi\group\WhereIAm.java
UNIX: $REGISTRY_HOME/demos/security/group/src/demo/uddi/group/WhereIAm.java

The main method starts by gathering configuration information from the user. The first, login name, is used to run the command; the second is argument of the where_amI operation. It then logs the user to the registry, creates the Where_amI object, sends it over SOAP and prints a list of groups to which the login belongs.

String user = UserInput.readString("Enter login to authenticate", 
	               DemoProperties.getProperty(USER_JOHN_NAME));
String password = UserInput.readString("Enter password", 
                       DemoProperties.getProperty(USER_JOHN_PASSWORD));
String login = UserInput.readString("Enter login to search", user);
System.out.println();

UDDI_Security_PortType security = getSecurityStub();
String authInfo = getAuthInfo(user, password, security);
Where_amI save = createWhereAmI(login, authInfo);
GroupList groups = whereAmI(save);
printGroupList(groups);
discardAuthInfo(authInfo, security);

The method createWhereAmI is used to create an object representation of the where_amI operation.

public static Where_amI createWhereAmI(String login, String authInfo)
  throws InvalidParameterException {
    System.out.println("login = " + login);

    Where_amI find = new Where_amI();
    find.setLoginName(login);
    find.setAuthInfo(authInfo);

    return find;
}

The helper method, getGroupStub(), returns the UDDI Group stub of the Web service listening at the URL specified by the URL_GROUP property.

public static GroupApi getGroupStub() throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.group
    String url = DemoProperties.getProperty(URL_GROUP, "http://localhost:8888/registry/uddi/group");
    System.out.print("Using Group API at url " + url + " ..");
    GroupApi account = GroupStub.getInstance(url);
    System.out.println(" done");
    return account;
}

The Oracle Service Registry API call where_amI is performed in the method whereAmI.

public static GroupList whereAmI(Where_amI find)
  throws SOAPException, GroupException {
    GroupApi groupApi = getGroupStub();
    System.out.print("Search in progress ...");
    GroupList groups = groupApi.where_amI(find);
    System.out.println(" done");
    return groups;
}

Finally the method printGroupList is used to print the found groups to the console.

public static void printGroupList(GroupList groups) {
    System.out.println();
    ListDescription listDescription = groups.getListDescription();
    if (listDescription != null) {
        // list description is mandatory part of result, if the resultant list is subset of available data
        int includeCount = listDescription.getIncludeCount();
        int actualCount = listDescription.getActualCount();
        int listHead = listDescription.getListHead();
        System.out.println("Displaying " + includeCount + " of " + actualCount + ", 
	                                                  starting at position " + listHead);
    }

    GroupInfoArrayList groupInfoArrayList = groups.getGroupInfoArrayList();
    if (groupInfoArrayList == null) {
        System.out.println("Nothing found");
        return;
    }

    int position = 1;
    for (Iterator iterator = groupInfoArrayList.iterator(); iterator.hasNext();) {
        GroupInfo group = (GroupInfo) iterator.next();
        System.out.println("Group " + position);
        System.out.println(group.toXML());
        System.out.println();
        System.out.println("********************************************************");
        position++;
    }
}

Building and Running Demos  Locate

This section shows how to build and run the Oracle Service Registry Group demos.

  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\security\group
    UNIX: $REGISTRY_HOME/demos/security/group

  3. Build demos 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. To get list of all available commands, run

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

  5. The selected demo can be executed via the run command with the name of the demo as parameter. For example, to run the WhereIAm demo, invoke

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

    The output of this demo will resemble the following:

    Running WhereIAm demo...
    Find groups of user where
    Enter login to authenticate [demo_john]:
    Enter password [demo_john]:
    Enter login to search [demo_john]:
    
    Using Security at url https://mycomp.com:8443/registry/uddi/security .. done
    Logging in .. done
    login = demo_john
    Using Group API at url https://mycomp.com:8443/registry/uddi/group .. done
    Search in progress ... done
    
    Group 1
    <groupInfo xmlns="http://systinet.com/uddi/group/5.0">
    <name>system#everyone</name>
    <description>The special group that contains all users.</description>
    <privateGroup>false</privateGroup>
    <external>false</external>
    </groupInfo>
    
    ********************************************************
    Group 2
    <groupInfo xmlns="http://systinet.com/uddi/group/5.0">
    <name>system#registered</name>
    <description>The special group that contains all users who are logged
    onto the UDDI registry.</description>
    <privateGroup>false</privateGroup>
    <external>false</external>
    </groupInfo>
    
    ********************************************************
    Logging out .. done
  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.