mil.dod.th.ose.gui.webapp/src/mil/dod/th/ose/gui/webapp/comms/CommsLayerTypesMgrImpl.java
private synchronized void eventGetCommsTypesResponseData(final GetAvailableCommTypesResponseData message, 
            final int systemId)
    {
        final List<String> newTypesList = new ArrayList<String>(message.getProductTypeList());
        final CommType type = message.getCommType();
        
        List<String> oldComms = null;
        if (type.equals(CommType.TransportLayer))
        {
            oldComms = m_TransportTypes.get(systemId);
        }
        else if (type.equals(CommType.Linklayer))
        {
            oldComms = m_LinkTypes.get(systemId);
        }
        else if (type.equals(CommType.PhysicalLink))
        {
            oldComms = m_PhysicalTypes.get(systemId);
        }
        else
        {
            m_GrowlMessageUtil.createGlobalFacesMessage(FacesMessage.SEVERITY_WARN, "Unknown Layer Type", //NOCHECKSTYLE
                   String.format("Received information about %s, this type is not a known comms layer type", //multiple
                           type)); //string literals : used for consistency.
        }
        
        //used to maintain list of existing types
        final List<String> updatedList = new ArrayList<String>();
        
        if (oldComms != null)
        {
            for (String oldComm : oldComms)
            {
                //if item is in new list remove from new list
                if (newTypesList.contains(oldComm))
                {
                    newTypesList.remove(oldComm); //remove already known type from list of new types
                    updatedList.add(oldComm);
                }
                else //if type no longer exists 
                {
                    //remove the capabilties object corresponding to obsolete type
                    final Map<String, Object> capabilities = m_Capabilities.get(systemId);
                    capabilities.remove(oldComm);
                }
            }
        }
        
        //used to ensure that capabilities requests are only sent if type is new
        for (String newComms : newTypesList)
        {
            updatedList.add(newComms);
            final GetCapabilitiesRequestData requestMessage = GetCapabilitiesRequestData.newBuilder().setCommType(type).
                    setProductType(newComms).build();
            
            final CapabilitiesResponseHandler handler = new CapabilitiesResponseHandler(newComms);
            
            m_MessageFactory.createCustomCommsMessage(CustomCommsMessageType.GetCapabilitiesRequest,
                    requestMessage).queue(systemId, handler);
        }
        
        if (type.equals(CommType.TransportLayer))
        {
            m_TransportTypes.put(systemId, updatedList);
        }
        else if (type.equals(CommType.Linklayer))
        {
            m_LinkTypes.put(systemId, updatedList);
        }
        else if (type.equals(CommType.PhysicalLink))
        {
            m_PhysicalTypes.put(systemId, updatedList);
        }
        
        Logging.log(LogService.LOG_DEBUG, "Added comms types %s of type %s", updatedList.toString(), type.toString());
                
        //post notice
        m_GrowlMessageUtil.createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Layer Types Updated", 
                String.format("Controller 0x%08x updated the list of available %ss", systemId, type.toString()));       
    }
/**
     * Method for handling GetAvailableCommTypes request.  
     * @param message
     *      Message containing the necessary data.
     * @param systemId
     *      ID of the controller from which the response originated
     */
