System.out.println("Cloning task from same node " + tsk.getUID());
if (logger.isDebugEnabled()) { logger.debug("Cloning task from same node " + tsk.getUID()); }
  public void execute(Directive dir, Collection changes)  {    if (dir instanceof Task) {      Task tsk = (Task) dir;      try {        Task existingTask = logplan.findTask(tsk);        if (existingTask == null) {          // only add if it isn't already there.	  //System.err.print("!");          if (tsk.getWorkflow() != null) {            // Has been marked and the mark remains meaning tsk is the            // same instance as the sending agent has so we clone it            System.out.println("Cloning task from same node " + tsk.getUID());            tsk = cloneAliasedTask(tsk);          }          rootplan.add(tsk);        } else if (tsk.isDeleted()) {          if (existingTask.isDeleted()) {            rootplan.remove(existingTask); // Complete the removal          } else {            // Whoops! We must have restarted and reverted to a            // pre-deletion state.          }        } else if (tsk == existingTask) {          // This never happens any more          rootplan.change(existingTask, changes);        } else {          Preference[] newPreferences = ((TaskImpl) tsk).getPreferencesAsArray();          Preference[] existingPreferences = ((TaskImpl) existingTask).getPreferencesAsArray();          if (java.util.Arrays.equals(newPreferences, existingPreferences)) {            PlanElement pe = existingTask.getPlanElement();            if (pe != null) {              rootplan.change(pe, changes);	// Cause estimated result to be resent            }          } else {            ((NewTask) existingTask).setPreferences(tsk.getPreferences());            rootplan.change(existingTask, changes);          }        }      } catch (SubscriberException se) {        logger.error("Could not add Task to LogPlan: "+tsk);        se.printStackTrace();      }    }  }