logger.debug("************************>>> Saw DUPLICATE agent asset ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);
if (logger.isDebugEnabled()) logger.debug("************************>>> Saw DUPLICATE agent asset ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);
        public void statusChanged(CommunityStatusChangeEvent[] csce) {                        DefaultAssetTechSpec hostAsset;            DefaultAssetTechSpec nodeAsset;            DefaultAssetTechSpec agentAsset;            String agentName = null;            String nodeName = null;            String hostName = null;                        boolean newAgent;            boolean movingAgent;            boolean removedAsset;                        //Look at the events for new agent assets            for (int i = 0; i < csce.length; i++) {                newAgent = false;                movingAgent = false;                removedAsset = false;//logger.warn("!!!! [STATUS CHANGED CALLED] on asset="+csce[i].getName()+" with:  \n= "+csce[i].toString()+"  getCurrentLocation = " + csce[i].getCurrentLocation()+" getPriorLocation = " + csce[i].getPriorLocation());                /*                logger.warn("!!!! ****************************************************");logger.warn("!!!! [STATUS CHANGED CALLED] asset = "+csce[i].getName());if (csce[i].locationChanged())    logger.warn("!!!! location changed");if (csce[i].membersAdded())    logger.warn("!!!! membersAdded");if (csce[i].leaderChanged())    logger.warn("!!!! leaderChanged");if (csce[i].membersRemoved())    logger.warn("!!!! membersRemoved");if (csce[i].stateChanged())    logger.warn("!!!! stateChanged");if (csce[i].stateExpired())    logger.warn("!!!! stateExpired");logger.warn("!!!! getCurrentLocation = " + csce[i].getCurrentLocation());logger.warn("!!!! getPriorLocation = " + csce[i].getPriorLocation());logger.warn("!!!! **********************************************************");*/                // Is this a new agent?                 if ( (csce[i].membersAdded() && csce[i].getCurrentLocation() != null) ||                    (csce[i].locationChanged() && csce[i].getPriorLocation() == null) )  {                                            newAgent = true;                                        } else if (csce[i].locationChanged() && csce[i].getPriorLocation() != null) {                                        movingAgent = true;                } else if (csce[i].membersRemoved()) {                                        removedAsset = true;                }                                agentName = csce[i].getName();                //***********************************************************************                //******** Ignore if not a new agent or moving agent -- for NOW *********                //***********************************************************************                //Later could monitor other changes in an agent / node.                if ( newAgent || movingAgent ) {                                                            if ( csce[i].getType() == CommunityStatusModel.AGENT ) {                        nodeName = csce[i].getCurrentLocation();                        hostName = csm.getLocation(nodeName);                    }                    else if ( csce[i].getType() == CommunityStatusModel.NODE ) { //node & node agent have the same name                        nodeName = agentName;                        hostName = csce[i].getCurrentLocation();                    }                                        if (hostName == null || nodeName == null || hostName.length() == 0 || nodeName.length() == 0) {                      //  logger.warn("!!!- [ASSET NOT ADDED] Saw new agent asset ["+agentName+"] without host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                        continue;                    } else { //continue                        hostAsset = getHost(hostName);                        nodeAsset = getNode(hostAsset, nodeName);                    }                                        //*** Handle a new agent                    if ( newAgent )  {                        //Make sure we haven't seen this agent before we create a new one!                        agentAsset = DefaultAssetTechSpec.findAssetByID(new AssetID(agentName, AssetType.AGENT));                        if (agentAsset != null) {                            logger.debug("************************>>> Saw DUPLICATE agent asset ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                            continue;                        }                                                                                            logger.debug("============>>> Saw new agent asset ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                        agentAsset = new DefaultAssetTechSpec( hostAsset, nodeAsset,  agentName, AssetType.AGENT, us.nextUID());                        //Use NODE name to assign FWD / REAR property -- doing this also for nodes in getNode()                        if (nodeName.startsWith("REAR")) {                            agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "REAR"));                        } else if (nodeName.startsWith("FWD")) {                            agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "FORWARD"));                        }                                                queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.NEW_ASSET));                                                //*** Handle an agent moving                    } else if (movingAgent) { //it's a movingAgent                                                logger.info("Agent location changed: agent=" + agentName +                        " priorLocation=" + csce[i].getPriorLocation() +                        " newLocation=" + csce[i].getCurrentLocation());                                                agentAsset = DefaultAssetTechSpec.findAssetByID(new AssetID(agentName, AssetType.AGENT));                        agentAsset.setNewLocation(hostAsset, nodeAsset);                        queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.MOVED_ASSET));                        //Use NODE name to assign FWD / REAR property                        if (nodeName.startsWith("REAR")) {                            agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "REAR"));                        } else if (nodeName.startsWith("FWD")) {                            agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "FWD"));                        }                        //*** Handle an agent that has been removed                    }                                     } else if (removedAsset) { //it's a removedAsset                                                //if it's a node agent, remove the node asset.                        if (csce[i].getType() == CommunityStatusModel.AGENT) {                            logger.info("Agent REMOVED: agent=" + agentName);                                                    agentAsset = DefaultAssetTechSpec.findAssetByID(new AssetID(agentName, AssetType.AGENT));                            queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.REMOVED_ASSET));                                                                        } else if (csce[i].getType() == CommunityStatusModel.NODE) {                            logger.info("NODE REMOVED: node=" + agentName);                                                    nodeAsset = DefaultAssetTechSpec.findAssetByID(new AssetID(agentName, AssetType.NODE));                            queueChangeEvent(new AssetChangeEvent( nodeAsset, AssetChangeEvent.REMOVED_ASSET));                                                                        }                                                //REMOVE the node asset too???                        //if (csce[i].getType() == CommunityStatusModel.NODE) { }                                        } else {                   // logger.debug("!!!! [STATUS CHANGED CALLED] - UNKNOWN change");                }            }        }