15 Integrating UIM Using UIM-Formatted URLs

This chapter provides information about integrating Oracle Communications Unified Inventory Management (UIM) with an external application using a UIM-formatted Uniform Resource Locators (URL), which provides the ability for an external application to access a UIM page.

For example, the OSM-UIM Reference Implementation uses a UIM-formatted URL to access a UIM page from within OSM. In the implementation, the OSM task flow defines numerous tasks, one of which calls the UIM Service Fulfillment Web Service operation of ProcessInteraction. If the operation fails, an OSM fallout task provides a URL link that the user can click to access the UIM Business Interaction Summary page for the business interaction that failed to process.

In such scenarios when a UIM-formatted URL is used to access a UIM page, UIM redirects to the UIM Login page so you can enter your security credentials before continuing to the page specified by the URL. After the specified UIM page is accessed, you have the ability to navigate freely in UIM. For example, from a summary page, you can click Edit and update UIM data from a maintenance page.

About UIM-Formatted URLs

UIM-formatted URLs are used to access UIM pages from an external application.

Table 15-1 lists the supported UIM pages you can access using UIM-formatted URLs. The table also lists the corresponding entity type that you specify as part of the UIM-formatted URL, as described in "About the URL Format".

If you need to access UIM pages other than those listed in Table 15-1, you can do so by extending the UIM-formatted URL functionality. See "Extending UIM-Formatted URL Functionality" for more information.

Table 15-1 Supported Page Names and Corresponding Entity Type

Page Name Entity Type

Business Interaction Summary

BusinessInteraction

Connectivity Details

Connectivity

Device Interface Summary

DeviceInterface

Equipment Summary

Equipment

Inventory Group Summary

InventoryGroup

Logical Device Summary

LogicalDevice

Logical Device Account Summary

LogicalDeviceAccount

Network Summary

Network

Physical Device Summary

PhysicalDevice

Pipe Summary

Pipe

Pipe Configuration Summary

PipeConfiguration

Property Location Details

PropertyLocation

Service Summary

Service

Service Configuration Summary

ServiceConfiguration


About the URL Format

The URL format for invoking the UIM master flow, which is defined by the MasterFlow.xml file, is:

http://server:port/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&id=id&entity=entity

where:

  • server:port is the server and port on which UIM is running

  • id is the id number of the entity you want to access

  • entity is the entity type for the summary page you want to access

For example, the following URL invokes the UIM master flow on myServer:7001, and accesses the Business Interaction Summary page for the business interaction with id 456:

http://myServer:7001/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&id=456&entity=BusinessInteraction

Note:

The UIM Help > Link To Page menu option displays the UIM-formatted URL for the current page, which you can view for additional examples.

About id

The id that you specify in the UIM-formatted URL is the sequentially-generated id attribute that uniquely identifies a UIM entity. This is not to be confused with the persistent pattern-generated entityId attribute.

Note:

For more information about the sequentially-generated id and persistent pattern-generated entityId, see Oracle Communications Information Model Reference.

About entity

The entity that you specify in the UIM-formatted URL is the Java class name, so it must be spelled correctly and have no spaces.

For example, this is a valid URL:

http://jsmith:7001/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&id=102&entity=BusinessInteraction

And this is an invalid URL:

http://jsmith:7001/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&id=102&entity=Business Interaction

About the InventoryGroup Entity

If you specify InventoryGroup as the entity in the UIM-formatted URL, you must replace id with name and provide the inventory group name because for an inventory group, the name is the unique identifier.

For example:

http://jsmith:7001/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&name=MyInvGrpName&entity=InventoryGroup

Using UIM-Formatted URLs

You can use UIM-formatted URLs to access any of the supported UIM pages from an external application. This is done by writing custom code that constructs a UIM-formatted URL, which is then used as the input argument to the following Java method:

javax.faces.context.ExternalContext.redirect(java.lang.String url)

The redirect() method takes in a URL and opens a page based on the input URL. The page is opened in a new browser. To return to the external application that called the redirect() method, close the new browser.

To learn more about this method, see the following website:

http://docs.oracle.com/javaee/7/api/javax/faces/context/ExternalContext.html">>

