Updating Push Destinations for Resources — Service Connector API Example (Java)

Example code is provided that illustrates adding values to organization model attributes using method calls available in the Service Connector API.

The step numbers in the comments correspond to the steps in the illustration, Updating Push Destinations for Organizational Entities.

public void updateResourcePushDestinations(int aModelVersion) throws DirectoryEngineFault, SecurityFault
    {
        // Step 1: perform some search on resources
        FindResources findResources = FindResources.Factory.newInstance();
        findResources.setModelVersion(aModelVersion);
        findResources.addResourceName("Clint Hill");
        FindResourcesResponse resources = getOrgResourceService().findResources(findResources);
        // select a resource from list
        XmlModelEntity resource = resources.getResourceArray(0);
        // Step 2: get details of the selected resource
        String[] guids = { resource.getGuid() };
        XmlResourceDetail[] detail = getOrgResourceService().getResource(aModelVersion, guids);
        // select push destination for removal
        XmlPushDestinationId[] removals = { detail[0].getPushDestinationArray(0) };
        // create a new push destination
        XmlPushDestination[] additions = { XmlPushDestination.Factory.newInstance() };
        additions[0].setChannelType(ChannelType.EMAIL_CHANNEL);
        additions[0].setChannelId("work-email");
        additions[0].setName("Office");
        additions[0].addValue("me@work.com");
        additions[0].setEnabled(true);
        // Step 3: update push destinations
        getOrgModelService().updatePushDestinations(-1, OrganisationalEntityType.RESOURCE,
                                                    detail[0].getGuid(), removals, additions);
    }