roleSchedule.getOverlappingRoleSchedule(startDate, endDate);
roleSchedule.getOverlappingRoleSchedule(startDate.getTime(), endDate.getTime());
  private void modifyAsset(String modifyArgs,                            ParsePosition parsePosition,                           PrintStream out,                           PlanServiceContext psc,                           PlanServiceUtilities psu) throws RuntimePSPException {        String uidStr =       AssetPerturbationMessage.parseParameter(modifyArgs,                                               AssetPerturbationMessage.UID_LABEL,                                               AssetPerturbationMessage.DELIM,                                               parsePosition);    if (uidStr.equals("")) {      throw new RuntimePSPException("No UID for alert.");    }    myModifyUID = new UID(uidStr);          if (debug)        System.out.println ("myModifyUID is " + myModifyUID);    String startStr =       AssetPerturbationMessage.parseParameter(modifyArgs,                                               AssetPerturbationMessage.START_LABEL,                                               AssetPerturbationMessage.DELIM,                                              parsePosition);    if (startStr.equals("")) {      throw new RuntimePSPException("No start date.");    }    Date startDate = null;    try {      startDate = AssetPerturbationMessage.getDateFormat().parse(startStr);    } catch (ParseException pe) {      throw new RuntimePSPException("Unable to parse start date = " + startStr);    }    String endStr =       AssetPerturbationMessage.parseParameter(modifyArgs,                                               AssetPerturbationMessage.END_LABEL,                                               AssetPerturbationMessage.DELIM,                                               parsePosition);    if (endStr.equals("")) {      throw new RuntimePSPException("No end date.");    }    Date endDate = null;    try {      endDate = AssetPerturbationMessage.getDateFormat().parse(endStr);    } catch (ParseException pe) {      throw new RuntimePSPException("Unable to parse end date = " + endStr);    }    ServerPlugInSupport serverPluginSupport = psc.getServerPlugInSupport();    Subscription subscription =       serverPluginSupport.subscribe(this, assetByUIDPred);    Collection container =       ((CollectionSubscription)subscription).getCollection();        if (container.size() == 0) {      System.out.println("PSP_AssetPerturbation.execute(): query by UID " +                          myModifyUID +                          " returned no assets.");      throw new RuntimePSPException("UID " + myModifyUID +                                     " does not exist.");    } else if (container.size() > 1) {               System.out.println("PSP_AssetPerturbation.execute(): query by UID " +                          myModifyUID +                          " returned multiple alerts.");      throw new RuntimePSPException("UID " + myModifyUID + " not unique.");    }                  Enumeration assetsByUID  = new Enumerator(container);    Asset asset = (Asset)assetsByUID.nextElement();    RoleSchedule roleSchedule = asset.getRoleSchedule();    Collection overlapSchedule =       roleSchedule.getOverlappingRoleSchedule(startDate, endDate);    if (!overlapSchedule.isEmpty()) {      Enumeration planElements = new Enumerator(overlapSchedule);      if (debug) {        System.out.println("PSP_AssetPerturbation - removing plan elements involving "  + asset);      }      Vector stuffToRemove = new Vector ();      Vector originalTasks = new Vector ();      publishRemoveUntilBoundary(psc, planElements, stuffToRemove,                                  originalTasks);      for (int i = 0; i < stuffToRemove.size (); i++) {          serverPluginSupport.publishRemoveForSubscriber(stuffToRemove.elementAt(i));      }      for (int i = 0; i < originalTasks.size (); i++) {          NewTask oTask = (NewTask)originalTasks.elementAt(i);          if (debug && (oTask.getWorkflow () != null)) {            System.out.println ("original task " + oTask + " had non-null workflow");          }          oTask.setWorkflow (null);          serverPluginSupport.publishChangeForSubscriber(oTask);      }    }    RootFactory ldmFactory =       serverPluginSupport.getFactoryForPSP();        NewTask newTask = createUnavailableTask(asset, startDate, endDate,                                             ldmFactory);    ClusterIdentifier clusterID =       ClusterIdentifier.getClusterIdentifier(serverPluginSupport.getClusterIDAsString());    newTask.setSource(clusterID);    newTask.setDestination(clusterID);    serverPluginSupport.publishAddForSubscriber(newTask);    AllocationResult allocationResult =       createEstimatedAllocationResult(newTask, ldmFactory);    Allocation allocation =       ldmFactory.createAllocation(ldmFactory.getRealityPlan(),                                  newTask,                                  asset,                                  allocationResult,                                  Constants.Role.OUTOFSERVICE);    serverPluginSupport.publishAddForSubscriber(allocation);    if (debug) {      System.out.println("\nSchedule immediately after publish.\n" +                          "Should be unavailable from " + startDate +                          " to " + endDate +                          "\nAllocation is " + allocation +                          " to asset " + asset);    }    roleSchedule = asset.getRoleSchedule();    Collection encapSchedule =       roleSchedule.getEncapsulatedRoleSchedule(new Date("01/01/1999 00:00"),                                               new Date("12/31/1999 11:59"));    if (!encapSchedule.isEmpty()) {      Enumeration planElements = new Enumerator(encapSchedule);      while (planElements.hasMoreElements()) {        PlanElement planElement = (PlanElement)planElements.nextElement();        AllocationResult result = planElement.getEstimatedResult();        if (result != null) {          // make sure that the start and end time aspect values are defined.          // remember that they may change due to notification feedback          if ((result.isDefined(AspectType.START_TIME)) &&               (result.isDefined(AspectType.END_TIME))) {            Date eStart =               new Date((long)result.getValue(AspectType.START_TIME));            Date eEnd = new Date((long)result.getValue(AspectType.END_TIME));            if (debug) {                System.out.println(planElement + " start: " + eStart +                                    " end: " + eEnd);            }          }        }      }     }    serverPluginSupport.unsubscribeForSubscriber(subscription);      }