How you call the custom code depends on the external application and how it supports extending the application through custom code. For example, when extending UIM, custom code is called through the use of rulesets and extension points.

Example 15-1 shows custom code that constructs the UIM-formatted URL and calls the redirect() method.

Example 15-1 Custom Code

// This example code assumes that server, port, id, and entity are either input
// arguments, or readily retrievable/available to the custom code. 
// It also assumes that id is an int, and the rest are Strings.

String url = "http://" + server + ":" + port + "/Inventory/faces/adf.task-flow?adf.tfId=MasterFlow&adf.tfDoc=/WEB-INF/MasterFlow.xml&id=" + Integer.toString(id) + "&entity=" + entity; 

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
externalContext.redirect(url);

Extending UIM-Formatted URL Functionality

If you need to access UIM pages other than those listed in Table 15-1, you must extend the UIM-formatted URL functionality through the following:

MasterFlow.xml

UIM_Home/inventory.ear/inv.war/WEB-INF/MasterFlow.xml defines the master task flow for UIM and is used to invoke specific task flows, such as BusinessInteractionSummaryFlow, EquipmentSummaryFlow, and so forth.

Extending MasterFlow.xml

To extend MasterFlow.xml:

  1. Ensure the <visibility> element defines the <url-invoke-allowed> element. For example:

    <visibility id="__7">
        <url-invoke-allowed/>
    </visibility>
    
  2. Ensure the <data-control-scope> element value is set to isolated. For example:

    <data-control-scope>isolated</data-control-scope>
    

MasterBean.class

The UIM_Home/inventory.ear/inv.war/WEB-INF/classes/oracle/communications/ inventory/ui/common/bean/MasterBean.class logic supports the UIM pages listed in Table 15-1.

MasterBean runs when an ADF standard-formatted URL that invokes the UIM MasterFlow is entered in a browser. MasterBean uses the input ADF standard-formatted URL to construct the UIM-formatted URL by doing the following:

  • Defines a static Map that houses taskflow data

  • Defines an init() method that:

    • Extracts the entity type and entity id from the ADF standard-formatted URL

    • Uses the entity type to get the entity taskflowMap and load it into the static Map that houses the taskflow data

    • Uses the entity id to get the entity and stores some of the entity data in local variables

    • Calls the MasterBean.getCurrentUrl() method, passing in various taskflow data and entity data to construct and return the UIM-formatted URL

    • Calls the javax.faces.context.ExternalContext.redirect() method, passing in the UIM-formatted URL to access the page

  • Defines the getCurrentUrl() method, which takes in various taskflow data and entity data and uses it to construct and return the UIM-formatted URL

Extending MasterBean

If you need to access UIM pages other than those listed in Table 15-1, you must extend MasterBean to handle any additional taskflow data or entity data that may be needed to access other UIM pages, construct the UIM-formatted URL accordingly using the additional data, and call the redirect() method with the customized UIM-formatted URL.

