if (allPermittedSoFar) propagatePermissions(rr);
if (allPermittedSoFar) { propagatePermissions(rr); iter.remove(); rr.getAlarm().cancel(); if (logger.isDebugEnabled()) logger.debug("Removing RequestedAlarm for: " + rr.getNodeID()); }
    public void execute() {            if (logger.isDebugEnabled()) logger.debug("Entering ** execute() **");        if (logger.isDetailEnabled()) logger.detail("RTC's: " + reconnectTimeConditionSubscription.toString());        if (logger.isDebugEnabled()) logger.debug("Added RTC's: " + reconnectTimeConditionSubscription.getAddedCollection().toString());        if (logger.isDebugEnabled()) logger.debug("Changed RTC's: " + reconnectTimeConditionSubscription.getChangedCollection().toString());        if (logger.isDetailEnabled()) logger.detail("OpModes's: " + blackboard.query(DisconnectDefenseAgentEnabler.pred).toString());               Iterator iter;        if (rehydrating) {            Collection c = blackboard.query(NodeStatus.pred);            iter = c.iterator();            if (iter.hasNext()) {                nodeStatus = (NodeStatus)iter.next();                if (logger.isDebugEnabled()) logger.debug(nodeStatus.toString());                Iterator iter2 = nodeStatus.values().iterator();                while (iter2.hasNext()) {                   // create the Action(s) & Diagnosis(s) for the Node & its agents                   NodeStatusRecord nsr = (NodeStatusRecord)iter2.next();                   RequestToDisconnectNodeDiagnosis diag = createNodeDiagnosisAndAction(nsr.getNodeID(), nsr.getDiagnosis());                   if (nsr.getDiagnosis().equals(DISCONNECTED))                         createOverdueAlarm(diag, nsr.getAgents(), (nsr.getReconnectTime()-System.currentTimeMillis() < 120000) ? 120000 :  (nsr.getReconnectTime()-System.currentTimeMillis())); // give the node at least 2 minutes from now due to the move                   Iterator iter3 = nsr.getAgents().iterator();                   while (iter3.hasNext()) {                       createAgentDiagnosisAndAction((AssetID)iter3.next(), nsr.getDiagnosis());                   }                   // create an OverdueAlarm if the Node is Disconnected                }                rehydrating = false;            }        }        // Handle timed-out requests & deny permission          if (somethingRequestedExpired) {            iter = expiredRequestedAlarms.iterator();            while(iter.hasNext()) {                RequestedAlarm thisAlarm = (RequestedAlarm)iter.next();                if (thisAlarm.hasExpired()) {                    thisAlarm.handleExpiration();                }            }        expiredRequestedAlarms.clear();        somethingRequestedExpired = false;        }                // Handle expired Alarms for overdue nodes        if (somethingOverdueExpired) {            iter = expiredOverdueAlarms.iterator();            while(iter.hasNext()) {                OverdueAlarm thisAlarm = (OverdueAlarm)iter.next();                if (thisAlarm.hasExpired()) {                    thisAlarm.handleExpiration();                }            }        expiredOverdueAlarms.clear();        somethingOverdueExpired = false;        }                if (managerAddress != null) {// already know the ManagerAgent, so create Diagnoes & Actions for newly announced Nodes & Agents            if (logger.isDebugEnabled()) logger.debug("Know MA, so create Diagnosis & Action for newly announce Nodes & Agents");            iter = reconnectTimeConditionSubscription.getAddedCollection().iterator();            while (iter.hasNext()) {                ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();                createDiagnosisAndAction(new AssetID(rtc.getAsset(), AssetType.findAssetType(rtc.getAssetType())));            }        }                Iterator i = managerAddressSubscription.getAddedCollection().iterator();        if (i.hasNext()) { // just found the ManagerAgentAddress            managerAddress = ((RobustnessManagerID)i.next()).getMessageAddress();            if (logger.isDebugEnabled()) logger.debug("ManagerAddress: "+managerAddress.toString());            // so create conditions & opmodes for everything we've seen so far but not created            iter = reconnectTimeConditionSubscription.iterator();            while (iter.hasNext()) {                ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();                createDiagnosisAndAction(new AssetID(rtc.getAsset(), AssetType.findAssetType(rtc.getAssetType())));            }                    }                iter = reconnectTimeConditionSubscription.getChangedCollection().iterator();        while (iter.hasNext()) {            ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();            if (rtc != null) {                double encodedTime = ((Double)rtc.getValue()).doubleValue();                if (logger.isDebugEnabled()) logger.debug("Changed "+rtc.toString());                handleNodeRequest(rtc);            }        }        boolean anActionHasChangedPermittedValues = false;        iter = ActionSubscription.getChangedCollection().iterator();        while (iter.hasNext()) {            DisconnectAction action = (DisconnectAction)iter.next();            if (logger.isDebugEnabled()) logger.debug("Saw Changed: " + action.dump());            Set newPV = action.getNewPermittedValues();            if (newPV != null) {                if (logger.isDebugEnabled()) logger.debug("NPV: " + newPV.toString());                if (logger.isDebugEnabled()) logger.debug("Permitted change to: " + action.dump());                try {                    anActionHasChangedPermittedValues = true;                    action.setPermittedValues(newPV);                    action.clearNewPermittedValues();                } catch (IllegalValueException e)  {                logger.error("Attempt to set: "+action.dump()+" with illegal value "+e.toString());                return;                }             }         }        if (anActionHasChangedPermittedValues) {            iter = pendingRequests.values().iterator();            while (iter.hasNext()) {                RequestRecord rr = (RequestRecord)iter.next();                Iterator iter2 = rr.getOriginalActions().iterator();                boolean allPermittedSoFar = true;                while (iter2.hasNext()) {                    Action thisAction = (Action)iter2.next();                    if ((thisAction.getPermittedValues() != null ) && (thisAction.getPermittedValues().contains(rr.getRequest()))) {                        if (logger.isDebugEnabled()) logger.debug(rr.getRequest() + " of: " + thisAction.getAssetID().toString() + " is permitted");                    }                    else {                        if (logger.isDebugEnabled()) logger.debug(rr.getRequest() + " of: " + thisAction.getAssetID().toString() + " is NOT permitted");                        allPermittedSoFar = false;                    }                                            }                if (allPermittedSoFar) propagatePermissions(rr);            }                            }            }