Skip Headers
Oracle® Communications Network Integrity UIM Integration Cartridge Guide
Release 7.2.2

Part Number E35810-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
PDF · Mobi · ePub

9 Update Logical Device Coding Example

This chapter provides a client coding example for the Oracle Communications Unified Inventory Management (UIM) Sample Web service.

UIM Sample Web Service Update Logical Device Code Example

Example 9-1 shows a fragment of code used to update a logical device using the UIM Sample Web service. The fragment shows how handling is accomplished for the UIM Sample Web service.

Example 9-1 Update Logical Device Coding Fragment

String errorMessageTask = "";
try {
        if (connect() == null) {
                failAll(context, attributeValueMismatchList, UIM_CONNECTION_FAILURE);
                return;
        }
 
        errorMessageTask = "findLogicalDevice";
        Range range = new Range();
        range.setStartRange(0);
        range.setEndRange(2);
        FindLogicalDeviceRequestType findLogicalDeviceRequestType = new FindLogicalDeviceRequestType();
        findLogicalDeviceRequestType.setId(importedLogicalDevice.getId());
        findLogicalDeviceRequestType.setIdQualifier(SearchQualifier.equals);
        findLogicalDeviceRequestType.setRange(range);
 
        GetIdsResponseType uimLogicalDevices = uimPort.findLogicalDevice(findLogicalDeviceRequestType);
 
        if (uimLogicalDevices.getId() != null) {
                String[] Ids = uimLogicalDevices.getId();
                if (Ids.length != 1) {
                        String msg = "Found " + Ids.length + " logicalDevices matching importedLogicalDevice.getId()="
                                        + importedLogicalDevice.getId() + ", expecting 1";
                        logger.log(Level.SEVERE, msg);
                        failAll(context, attributeValueMismatchList, msg);
                        return;
                }
        }
 
        errorMessageTask = "getLogicalDevice";
        GetLogicalDeviceRequestType getLogicalDeviceRequestType = new GetLogicalDeviceRequestType();
        getLogicalDeviceRequestType.setId(importedLogicalDevice.getId());
        GetLogicalDeviceResponseType getLogicalDeviceResponseType = uimPort
                        .getLogicalDevice(getLogicalDeviceRequestType);
 
        NILogicalDevice wsLogicalDevice = getLogicalDeviceResponseType.getLogicalDevice();
 
        for (DisDiscrepancy discrepancy : attributeValueMismatchList) {
 
                String attrName = discrepancy.getAttributeOrRelationshipName();
 
                if (attrName.equals(NAME)) {
                        wsLogicalDevice.setName(discoveredLogicalDevice.getName());
                } else if (attrName.equals(DESCRIPTION)) {
                        wsLogicalDevice.setDescription(discoveredLogicalDevice.getDescription());
                } else if (attrName.equals(LogicalDeviceHelper.MGMT_IP_ADDRESS)) {
                        copyCharacteristic(discoveredLogicalDevice, wsLogicalDevice, LogicalDeviceHelper.MGMT_IP_ADDRESS);
                } else if (attrName.equals(LogicalDeviceHelper.NATIVE_EMS_ADMIN_SERVICE_STATE)) {
                        wsLogicalDevice.setNativeEmsAdminServiceState(LogicalDeviceHelper
                                        .convertEmsServiceState(discoveredLogicalDevice.getNativeEmsAdminServiceState()));
                } else if (attrName.equals(LogicalDeviceHelper.NATIVE_EMS_SERVICE_STATE)) {
                        wsLogicalDevice.setNativeEmsServiceState(LogicalDeviceHelper.convertEmsServiceState(discoveredLogicalDevice
                                        .getNativeEmsServiceState()));
                } else if (attrName.equals(LogicalDeviceHelper.SYS_OBJECT_ID)) {
                        copyCharacteristic(discoveredLogicalDevice, wsLogicalDevice, LogicalDeviceHelper.SYS_OBJECT_ID);
                } else {
                        copyCharacteristic(discoveredLogicalDevice, wsLogicalDevice, attrName);
                }
        }
        UpdateLogicalDeviceRequestType updateLogicalDeviceRequestType = new UpdateLogicalDeviceRequestType();
        updateLogicalDeviceRequestType.setLogicalDevice(wsLogicalDevice);
 
        errorMessageTask = "updateLogicalDevice";
        checkResponse(uimPort.updateLogicalDevice(updateLogicalDeviceRequestType));
        passAll(context, attributeValueMismatchList);
} catch (Exception e) {
        failAll(context, attributeValueMismatchList, errorMessageTask + LOCAL_ENTITY + discoveredLogicalDevice.getId(), e);
}
logger.exiting(LOG_MYCLASSNAME, "handleAttributeValueMismatch");