for ( Iterator iter = diagnosesWrapperSubscription.getAddedCollection().iterator(); iter.hasNext() ; ) { DiagnosesWrapper dw = (DiagnosesWrapper)iter.next(); Diagnosis d = (Diagnosis) dw.getContent();  findDiagnosisCollection(d.getAssetID()); findActionCollection(d.getAssetID()); findCostBenefitEvaluation(d.getAssetID()); }
  public void execute() {        for ( Iterator iter = diagnosesWrapperSubscription.getAddedCollection().iterator();            iter.hasNext() ; )         {            DiagnosesWrapper dw = (DiagnosesWrapper)iter.next();            Diagnosis d = (Diagnosis) dw.getContent();            //indexDiagnosis(dw, key);            findDiagnosisCollection(d.getAssetID());            findActionCollection(d.getAssetID());            findCostBenefitEvaluation(d.getAssetID());        }               Iterator iter;            // Get the ActionSelectionKnob for current settings        iter = knobSubscription.iterator();        if (iter.hasNext())         {                    knob = (ActionSelectionKnob) iter.next();        }      /*            if (testServlet == null) {          iter = testServletSubscription.getAddedCollection().iterator();          if (iter.hasNext()) {              testServlet = (TestObservationServlet)iter.next();               if (logger.isDebugEnabled()) logger.debug("Found TestObservationServlet");           }      }*/            //********* Process new CostBenefit objects ************          iter = costBenefitSubscription.getAddedCollection().iterator();      while (iter.hasNext()) {          CostBenefitEvaluation cbe = (CostBenefitEvaluation)iter.next();           if (logger.isDebugEnabled()) logger.debug("Saw new CBD: \n"+cbe.toString());/*          if (testServlet != null) {               if (logger.isDebugEnabled()) logger.debug("Adding CBD to observation servlet");              testServlet.addCostBenefitDiagnosis(cbd);               testServlet.updateCostBenefitStatus(cbd,"RUNNING");          }*/          selectActions(cbe, knob);/*          if (testServlet != null) {               if (!running) testServlet.updateCostBenefitStatus(cbd,"NOTHING TO DO");          }*/      }      //********* Process Actions that have Timed Out ***********      if (logger.isDebugEnabled()) logger.debug("Ready to Process Timeouts");      iter = failedActionSubscription.getAddedCollection().iterator();      // Mark the resolution of all the Actions that just reported back (for now it will just be one Action)      while (iter.hasNext()) {          FailedActionWrapper faw = (FailedActionWrapper)iter.next();          publishRemove(faw);    // we have the info we want, so get rid of it           Action action = faw.getAction();          // get the CBE associated with the failed Action          CostBenefitEvaluation cbe = findCostBenefitEvaluation(action.getAssetID());          if (logger.isDebugEnabled()) logger.debug(action + " has timed out w/o succeeding");          Object variantAttempted = action.getValue().getAction();          VariantEvaluation variantAttemptedEvaluation = cbe.getActionEvaluation(action).getVariantEvaluation(variantAttempted);          variantAttemptedEvaluation.setTried();          selectActions(cbe, knob);  // try to find a new action      }/*                    //mark what the defense did & DISABLE it          CostBenefitDiagnosis.ActionBenefit[] dbArray = cbe.getActions();          CostBenefitDiagnosis.ActionBenefit actionBenefit;                 for (int i=0; i<dbArray.length; i++) {             actionBenefit = dbArray[i];             if (actionBenefit.getAction() != null && actionBenefit.getAction().getName().equalsIgnoreCase(actionName)) {                 actionBenefit.setOutcome(outcome);                 DefenseApplicabilityConditionSnapshot dacs = def.getCondition();                 dacs.setCompletionTime(dc.getCompletionTime());                 setAction(dacs, DEF_DISABLED, MON_DISABLED, 0L, null);                             if (testServlet != null) { testServlet.updateDefenseStatus(cbd,def.getDefense().getName(),"DISABLED"); }             } // re-enable MsgLog so messages about the next Defense (if any) can be delivered             if (def.getDefense() != null && def.getDefense().getName().equalsIgnoreCase("MsgLog")) {                 DefenseApplicabilityConditionSnapshot dacs = def.getCondition();                 if (dacs != null) {                     setAction(dacs, DEF_ENABLED, MON_ENABLED, 0L, null); // check that MsgLog actually exists                        if (testServlet != null) { testServlet.updateDefenseStatus(cbd,def.getDefense().getName(),"ENABLED"); }                 }             }                    }/*          // fixed the problem, so announce the result, clean up & exit          if (logger.isDebugEnabled()) logger.debug("***** "+outcome+" *****");          if (outcome.equals("SUCCEEDED")) {   // whatever we just tried worked (at least its own defense thinks it did)              if (logger.isDebugEnabled()) logger.debug("Processing Success");              String resolution = "COMPLETED - PROBLEM SOLVED";              TimedDefenseDiagnosis tdd = TimedDefenseDiagnosis.find(cbd.getAssetName(), blackboard);              if (tdd != null) {                  tdd.setDisposition(resolution, System.currentTimeMillis());                  publishChange(tdd); // let the TDD Plugin remove it              }              publishRemove(cbd);  // no longer need this since the problem is solved              if (testServlet != null) testServlet.updateCostBenefitStatus(cbd, resolution);           }          else { // the last thing we tried failed              // see if there is another defense to try & if so, try it              boolean stillTrying = handleAsset(cbd);              // no more defenses              if (!stillTrying) {                  String resolution = "COMPLETED - NO MORE DEFENSES TO TRY";                  TimedDefenseDiagnosis tdd = TimedDefenseDiagnosis.find(cbd.getAssetName(), blackboard);                  if (tdd != null) {                      tdd.setDisposition(resolution, System.currentTimeMillis());                      publishChange(tdd); // let the TDD Plugin remove it                  }                  publishRemove(cbd);  // no longer need this since the problem can't be solved                  if (testServlet != null) testServlet.updateCostBenefitStatus(cbd, resolution);              }          }*/      if (logger.isDebugEnabled()) logger.debug("Done processing TimeOuts");  }