Navigating the Organization Model — Service Connector API Example (Java)

Example code is provided that illustrates navigating an organization model using method calls available in the Service Connector API.

The step numbers in the comments correspond to the steps in the illustration, Navigating the Organization Model.

public XmlResourceDetail navigateModel(int aModelVersion)
                                      throws DirectoryEngineFault, SecurityFault
    {
        // Step 1: get details of all model entities in given major version
        GetOrgModelResponse model = getOrgModelService().getOrgModel(aModelVersion, false);
        // select a position, group, etc. from model
        XmlPosition position = model.getOrganizationArray(0).getOrgUnitArray(0).getPositionArray(0);
        // Step 2: list resource associated with model entity
        FindResources request = FindResources.Factory.newInstance();
        request.setModelVersion(aModelVersion);
        request.addNewEntityRef().setGuid(position.getGuid());
        FindResourcesResponse resources = getOrgResourceService().findResources(request);
        // select resource from list
        XmlModelEntity resource = resources.getResourceArray(0);
        // Step 3: get details for selected resource(s)
        String[] guids = { resource.getGuid() };
        XmlResourceDetail[] detail = getOrgResourceService().getResource(aModelVersion, guids);
        return(detail[0]);
    }