if (!(pe instanceof Expansion)) { if (logger.isErrorEnabled()) { logger.error("publishExpansion: problem pe not Expansion?" + pe + "\n  Task:" + PublicationKey.getTotalTaskKey(task) + "\n  Parent Task:" + PublicationKey.getTotalTaskKey(parent)); } return; }  expansion = (Expansion) pe;  Hashtable published_tasks = createPublishedTable(expansion.getWorkflow().getTasks());  boolean change_expansion = false; NewTask new_task; Task prev_task; String key; PublishedTask published_task; Context context = parent.getContext();  elements = tasks.elements(); while (elements.hasMoreElements()) { new_task = (NewTask) elements.nextElement(); if (new_task.getContext() == null) new_task.setContext(context); key = taskKey(new_task);   published_task = (PublishedTask) published_tasks.get(key); if (published_task != null) { if (published_task.getPublished()) { if (logger.isErrorEnabled()) { logger.error("WARNING: publishExpansion() Change() Ack! Two PublishedElements with the same key! <" + key + ">\n TASK1:" + published_task.getTask() + "\nTASK2:" + new_task); } } else { prev_task = published_task.getTask();  if (prev_task.beforeCommitment(new Date(getAlpTime()))) {  Task t = changeTask(prev_task, new_task); if (t != null) {  delegate_.publishChange(t); change_expansion = true;  published_task.setTask(t);  } } else { if (logger.isDebugEnabled()) { logger.debug("publishExpansion() After commitment:" + prev_task.getCommitmentDate() + " task:" + key); } } } published_task.setPublished(true); } else {  publishAddTask(new_task); change_expansion = true; published_tasks.put(key, new PublishedTask(new_task, true)); } } boolean remove_from_wf = rescindUnpublishedTasks(published_tasks); if (change_expansion || remove_from_wf) {        NewWorkflow nwf = (NewWorkflow) expansion.getWorkflow();     Vector newTasks = new Vector(); Enumeration key_list = published_tasks.keys(); while (key_list.hasMoreElements()) { key = (String) key_list.nextElement(); PublishedTask ipo = (PublishedTask) published_tasks.get(key); NewTask newTask = (NewTask) ipo.getTask();  if (ipo.getPublished()) { newTasks.addElement(newTask); newTask.setWorkflow(nwf); } } nwf.setTasks(newTasks.elements()); if (expansion.getEstimatedResult() != null) { expansion.setEstimatedResult(buildExpansionResult(expansion)); } delegate_.publishChange(expansion); } }
  protected void publishExpansion(Task parent, Vector tasks) {    if (tasks.isEmpty()) {      if (logger.isErrorEnabled()) {        logger.error("publishExpansion - no tasks" + TaskUtils.taskDesc(parent));      }      return;    }    Enumeration elements = tasks.elements();    Task task = (Task) elements.nextElement();    PlanElement pe = parent.getPlanElement();    Expansion expansion;    if (pe == null) {      // In MB5.2 no longer automatically publishes tasks in a workflow.      Enumeration enum = tasks.elements();      while (enum.hasMoreElements()) {        publishAddTask((Task) enum.nextElement());      }      // create new expansion      expansion = buildExpansion(parent, tasks);      delegate_.publishAdd(expansion);      return;    }