Method for handling GetAvailableCommTypes request.
@param message
Message containing the necessary data.
@param systemId
ID of the controller from which the response originated
Method for handling GetAvailableCommTypes request . @param message Message containing the necessary data . @param systemId ID of the controller from which the response originated
private synchronized void eventGetCommsTypesResponseData(final GetAvailableCommTypesResponseData message, 
            final int systemId)
    {
        final List<String> newTypesList = new ArrayList<String>(message.getProductTypeList());
        final CommType type = message.getCommType();
        List<String> oldComms = null;
        if (type.equals(CommType.TransportLayer))
        {
            oldComms = m_TransportTypes.get(systemId);
        }
        else if (type.equals(CommType.Linklayer))
        {
            oldComms = m_LinkTypes.get(systemId);
        }
        else if (type.equals(CommType.PhysicalLink))
        {
            oldComms = m_PhysicalTypes.get(systemId);
        }
        else
        {
            m_GrowlMessageUtil.createGlobalFacesMessage(FacesMessage.SEVERITY_WARN, "Unknown Layer Type", 
                   String.format("Received information about %s, this type is not a known comms layer type", 
                           type)); 
        }
        final List<String> updatedList = new ArrayList<String>();
        if (oldComms != null)
        {
            for (String oldComm : oldComms)
            {
                if (newTypesList.contains(oldComm))
                {
                    newTypesList.remove(oldComm); 
                    updatedList.add(oldComm);
                }
                else 
                {
                    final Map<String, Object> capabilities = m_Capabilities.get(systemId);
                    capabilities.remove(oldComm);
                }
            }
        }
        for (String newComms : newTypesList)
        {
            updatedList.add(newComms);
            final GetCapabilitiesRequestData requestMessage = GetCapabilitiesRequestData.newBuilder().setCommType(type).
                    setProductType(newComms).build();
            final CapabilitiesResponseHandler handler = new CapabilitiesResponseHandler(newComms);
            m_MessageFactory.createCustomCommsMessage(CustomCommsMessageType.GetCapabilitiesRequest,
                    requestMessage).queue(systemId, handler);
        }
        if (type.equals(CommType.TransportLayer))
        {
            m_TransportTypes.put(systemId, updatedList);
        }
        else if (type.equals(CommType.Linklayer))
        {
            m_LinkTypes.put(systemId, updatedList);
        }
        else if (type.equals(CommType.PhysicalLink))
        {
            m_PhysicalTypes.put(systemId, updatedList);
        }
        Logging.log(LogService.LOG_DEBUG, "Added comms types %s of type %s", updatedList.toString(), type.toString());
        m_GrowlMessageUtil.createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Layer Types Updated", 
                String.format("Controller 0x%08x updated the list of available %ss", systemId, type.toString()));       
    }
private synchronized void eventGetCommsTypesResponseData ( final GetAvailableCommTypesResponseData message , final int systemId ) { final List < String > newTypesList = new ArrayList < String > ( message . getProductTypeList ( ) ) ; final CommType type = message . getCommType ( ) ; List < String > oldComms = null ; if ( type . equals ( CommType . TransportLayer ) ) { oldComms = m_TransportTypes . get ( systemId ) ; } else if ( type . equals ( CommType . Linklayer ) ) { oldComms = m_LinkTypes . get ( systemId ) ; } else if ( type . equals ( CommType . PhysicalLink ) ) { oldComms = m_PhysicalTypes . get ( systemId ) ; } else { m_GrowlMessageUtil . createGlobalFacesMessage ( FacesMessage . SEVERITY_WARN , "Unknown Layer Type" , String . format ( "Received information about %s, this type is not a known comms layer type" , type ) ) ; } final List < String > updatedList = new ArrayList < String > ( ) ; if ( oldComms != null ) { for ( String oldComm : oldComms ) { if ( newTypesList . contains ( oldComm ) ) { newTypesList . remove ( oldComm ) ; updatedList . add ( oldComm ) ; } else { final Map < String , Object > capabilities = m_Capabilities . get ( systemId ) ; capabilities . remove ( oldComm ) ; } } } for ( String newComms : newTypesList ) { updatedList . add ( newComms ) ; final GetCapabilitiesRequestData requestMessage = GetCapabilitiesRequestData . newBuilder ( ) . setCommType ( type ) . setProductType ( newComms ) . build ( ) ; final CapabilitiesResponseHandler handler = new CapabilitiesResponseHandler ( newComms ) ; m_MessageFactory . createCustomCommsMessage ( CustomCommsMessageType . GetCapabilitiesRequest , requestMessage ) . queue ( systemId , handler ) ; } if ( type . equals ( CommType . TransportLayer ) ) { m_TransportTypes . put ( systemId , updatedList ) ; } else if ( type . equals ( CommType . Linklayer ) ) { m_LinkTypes . put ( systemId , updatedList ) ; } else if ( type . equals ( CommType . PhysicalLink ) ) { m_PhysicalTypes . put ( systemId , updatedList ) ; } Logging . log ( LogService . LOG_DEBUG , "Added comms types %s of type %s" , updatedList . toString ( ) , type . toString ( ) ) ; m_GrowlMessageUtil . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , "Layer Types Updated" , String . format ( "Controller 0x%08x updated the list of available %ss" , systemId , type . toString ( ) ) ) ; }
Method for handling GetAvailableCommTypes request.
Method for handling GetAvailableCommTypes request .
//NOCHECKSTYLE //multiple //string literals : used for consistency. //used to maintain list of existing types //if item is in new list remove from new list //remove already known type from list of new types //if type no longer exists  //remove the capabilties object corresponding to obsolete type //used to ensure that capabilities requests are only sent if type is new //post notice