Program: 73652
Project: 73652
Buggy source:
/** 
 * Save a model but keep a list of models that reference it point to the old model and update the rest of the models.
 * @param xmlDBModelWithReferenceChanges An object that contains the modelto be saved, the list of parents that should have the old reference, and the new version name that will be placed as a reference in the parents' list.
 * @return A string that represents the model Id of the newly created model.
 * @exception DBConnectionException Thrown if the connection to the databasefails.
 * @exception DBExecutionException Thrown if the operation fails to execute.
 * @exception DBModelNotFoundException Thrown if the model to be saved isnot in the database.
 * @exception ModelAlreadyExistException Thrown if the new version name matchesa name of a model that is already in the database.
 * @exception IllegalArgumentException Thrown if the parameters passed are notproperly set.
 * @exception XMLDBModelParsingException Thrown if the MoML in the model objectis corrupted.
 * @exception CircularDependencyException Thrown if the save operation causes acircular dependency.
 */
public String saveWithParents(XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges) throws DBConnectionException, DBExecutionException, DBModelNotFoundException, ModelAlreadyExistException, IllegalArgumentException, XMLDBModelParsingException, CircularDependencyException {
  String newModelId="String_Node_Str";
  if (xmlDBModelWithReferenceChanges == null || xmlDBModelWithReferenceChanges.getModelToBeSaved() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(true);
    if (dbConnection == null) {
      throw new DBConnectionException("String_Node_Str");
    }
    if (xmlDBModelWithReferenceChanges != null && xmlDBModelWithReferenceChanges.getModelToBeSaved() != null && !xmlDBModelWithReferenceChanges.getModelToBeSaved().getIsNew() && xmlDBModelWithReferenceChanges.getVersionName() != null && xmlDBModelWithReferenceChanges.getVersionName().length() > 0 && xmlDBModelWithReferenceChanges.getParentsList() != null && xmlDBModelWithReferenceChanges.getParentsList().size() > 0) {
      GetModelTask getModelTask=new GetModelTask(xmlDBModelWithReferenceChanges.getModelToBeSaved().getModelName());
      XMLDBModel dbModelToBeSaved=dbConnection.executeGetModelTask(getModelTask);
      XMLDBModel newXMLDBModel=new XMLDBModel(xmlDBModelWithReferenceChanges.getVersionName());
      newXMLDBModel.setIsNew(true);
      newXMLDBModel.setModel(dbModelToBeSaved.getModel());
      newModelId=save(newXMLDBModel,dbConnection);
      newXMLDBModel.setModelId(newModelId);
      UpdateParentsToNewVersionTask updateParentsToNewVersionTask=new UpdateParentsToNewVersionTask();
      updateParentsToNewVersionTask.setNewModel(newXMLDBModel);
      updateParentsToNewVersionTask.setOldModel(xmlDBModelWithReferenceChanges.getModelToBeSaved());
      updateParentsToNewVersionTask.setParentsList(xmlDBModelWithReferenceChanges.getParentsList());
      dbConnection.executeUpdateParentsToNewVersion(updateParentsToNewVersionTask);
    }
    String oldModelId="String_Node_Str";
    oldModelId=save(xmlDBModelWithReferenceChanges.getModelToBeSaved(),dbConnection);
    if (xmlDBModelWithReferenceChanges.getModelToBeSaved().getIsNew()) {
      newModelId=oldModelId;
    }
    dbConnection.commitConnection();
  }
 catch (  DBConnectionException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  DBExecutionException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  ModelAlreadyExistException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  IllegalArgumentException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  XMLDBModelParsingException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  CircularDependencyException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  return newModelId;
}

Fixed version (ground truth):
/** 
 * Save a model but keep a list of models that reference it point to the old model and update the rest of the models.
 * @param xmlDBModelWithReferenceChanges An object that contains the modelto be saved, the list of parents that should have the old reference, and the new version name that will be placed as a reference in the parents' list.
 * @return A string that represents the model Id of the model being saved.
 * @exception DBConnectionException Thrown if the connection to the databasefails.
 * @exception DBExecutionException Thrown if the operation fails to execute.
 * @exception DBModelNotFoundException Thrown if the model to be saved isnot in the database.
 * @exception ModelAlreadyExistException Thrown if the new version name matchesa name of a model that is already in the database.
 * @exception IllegalArgumentException Thrown if the parameters passed are notproperly set.
 * @exception XMLDBModelParsingException Thrown if the MoML in the model objectis corrupted.
 * @exception CircularDependencyException Thrown if the save operation causes acircular dependency.
 */
public String saveWithParents(XMLDBModelWithReferenceChanges xmlDBModelWithReferenceChanges) throws DBConnectionException, DBExecutionException, DBModelNotFoundException, ModelAlreadyExistException, IllegalArgumentException, XMLDBModelParsingException, CircularDependencyException {
  String modelId="String_Node_Str";
  if (xmlDBModelWithReferenceChanges == null || xmlDBModelWithReferenceChanges.getModelToBeSaved() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DBConnection dbConnection=null;
  try {
    dbConnection=DBConnectorFactory.getSyncConnection(true);
    if (dbConnection == null) {
      throw new DBConnectionException("String_Node_Str");
    }
    if (!xmlDBModelWithReferenceChanges.getModelToBeSaved().getIsNew() && xmlDBModelWithReferenceChanges.getVersionName() != null && xmlDBModelWithReferenceChanges.getVersionName().length() > 0 && xmlDBModelWithReferenceChanges.getParentsList() != null && xmlDBModelWithReferenceChanges.getParentsList().size() > 0) {
      GetModelTask getModelTask=new GetModelTask(xmlDBModelWithReferenceChanges.getModelToBeSaved().getModelName());
      XMLDBModel dbModelToBeSaved=dbConnection.executeGetModelTask(getModelTask);
      XMLDBModel newXMLDBModel=new XMLDBModel(xmlDBModelWithReferenceChanges.getVersionName());
      newXMLDBModel.setIsNew(true);
      newXMLDBModel.setModel(dbModelToBeSaved.getModel());
      String newModelId=save(newXMLDBModel,dbConnection);
      newXMLDBModel.setModelId(newModelId);
      UpdateParentsToNewVersionTask updateParentsToNewVersionTask=new UpdateParentsToNewVersionTask();
      updateParentsToNewVersionTask.setNewModel(newXMLDBModel);
      updateParentsToNewVersionTask.setOldModel(xmlDBModelWithReferenceChanges.getModelToBeSaved());
      updateParentsToNewVersionTask.setParentsList(xmlDBModelWithReferenceChanges.getParentsList());
      dbConnection.executeUpdateParentsToNewVersion(updateParentsToNewVersionTask);
    }
    String oldModelId="String_Node_Str";
    modelId=save(xmlDBModelWithReferenceChanges.getModelToBeSaved(),dbConnection);
    dbConnection.commitConnection();
  }
 catch (  DBConnectionException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  DBExecutionException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  ModelAlreadyExistException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  IllegalArgumentException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  XMLDBModelParsingException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
catch (  CircularDependencyException e) {
    if (dbConnection != null) {
      dbConnection.abortConnection();
    }
    throw e;
  }
 finally {
    if (dbConnection != null) {
      dbConnection.closeConnection();
    }
  }
  return modelId;
}