Skip Headers
Oracle® Communications Network Integrity UIM Sample Web Service Guide
Release 7.1

E23708-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
Go to next page
Next
PDF · Mobi · ePub

12 Update Logical Device Coding Example

This chapter provides a client coding example for the Network Integrity Unified Inventory Management (UIM) Sample Web Service.

Update Logical Device Coding Fragment

Example 12-1 shows a fragment of code used to update a Logical Device using UIM Sample Web Service. The fragment shows how handling is accomplished for UIM Sample Web Service.

Example 12-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");