To extend MasterBean:

  1. View the UIM-formatted URL for the page you want to access to determine what data the custom URL requires:

    1. Log in to UIM.

    2. Navigate to the UIM page you want to access from the external application.

    3. Click Help > Link To to display the UIM-formatted URL.

    4. Study the UIM-formatted URL to determine what data it uses.

  2. Create a new custom Java class that extends oracle.communications.inventory.ui.common.bean.MasterBean.

  3. Define a static Map named taskFlowMap to store taskflow-related data.

    For example:

    private static final Map<String, TaskFlowModel> taskFlowMap = 
        new HashMap<String, TaskFlowModel>();
    
  4. In a static block, define the taskflow for the UIM page you need to access.

    For example, the existing MasterBean logic defines the taskflows for all of the UIM pages listed in Table 15-1, of which Business Interaction is shown here:

    static {
    TaskFlowModel taskFlowModelObj = 
        new TaskFlowModel(BusinessInteraction.class, 
            InventoryUIBundleManager.getLabel("BUSINESS_INTERACTION_SUMMARY"));
    
    taskFlowModelObj.setTaskFlowId("/WEB-INF/oracle/communications/inventory/ui/businessinteraction/flow/BusinessInteractionSummaryFlow.xml#BusinessInteractionSummaryFlow");
    
    taskFlowMap.put("BusinessInteraction", taskFlowModelObj);
    }
    
  5. Define an init() method that does the following:

    Note:

    These steps assume your custom code knows the entity type you want to access, and has the id of the entity you want to access.
    1. Use the entity type to get the entity taskflowMap from the static Map that is defined and loaded when the class is created. For example:

      taskFlowModelObj = taskFlowMap.get(entity);
      
    2. Use the entity id to get the entity. For example:

      finder = PersistenceHelper.makeFinder();
      Collection result = null;
      result = finder.findById(taskFlowModelObj.getEntityClass(),id); 
      
    3. Depending on what you determined in step 1, create local variables and populate them with the retrieved taskflow data and retrieved entity data.

      The variables you create depend on the data required for the UIM-formatted URL for the page you want to access. These variables will be used as method input parameters in the next step.

    4. Call your custom getURL() method (as described in step 6, below).

      Pass in the appropriate taskflow data and entity data to construct and return the UIM-formatted URL. For example, the following shows a call to the getURL() method using local variables of taskFlowId, taskKeyList, taskParameterList, taskLabel, and taskType:

      String url = getURL(taskFlowId,taskKeyList,taskParametersList,
                          taskLabel,taskType);
      
    5. Call the javax.faces.context.ExternalContext.redirect() method, passing in the UIM-formatted URL to access the page. For example:

      FacesContext facesContext = FacesContext.getCurrentInstance();
      ExternalContext externalContext = facesContext.getExternalContext();
      externalContext.redirect(url);
      
  6. Define a custom getURL() method that:

    1. Defines input arguments that reflect the taskflow-related data and entity data needed to construct the custom UIM-formatted URL.

    2. Constructs the custom UIM-formatted URL using the input argument data.

      See "About the URL Format" for detailed information on the URL format.

    3. Returns a String that is the custom UIM-formatted URL.

    Example 15-2 shows the MasterBean.getCurrentURL() method, which you can use in writing a similar custom getURL() method.

    Example 15-2 MasterBean.getCurrentURL()

    public String getCurrentURL(String navTaskFlowId, String navTaskKeyList, 
                                String navTaskParametersList, String navTaskLabel,
                                String navTaskType) throws Exception 
    {
        try {
            String homePageWebApp = null;
            String homePageViewId = null;
            boolean contextualAreaCollapsed = 
                PatternsConstants.DEFAULT_CONTEXTUAL_AREA_COLLAPSED;
            int contextualAreaWidth = 
                PatternsConstants.DEFAULT_CONTEXTUAL_AREA_WIDTH;
            StringBuffer url = null;
            FacesContext facesContext = FacesContext.getCurrentInstance();
            String urlStr = null;
            urlStr = ControllerContext.getInstance().getGlobalViewActivityURL
                     ("/InventoryUIShell");
     
            int qIndex = urlStr.indexOf('?');
            if (qIndex > -1) {
                urlStr = urlStr.substring(0, qIndex);
            }
     
            url = new StringBuffer(urlStr);
            if (urlStr.indexOf('?') > -1) {
                url.append('&');
            } else {
                url.append('?');
            }
            url.append(MainAreaHandler.FND).append('=');
        
            StringBuffer fndBuffer = new StringBuffer();
            if (navTaskFlowId != null) {
                fndBuffer.append
                    (URLEncoder.encode(navTaskFlowId, MainAreaHandler.UTF_8));
            }
            fndBuffer.append(';');
            if (navTaskParametersList != null) {
                fndBuffer.append
                    (URLEncoder.encode(navTaskParametersList, MainAreaHandler.UTF_8));
            }
            fndBuffer.append(';');
            if (navTaskKeyList != null) {
                fndBuffer.append
                    (URLEncoder.encode(navTaskKeyList, MainAreaHandler.UTF_8));
            }
            fndBuffer.append(';');
            if (navTaskLabel != null) {
                fndBuffer.append
                    (URLEncoder.encode(navTaskLabel, MainAreaHandler.UTF_8));
            }
            fndBuffer.append(';');
            if (navTaskType != null) {
              fndBuffer.append
                  (URLEncoder.encode(navTaskType, MainAreaHandler.UTF_8));
            }
            fndBuffer.append(';');
            fndBuffer.append
                (URLEncoder.encode(String.valueOf(contextualAreaCollapsed),
                 MainAreaHandler.UTF_8));
            fndBuffer.append(';');
            fndBuffer.append
                (URLEncoder.encode(String.valueOf(contextualAreaWidth),
                 MainAreaHandler.UTF_8));
            url.append
                (URLEncoder.encode(fndBuffer.toString(), MainAreaHandler.UTF_8));
        
            // Get from the model when navigating from the Home Page
            Map<String, Object> viewScopeMap =
                AdfFacesContext.getCurrentInstance().getViewScope();
            DistributedMenuModel homepageMenuModel = 
                (DistributedMenuModel)viewScopeMap.get
                    (PatternsConstants.HOMEPAGE_MENU_MODEL);
            if (homepageMenuModel == null) {
                homepageMenuModel = 
                   (DistributedMenuModel)PatternsUtil.getCurrentDistributedMenuModel
                       (PatternsConstants.HOMEPAGE_MENU_MODEL);
            }
            if (homepageMenuModel != null) {
                ItemNode focusItemNode =
                    PatternsUtil.getFocusItemNode(homepageMenuModel);
                if (focusItemNode != null) {
                    homePageViewId = focusItemNode.getFocusViewId();
                    Map<String, String> customPropList =
                        focusItemNode.getCustomPropList();
                    if (customPropList != null) {
                        homePageWebApp = 
                            customPropList.get(PatternsConstants.WEBAPP_NAME);
                    }
                }
            }
            // Model may not be available when avigating in between Apps pages
            if (homePageViewId == null && homePageViewId == null) {
                homePageWebApp = 
                   (String)viewScopeMap.get(PatternsConstants.WEBAPP_NAME);
                homePageViewId = 
                   (String)viewScopeMap.get(PatternsConstants.HOMEPAGE_VIEW_ID);
            }
            if (homePageViewId != null && homePageWebApp != null) {
                url.append("&").append(PatternsConstants.WEBAPP_NAME).append
                ("=").append(homePageWebApp).append
                ("&").append(PatternsConstants.HOMEPAGE_VIEW_ID).append("=").append
                (URLEncoder.encode(homePageViewId, MainAreaHandler.UTF_8));
            }
            ControllerContext.getInstance().markScopeDirty(viewScopeMap);
            HttpServletRequest request =
               (HttpServletRequest)facesContext.getExternalContext().getRequest();
            String hostnamePort = request.getScheme() + "://" + 
                request.getServerName() + ":" + request.getServerPort();
            String fullUrl = hostnamePort + url.toString();
            return fullUrl;
        }
        finally {
        }
    }
    

TaskFlowModel.class

UIM_Home/inventory.ear/inv.war/WEB-INF/classes/oracle/communications/ inventory/ui/common/model/TaskFlowModel.class holds taskflow-related data. Specifically, TaskFlowModel defines the entityClass, displayLabel, and taskFlowId class variables, and defines get() and set() methods for each.

When MasterBean is created, an instance of TaskFlowModel is created for each of the supported UIM pages listed in Table 15-1. The code example in step 4 of the "Extending MasterBean" shows this.

Extending TaskFlowModel

The TaskFlowModel logic supports the UIM pages listed in Table 15-1. If you need to access UIM pages other than those listed in Table 15-1, you may need to extend the TaskFlowModel logic to hold any additional taskflow-related data needed to access other UIM pages.

Note:

You only need to extend TaskFlowModel if additional data is needed to construct the custom UIM-formatted URL, as determined in step 1 of the "Extending MasterBean" section.

To extend TaskFlowModel:

  1. Create a new custom Java class that extends oracle.communications.inventory.ui.common.model.TaskFlowModel.

  2. Define additional class variables as needed.

  3. For each class variable, define the corresponding get() and set() methods.